2012-11-28 55 views

回答

0

添加觀察員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]; 
+0

謝謝你!幫助! – iCode

0

保持它包含所有視頻列表中的陣列可以發揮。首先在歌曲完成後將歌曲分配給播放器,您可以像這樣調用歌曲。這僅僅是一個例子。

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

然後在該方法中釋放前一個播放器併爲新播放器分配新歌曲。重複全部播放。