UIMoviePlayerControllerDidEnterFullscreenNotification 在 iOS8 中不起作用 [英] UIMoviePlayerControllerDidEnterFullscreenNotification doesn't work in iOS8

查看:26
本文介绍了UIMoviePlayerControllerDidEnterFullscreenNotification 在 iOS8 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UIWebView 通过 iFrame 播放 YouTube 视频.
我正在使用 UIMoviePlayerControllerDidEnterFullscreenNotification 将 youtube 屏幕检测为全屏.
像下面的代码:

I am using UIWebView to play a youtube video with iFrame.
I am using UIMoviePlayerControllerDidEnterFullscreenNotification to detect youtube screen into fullscreen.
Like below code :

[[NSNotificationCenter defaultCenter] addObserver: self
                                         selector: @selector(myMovieEnterFullScreen:)
                                             name: @"UIMoviePlayerControllerDidEnterFullscreenNotification"
                                           object: nil];

适用于iOS7.
但我尝试在 iOS8 中运行它.
它不起作用.
我认为通知名称已更改.
有没有其他方法可以检测 ios8 中的 youtube 全屏事件?

It works in iOS7.
But I try to run it in iOS8.
It doesn't work.
I think the notification name has be changed.
Has any alternative to detect the youtube fullscreen event in ios8?

推荐答案

markussvensson 的实现有一些误报,因为任何 UIWindowDidBecomeVisibleNotification 都被认为是全屏视频播放,这是不正确的.

The implementation by markussvensson has some false alarms, since any UIWindowDidBecomeVisibleNotification is considered as a full screen video playback which is not true.

Selvin 的AVPlayerItemBecameCurrentNotification"实现可以捕捉到电影播放的开始,但是不能捕捉到电影播放的停止.

The implementation "AVPlayerItemBecameCurrentNotification" by Selvin can catch movie playback start, but cannot catch movie playback stop.

所以我结合了这两种实现,它按预期工作.

So I combined both implementations and it works as expected.

  1. 将观察者添加到 AVPlayerItemBecameCurrentNotification &UIWindowDidBecomeHiddenNotification;

  1. Add observer to both AVPlayerItemBecameCurrentNotification & UIWindowDidBecomeHiddenNotification;

当 AVPlayerItemBecameCurrentNotification 发生时,设置一个标志;

When AVPlayerItemBecameCurrentNotification happens, set a flag;

当 UIWindowDidBecomeHiddenNotification 发生时,检查标志看是否是视频停止播放事件".

When UIWindowDidBecomeHiddenNotification happens, check the flag to see if it is a "video stop playing event".

顺便说一句,AVPlayerItemBecameCurrentNotification 没有记录,可能会在下一个 iOS 主要版本中被破坏.

BTW, AVPlayerItemBecameCurrentNotification is undocumented and might be broken for the next iOS major release.

这篇关于UIMoviePlayerControllerDidEnterFullscreenNotification 在 iOS8 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆