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

时间:2015-12-24 07:15:24

标签: android youtube fullscreen onbackpressed

当视频在Fullscreen上播放时。我想按下后退按钮可以退出全屏,我一直尝试覆盖 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();
    }
}

}

1 个答案:

答案 0 :(得分:2)

你能试试吗?

var Startdatetime = DateTime.ParseExact(startdate.Substring(0, 24), "ddd MMM d yyyy HH:mm:ss", CultureInfo.InvariantCulture);