YouTubePlayerSupportFragment fullscreen button forces orientation change and does not enter fullscreen

坚强是说给别人听的谎言 提交于 2019-12-24 03:22:30

问题


i am creating YouTubePlayerSupportFragment. Playing in portrait mode works just fine. As soon as i click the fullscreen button of the player it forces an orientation change and recreates the activity i am in (the video stops playing and the fragment is recreated).

this is how i create the fragment:

fragment = (YouTubePlayerSupportFragment) getSupportFragmentManager().findFragmentById(R.id.youtube_fragment);
fragment.initialize(Config.YOUTUBE_API_KEY, this);

The only similar thing on StackOverflow I could find was this question: YouTubePlayerSupportFragment starts duplicate Activity

This guy has the same problem but no answer so far.


回答1:


I had the same issue and apparently it's defined behaviour. You can disable it like this (for example in onInitializationSucces):

@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean success) {
    player.setFullscreenControlFlags(0);

More info here.




回答2:


my problem was i did't call super.onSaveInstanceState(b) on my own onSaveInstanceState...



来源:https://stackoverflow.com/questions/18105140/youtubeplayersupportfragment-fullscreen-button-forces-orientation-change-and-doe

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