|
<div id="cnblogs_post_body">
MPMoviePlayerViewController已经实现了一些通知的监听并对MPMoviePlayerController实现了一些控制,比如:
1. 监听UIApplicationDidEnterBackgroundNotification通知,调用[movieplayer stop],播放器停止。
2. 监听MPMoviePlayerPlaybackDidFinishNotification(调用stop方法或视频播放结束时发送通知)通知,调用dismiss方法移除自身。
需求1:app中一个课程包含若干个章节,所以每次播放完一个章节后要求直接加载播放下一个课程。
遇到问题:由于MPMoviePlayerViewController监听了MPMoviePlayerPlaybackDidFinishNotification通知,当一个视频播放完毕,它会在监听方法中 调用dismissMoviePlayerViewControllerAnimated方法,播放器视图就直接移除了。
解决方法:
<div class="cnblogs_code">// self为MPMoviePlayerViewController的一个实例对象。
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; |
|