使用MPMoviePlayerController时,播放按钮被“下一步”和“上一页”按钮包围。
点击后如何收到通知? 有没有办法为MPMoviePlayerController提供内容列表(数组)?
答案 0 :(得分:6)
如果您想要按钮通知,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];
}
答案 1 :(得分:4)
当用户按下下一个/上一个按钮时,不会生成任何通知(您应该提交相关的错误),因此在没有任何未批准的视图抓取的情况下解决此问题的唯一方法是实现您自己的视频叠加视图:
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];
}
不理想,但标准控件很容易重新实现。
答案 2 :(得分:0)
我认为您无法控制MPMoviePlayerController
。它是一个标准组件,基本上可以开始和停止播放电影而不是别的。