Youtubeapi非法状态排除玩家已被释放

时间:2013-12-16 08:53:57

标签: android youtube-api android-youtube-api

我在我的应用上使用YoutubeAPI,但我收到以下代码illegalstateexception。它说player has been released。我该如何克服这个问题

@Override
    protected void onResume() {

            if (video_player != null ){

                video_player.seekToMillis(pausedDuration);

        }
        // <-- this will cause re-buffer.
        super.onResume();
    }

编辑1 播放器的初始化

@Override
    public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,boolean wasRestored) {
        if (!wasRestored) {

            player.cueVideo(video_URL);
            video_player=player;
            prev_cat=cat_id;

        }
    }

另外, 我无法观看全屏视频

全屏代码

12-16 15:02:38.859: D/YouTubeAndroidPlayerAPI(22422): apps.youtube.core.player.Director.a:473 VideoStage: NEW
12-16 15:02:38.969: E/YouTubeAndroidPlayerAPI(22422): apps.youtube.core.player.Director.F:521 Media progress reported outside media playback
12-16 15:02:38.979: D/YouTubeAndroidPlayerAPI(22422): apps.youtube.core.player.sequencer.a.<init>:41 SequencerStage: New o
12-16 15:02:38.979: D/YouTubeAndroidPlayerAPI(22422): apps.youtube.core.player.sequencer.a.a:46 SequencerStage: NEW
12-16 15:02:38.989: D/YouTubeAndroidPlayerAPI(22422): apps.youtube.core.player.Director.a:627 PlaybackState reset by init
12-16 15:02:39.019: D/YouTubeAndroidPlayerAPI(22422): apps.youtube.core.player.sequencer.a.a:46 SequencerStage: VIDEO_LOADING 

1 个答案:

答案 0 :(得分:0)

我通过在Activity的onDestroy中使videoPlayer为空来克服了这个问题。