【问题标题】:Youtube api full screen portrait mode videos androidYoutube api 全屏人像模式视频 android
【发布时间】:2017-01-19 05:01:29
【问题描述】:

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

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

【问题讨论】:

    标签: android youtube youtube-api android-youtube-api


    【解决方案1】:

    你可以在这个SO answer看到关于如何在手机处于竖屏模式的情况下保持全屏模式的解决方案。

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

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

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

    您也可以尝试覆盖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

    setFullscreenControlFlags(int) 的标志以启用方向的自动控制。

    该行为是在进入全屏时强制横向设置并在离开全屏时切换回原始方向设置。当设备旋转回纵向时,该实现也会自动退出全屏。 这通常应该设置,除非应用程序被锁定为横向或您需要纵向全屏

    希望这会有所帮助!

    【讨论】:

    • 感谢您的帮助。我确实尝试过覆盖 onConfigurationChanged,但它不能自行工作。因为 FULLSCREEN_FLAG_CONTROL_ORIENTATION 标志是默认设置的。所以你必须通过简单的设置来删除那个位: setFullscreenControlFlags(FULLSCREEN_FLAG_CONTROL_SYSTEM_UI);并且如果视频以竖屏模式上传到youtube,进入全屏时会以竖屏模式显示。
    • @donny.rewq... 拯救了我的一天。我整个早上都在挖,但你的答案很到位。谢谢:)
    • 实现与官方YouTube应用相同的行为就这么简单:stackoverflow.com/questions/53242972/…
    • The implementation will also exit fullscreen automatically when the device is rotated back to portrait orientation 这是一个大问题 - 当它在按下全屏按钮后强制横向时,它可以立即离开该全屏模式(因为你以纵向方式握住手机)如果你不这样做' t 将手机快速旋转到横向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 2012-06-21
    • 2015-07-03
    • 1970-01-01
    相关资源
    最近更新 更多