Youtube api 全屏纵向模式视频 android

Youtube api full screen portrait mode videos android

使用 YouTube 应用程序可以纵向全屏播放纵向模式视频,这可以通过 android 中的 youtube 播放器 api 实现吗?

这就是我指的: http://thenextweb.com/apps/2015/07/22/you-can-now-watch-vertical-videos-in-full-screen-on-youtubes-android-app/

你可以在这个SO answer中看到如何在phone处于竖屏模式时保持全屏模式的解决方案。

On an orientation change, the onCreate method is called. You could try adding this line within the Activity in question in your Manifest file to prevent the onCreate call.

android:configChanges="orientation|keyboardHidden|screenSize|layoutDirection"

and it might maintain the fullscreen status of youtube for you.

您也可以尝试覆盖 onConfigurationChanged 方法:

@Override //reconfigure display properties on screen rotation
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

            //Checks the orientation of the screen
            if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) 
                {
                // handle change here
                } 
            else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                // or here
                }
    }

你也可以阅读这个documentation:

Flag for setFullscreenControlFlags(int) to enable automatic control of the orientation.

The behavior is to force landscape orientation when entering fullscreen and switching back to the original orientation setting when leaving fullscreen. The implementation will also exit fullscreen automatically when the device is rotated back to portrait orientation. This should generally be set unless the application is locked in landscape orientation or you require fullscreen in portrait orientation.

希望对您有所帮助!