按下后退按钮时,Android Youtube API退出全屏



当视频在全屏上播放时。我想按下后退按钮可以退出全屏,我一直试图超越onbackPress和onKeydown但不起作用。请帮我

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
    System.out.println("here");
    youTubePlayer.setPlayerStateChangeListener(playerStateChangeListener);
    youTubePlayer.setPlaybackEventListener(playbackeventlistener);
    youTubePlayer.setOnFullscreenListener(onFullscreenListener);
    you = youTubePlayer;
    if (b) {
         youTubePlayer.cueVideo(Video_id);
    }}

    youTubePlayer.setShowFullscreenButton(false);
    youTubePlayer.setManageAudioFocus(false);
    youTubePlayer.setFullscreen(true);
    youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.MINIMAL);
}
  @Override
public void onBackPressed() {
    super.onBackPressed();
    if (isFullscreen.equals(true)){
        you.setFullscreenControlFlags(0);
        isFullscreen = false;
        you.setFullscreen(false);

    }else {
        super.onBackPressed();
    }
}

}

你能试试这个吗?

@Override
public void onBackPressed() {
    if (isFullscreen.equals(true)){
        isFullscreen = false;
        you.setFullscreen(false);
    }else {
        super.onBackPressed();
    }
}

相关内容

  • 没有找到相关文章

最新更新