iphone - 如何知道 iPhone 中的 MPMoviePlayerController 何时已暂停?

标签 iphone notifications mpmovieplayercontroller

我想在用户暂停视频时为我的视频添加叠加 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/

相关文章:

iphone - 音频将在 iPhone 模拟器中播放,但不会在设备上播放

iphone - 使用 UIButton 按下传递对象数据

iphone - 自iOS 10以来,iOS的Youtube API不再支持Landscape?

iphone - 在自定义 MKOverlay 上绘图

ios - 一个活跃的 iOS 应用程序可以知道何时显示另一个应用程序的推送通知吗?

android - 为我的应用程序禁用清除通知

快速播放图库中的视频

Android - 如何将徽章计数添加到应用程序图标?

IOS : MPVideoView, 它的 Controller 和委托(delegate)是什么

iphone - 以 1.5 倍速、2 倍速播放视频文件