MPMoviePlayerPlaybackDidFinishNotification being called again in iPhone 4.3 simulator when setting contentURL

丶灬走出姿态 提交于 2019-12-03 15:15:08

I had the same problem. and solved it this way:

I created a new method to skip a video

- (void) skipVideo {
    [_moviePlayer stop];
}

Stopping the player in skipVideo will cause a MPMovieFinishReasonPlaybackEnded notification (in simulator and on device). When setting contentUrl of player now, no other MPMovieFinishReasonPlaybackEnded notification is caused, so moviePlayBackDidFinish is called only once;

Before playing next video (in playNextVideo) you have to call

[_moviePlayer prepareToPlay];

That works fine for me!

You can create new player for next track:

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: _movieUrl];
if (player)
{
    [self setMoviePlayer:player];
}
[self.moviePlayer play];

Instead of

self.moviePlayer.contentURL = _movieUrl;

Notification MPMoviePlayerPlaybackDidFinishNotification will called once.

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