[英]Next/Previous buttons on iPhone MPMoviePlayerController
使用MPMoviePlayerController時,播放按鈕被“下一步”和“上一頁”按鈕包圍。
如何在點擊時收到通知? 有沒有辦法為MPMoviePlayerController提供內容列表(數組)?
如果你想要按鈕通知,Nathan對於需要為播放器實現自己的UI是正確的。 您可以從播放器獲取有關播放狀態的通知。
從AddMusic示例中,self是包含MPMusicPlayerController實例的控制器或模型:
- (void) registerForMediaPlayerNotifications {
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver: self
selector: @selector (handle_NowPlayingItemChanged:)
name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification
object: musicPlayer];
[notificationCenter addObserver: self
selector: @selector (handle_PlaybackStateChanged:)
name: MPMusicPlayerControllerPlaybackStateDidChangeNotification
object: musicPlayer];
/*
// This sample doesn't use libray change notifications; this code is here to show how
// it's done if you need it.
[notificationCenter addObserver: self
selector: @selector (handle_iPodLibraryChanged:)
name: MPMediaLibraryDidChangeNotification
object: musicPlayer];
[[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];
*/
[musicPlayer beginGeneratingPlaybackNotifications];
}
當用戶按下下一個/上一個按鈕時,不會生成任何通知(您應該提交相關的錯誤),因此在沒有任何未經批准的視圖爬行的情況下解決此問題的唯一方法是實現您自己的視頻疊加視圖:
MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:someUrl];
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
NSArray* windows = [[UIApplication sharedApplication] windows];
if ([windows count] > 1) {
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayerWindow addSubview:yourCustomOverlayView];
}
不理想,但標准控件很容易重新實現。
我認為你無法控制MPMoviePlayerController
。 它是一個標准組件,基本上可以開始和停止播放電影,沒有別的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.