0
我有一個默認媒體播放器,我想依次播放視頻。我該怎麼做? 任何簡單的方法?在MPMoviePlayer
如何在iOS中順序播放視頻 - 目標C
我有一個默認媒體播放器,我想依次播放視頻。我該怎麼做? 任何簡單的方法?在MPMoviePlayer
如何在iOS中順序播放視頻 - 目標C
添加觀察員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];
保持它包含所有視頻列表中的陣列可以發揮。首先在歌曲完成後將歌曲分配給播放器,您可以像這樣調用歌曲。這僅僅是一個例子。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackStateChanged)
name: MPMoviePlayerPlaybackDidFinishNotification object:nil];
然後在該方法中釋放前一個播放器併爲新播放器分配新歌曲。重複全部播放。
謝謝你!幫助! – iCode