1

I am working on a project where I am showing a live streaming video in android. I am showing the video in video view. I want to provide facility of landscape and portrait video view to the user. If I rotate the device the video should be bigger in width. But currently If I do so it takes lots of time to reload the video from the web. Is it possible that video should work fine for this. I mean it should play normally and just the width increase. I am able to achieve the same in iOS.

Please suggest

Sanchit Paurush
  • 6,114
  • 17
  • 68
  • 107

2 Answers2

0

You can try this

public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        questionVideo.setDimensions(displayHeight, displayWidth);
        questionVideo.getHolder().setFixedSize(displayHeight, displayWidth);

    } else {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

        questionVideo.setDimensions(displayWidth, smallHeight);
        questionVideo.getHolder().setFixedSize(displayWidth, smallHeight);

    }
}
Sanchit Paurush
  • 6,114
  • 17
  • 68
  • 107
Manasi
  • 348
  • 1
  • 4
  • 14
0

Try this....

android:configChanges="orientation"

In your Activity in AndroidManifest.xml. This way your Activity wont be restarted automatically. See the documentation for more information..

Android
  • 106
  • 5