YouTube API全屏人像模式视频android [英] Youtube api full screen portrait mode videos android

查看:109
本文介绍了YouTube API全屏人像模式视频android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

纵向模式视频可以使用YouTube应用以纵向显示全屏播放,这可以通过Android中的youtube播放器API实现吗?

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?

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

推荐答案

您可以在此 SO answer 中找到解决方案关于即使手机处于纵向模式也如何保持全屏模式的信息.

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.

在方向更改时,将调用onCreate方法.你可以试试 在清单文件中的相关活动中添加此行 以防止onCreate调用.

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"

,它可能会为您保持youtube的全屏状态.

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

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

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

您还可以阅读文档:

setFullscreenControlFlags(int) 即可自动控制方向.

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.

希望这会有所帮助!

这篇关于YouTube API全屏人像模式视频android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆