Youtube api full screen portrait mode videos android

核能气质少年 提交于 2019-12-25 07:25:23

问题


Portrait mode videos can be played full screen in portrait orientation with the YouTube app, is this possible to achieve with the youtube player api in android?

This is what I am referring to: http://thenextweb.com/apps/2015/07/22/you-can-now-watch-vertical-videos-in-full-screen-on-youtubes-android-app/


回答1:


You can see in this SO answer the solution on how to retain the full-screen mode even if the phone is in portrait mode.

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.

You can also try overriding the onConfigurationChanged method:

@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
                }
    }

You can also read this 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.

Hope this helps!



来源:https://stackoverflow.com/questions/39438761/youtube-api-full-screen-portrait-mode-videos-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!