当使用 MPMoviePlayerController 时,播放按钮被“Next”和“Previous”按钮包围。
当它们被点击时如何获得通知?有没有办法为 MPMoviePlayerController 提供内容列表(数组)?
当使用 MPMoviePlayerController 时,播放按钮被“Next”和“Previous”按钮包围。
当它们被点击时如何获得通知?有没有办法为 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
. 它是一个标准组件,基本上可以开始和停止播放电影,仅此而已。