我想在用户暂停视频时为我的视频添加叠加 View 。有什么方法可以从 MPMoviePlayerController 获取暂停通知吗?
根据Apple Doc ,应该有办法做到这一点,但我找不到应该使用哪个通知来实现此目的。
引用:
In addition to being notified when playback finishes, interested clients can be notified in the following situations:
-When the movie player begins playing, is paused, or begins seeking forward ... For more information, see the Notifications section in this reference.
最佳答案
我假设您了解委托(delegate)和协议(protocol)作为接收回调的方式?
还有另一种全局机制,称为通知。
您可以通过以下方式执行此操作
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackStateChanged)
name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
然后,在playbackStateChanged中,您可以获取playbackState
- (void) playbackStateChanged {
_player.playbackState; // reading the playback
}
文档中指定了直接从播放器读取playbackstate的步骤
To get the current playback state, get the value of the playbackState property of the movie player object.
关于iphone - 如何知道 iPhone 中的 MPMoviePlayerController 何时已暂停?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2797061/