0

我有一个默认的媒体播放器,我想依次播放视频。我该怎么做?有什么简单的方法吗?

4

2 回答 2

0

MPMoviePlayer在for中添加观察者MPMoviePlayerPlaybackDidFinishNotification

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:yourMPMoviePlayerObject];

-(void)myMovieFinished:(NSNotification*)aNotification
{
    MPMoviePlayerController *moviePlayer = [aNotification object];
    //maintain index of video in this method as each time video URL will be different
    [moviePlayer setContentURL:nextVideoURLhere];
    [moviePlayer play];
}

不需要时删除:

[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidFinishNotification object:yourMPMoviePlayerObject];
于 2012-11-28T12:21:19.243 回答
0

维护一个包含所有要播放的视频列表的数组。先将歌曲分配给播放器,歌曲完成后就可以这样调用了。这只是一个例子。

[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(playbackStateChanged) 
    name: MPMoviePlayerPlaybackDidFinishNotification object:nil];

然后在该方法中释放以前的播放器并为新播放器分配新歌曲。对 all 重复相同的操作。

于 2012-11-28T12:28:47.257 回答