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

发布于 2024-08-31 16:08:03 字数 555 浏览 1 评论 0 原文

我想在用户暂停视频时为我的视频添加叠加视图。有什么方法可以从 MPMoviePlayerController 获取暂停通知吗?

根据Apple Doc,应该有办法做到这一点,但我找不到应该使用哪个通知来实现此目的。

引用:

除了在以下情况下收到通知之外 播放完毕,感兴趣的客户 可以通过以下方式通知 情况:

-当电影播放器​​开始播放、暂停或开始向前播放时 ... 有关详细信息,请参阅本参考中的通知部分。

I want to add an overlay view for my video when the video is paused by the user. Is there any way to get the pause notification from MPMoviePlayerController?

According to Apple Doc, there should be ways to do this but I can't find which notification should I use for this purpose.

Quote:

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫言歌 2024-09-07 16:08:03

我假设您了解委托和协议作为接收回调的方式?

还有另一种称为通知的全局机制。

您可以通过以下方式执行此操作

[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(playbackStateChanged) 
    name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

然后,在playbackStateChanged内,您可以获取playbackState

 - (void) playbackStateChanged {

   _player.playbackState; // reading the playback

 }

直接从播放器读取playbackstate的步骤在文档中指定

要获取当前播放状态,请获取影片播放器对象的playbackState 属性的值。

I assume you know about delegates and protocols as a means of receiving callbacks?

There's another global mechanism called notifications too.

You can do this via

[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(playbackStateChanged) 
    name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];

Then, within playbackStateChanged, you can fetch the playbackState

 - (void) playbackStateChanged {

   _player.playbackState; // reading the playback

 }

The step of reading playbackstate directly from the player is specified in the docs

To get the current playback state, get the value of the playbackState property of the movie player object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文