我想知道如何使用MPMoviePlayerViewController最有效地播放一系列視頻?iPad SDK:如何使用MPMoviePlayerViewController播放一系列視頻
例如,我想在一個系列播放以下:
Video1.mp4 Video2.mp4 Video3.mp4
等等...
任何建議表示讚賞。
我想知道如何使用MPMoviePlayerViewController最有效地播放一系列視頻?iPad SDK:如何使用MPMoviePlayerViewController播放一系列視頻
例如,我想在一個系列播放以下:
Video1.mp4 Video2.mp4 Video3.mp4
等等...
任何建議表示讚賞。
使用NSNotificationCenter
來監視MPMoviePlayerPlaybackDidFinishNotification
通知。然後,用你想玩的下一個項目設置玩家。
您可以用[NSNotificationCenter defaultCenter]
註冊通知MPMoviePlayerPlaybackDidFinishNotification
。一旦您收到該通知,只需加載下一個視頻並開始播放。
查看相應的類文檔以獲取更多詳細信息。
我確實有註冊的回調。我確實在我可以跟蹤的數組中有文件名。您是否建議將播放方法添加到 MPMoviePlayerPlaybackDidFinishNotification?謝謝。 // ---播放電影--- MPMoviePlayerController * player = [playerViewController moviePlayer]; [玩家播放]; – butchcowboy 2010-07-24 18:50:32
是的,但是您需要使用'-setContentURL:'將其設置爲下一部電影,然後播放它。 – jtbandes 2010-07-24 18:53:23
謝謝但仍然有問題。出於某種原因,我無法訪問包含fileNames的數組。此代碼在viewDidLoad中工作,但從MPMoviePlayerPlaybackDidFinishNotificaition拋出異常。這是訪問字符串數組的代碼。我怎樣才能從回調中訪問這個數組? \t \t NSString * string = [arrayBrotherPirateEnglish objectAtIndex:2]; 2010-07-26 14:13:17.391 BookReaderJuly23 [51927:207] ***由於未捕獲的異常'NSInvalidArgumentException',原因:'*** - [NSCFType objectAtIndex:]:無法識別的選擇器發送到實例0x5340b10' – butchcowboy 2010-07-26 18:17:03