0

I have a VideoView in which I want to play video after buffering complete.

I have managed two different xml code layouts for landscape and portrait each.

My issue is that when I change orientation of device, the video buffering restart again.

gauravsheohar
  • 396
  • 5
  • 12
Nilesh Patel
  • 137
  • 6

2 Answers2

0

Try putting

android:configChanges="screenOrientation" in the activity tag of your Manifest file.

This way the activity will not be recreated.

I think this will help you.

Rakesh Gondaliya
  • 1,050
  • 3
  • 25
  • 42
0

actually you have to do a couple of things firstly handle the orientation yourself to do this you have to add this under the activity

android:configChanges="keyboardHidden|orientation|screenSize"

now override onConfigurationChanged inside your activity.java file

After this it depends on your layout if there is anything under the videoview then hide it and change the layout params of the videoview like this,

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
     //your logic for landscape
    } else {
            //your logic for potrait
    }
}

Ps:things might not go very smoothly during orientation change in videoview, refer this answer also it might be helpful Android VideoView orientation change with buffered video

Community
  • 1
  • 1
Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52