问题
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