【发布时间】:2011-09-12 09:28:23
【问题描述】:
如何给 MPMoviePlayerViewController 设置通知?和 MPMoviePlayerController 中的一样吗?
请显示示例
【问题讨论】:
标签: objective-c ios mpmovieplayercontroller nsnotificationcenter
如何给 MPMoviePlayerViewController 设置通知?和 MPMoviePlayerController 中的一样吗?
请显示示例
【问题讨论】:
标签: objective-c ios mpmovieplayercontroller nsnotificationcenter
MPMoviePlayerView控制器只是一个包装器,为您提供对 MPMoviePlayerController 的控制。
MPMoviePlayerViewController 有自己的MPMoviePlayerController,它会发送您使用它所需的所有通知。
收听通知如下:
// Register for the playback finished notification
[[NSNotificationCenter defaultCenter] addObserver:self // the object listening / "observing" to the notification
selector:@selector(myMovieFinishedCallback:) // method to call when the notification was pushed
name:MPMoviePlayerPlaybackDidFinishNotification // notification the observer should listen to
object:self.moviePlayerViewController.moviePlayer]; // the object that is passed to the method
MPMoviePlayerController Class Reference 中列出了更多您可以并且应该使用的通知
所以基本上,是的 - 您可以使用与 MPMoviePlayerController 中相同的通知
【讨论】: