切换为人像时全屏熄灭

切换为人像时全屏熄灭

本文介绍了切换为人像时全屏熄灭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用适用于Android应用程序的Youtube API,我正在寻找一种避免在横向模式之间切换时退出全屏模式的方法.意思是,我不想在将手机切换为纵向模式时退出全屏模式.我需要视频始终保持全屏显示.

I am using Youtube API for android app and I'm looking for a way to avoid exiting full-screen mode while switching between landscape modes. Meaning, I don't want to exit full-screen mode while switching the phone to portrait mode. I need the video to always be on full-screen.

有没有办法做到这一点?

Is there a way to make it happen?

我当前的全屏代码是:

@Override
    public void onInitializationSuccess(YouTubePlayer.Provider provider,
            YouTubePlayer player, boolean wasRestored) {
        if (!wasRestored) {
            Intent intent = getIntent();
            String Video_Link = intent.getStringExtra("youtube_id");
            player.cueVideo(Video_Link);
            player.setFullscreen(true);
        }
    }

非常感谢.

推荐答案

在方向更改时,将调用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...

否则,您可以尝试覆盖onconfigchange方法:

otherwise you might try overriding the onconfigchange 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
                }
    }

这篇关于切换为人像时全屏熄灭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 07:27