Disable full screen for youtube api

删除回忆录丶 提交于 2019-12-03 12:17:22
StxXchedEyes

I faced the same issue and found a way to handle it that worked for me. In the OnInitializedListener() for the fragment, I do this:

@Override
public void onInitializationSuccess(Provider arg0,
final YouTubePlayer player, boolean arg2) {
//Tell the player you want to control the fullscreen change
player.setFullscreenControlFlags(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT);
//Tell the player how to control the change
player.setOnFullscreenListener(new OnFullscreenListener(){
@Override
public void onFullscreen(boolean arg0) {                    
// do full screen stuff here, or don't. I started a YouTubeStandalonePlayer 
// to go to full screen
}});

}});

And I still got an error since I used the YouTubeStandalonePlayer to handle my full screen, so I solved that by calling

finish(); 

in my OnPause() for the activity. Just remember you won't come back to where you left off if your user hits the back button. You could also send the user to the YouTube app through an intent, this did not require the finish() in OnPause when I tested it, but did not suit my needs as well as the standalone player.

Edit: If you want to remove the full-screen button, you can also just set the player style like this:

PlayerStyle style = PlayerStyle.MINIMAL;
player.setPlayerStyle(style);

Or you can just disable it by 1 line:

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