UIMoviePlayerControllerDidEnterFullscreenNotification 在 iOS8 中不起作用

Posted

技术标签:

【中文标题】UIMoviePlayerControllerDidEnterFullscreenNotification 在 iOS8 中不起作用【英文标题】:UIMoviePlayerControllerDidEnterFullscreenNotification doesn't work in iOS8 【发布时间】:2014-10-23 02:00:49 【问题描述】:

我正在使用UIWebView 使用 iFrame 播放 youtube 视频。 我正在使用UIMoviePlayerControllerDidEnterFullscreenNotification 将 youtube 屏幕检测为全屏。 如下代码:

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

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

【问题讨论】:

我也有同样的问题... :( 遇到同样的问题,任何帮助都会很棒 【参考方案1】:

markussvensson 的实现存在一些误报,因为任何 UIWindowDidBecomeVisibleNotification 都被视为不正确的全屏视频播放。

Selvin 实现的“AVPlayerItemBecameCurrentNotification”可以捕捉到电影播放开始,但不能捕捉到电影播放停止。

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

    将观察者添加到 AVPlayerItemBecameCurrentNotification 和 UIWindowDidBecomeHiddenNotification;

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

    当 UIWindowDidBecomeHiddenNotification 发生时,检查标志是否为“视频停止播放事件”。

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

【讨论】:

+1 好主意!我的方法中的一个警告是,第二次播放开始时我们没有收到AVPlayerItemBecameCurrentNotification。请参阅我的答案下方的 cmets。 对 WKWebView 的变通有什么想法吗? AVPlayerItemBecameCurrentNotification 不会在 WKWebView 中触发。不过,这似乎对 UIWebView 有效。 @SteveE 可以找到 WKWebView 检测视频播放的任何解决方案,如果你发现请在***.com/questions/55377677/…帮助我【参考方案2】:

我也有同样的问题。我没有找到真正的解决方案,但我能够使用 UIWindowDidBecomeVisibleNotification / UIWindowDidBecomeHiddenNotification 通知来解决它。

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(windowVisible:)
                                             name:UIWindowDidBecomeVisibleNotification
                                           object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(windowHidden:)
                                             name:UIWindowDidBecomeHiddenNotification
                                           object:self.view.window];

- (void)windowVisible:(NSNotification *)notification

    NSLog(@"-windowVisible");


- (void)windowHidden:(NSNotification *)notification

    NSLog(@"-windowHidden");

【讨论】:

【参考方案3】:

我同意@markussvensson。我确认没有UIMoviePlayerControllerDidEnterFullscreenNotification在iOS8上发布。

或者,您可以观察AVPlayerItemBecameCurrentNotification 以了解 YouTube 视频是否从UIWebView 全屏显示。

检查我是否在NSNotificationCenter 上写了一个钩子,以观察在视频播放期间传递的所有通知。

#import "NSNotificationCenter+Hook.h"
#import <objc/runtime.h>

@implementation NSNotificationCenter (Hook)

+ (void)load

    Method original = class_getInstanceMethod([NSNotificationCenter class], @selector(postNotificationName:object:userInfo:));
    Method swizzled = class_getInstanceMethod([NSNotificationCenter class], @selector(swizzle_postNotificationName:object:userInfo:));

    method_exchangeImplementations(original, swizzled);

    original = class_getInstanceMethod([NSNotificationCenter class], @selector(postNotificationName:object:));
    swizzled = class_getInstanceMethod([NSNotificationCenter class], @selector(swizzle_postNotificationName:object:));

    method_exchangeImplementations(original, swizzled);

    original = class_getInstanceMethod([NSNotificationCenter class], @selector(postNotification:));
    swizzled = class_getInstanceMethod([NSNotificationCenter class], @selector(swizzle_postNotification:));

    method_exchangeImplementations(original, swizzled);


- (void)swizzle_postNotificationName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo

    NSLog(@"HOOK_NOTIFICATION_With_UserInfo: %@",aName);
    [[NSNotificationCenter defaultCenter]swizzle_postNotificationName:aName object:anObject userInfo:aUserInfo];



- (void)swizzle_postNotificationName:(NSString *)aName object:(id)anObject
    NSLog(@"HOOK_NOTIFICATION_Without_UserInfo: %@",aName);
    [[NSNotificationCenter defaultCenter]swizzle_postNotificationName:aName object:anObject];


- (void)swizzle_postNotification:(NSNotification *)notification

    NSLog(@"HOOK_NOTIFICATION_NSNotification: %@",notification.name);
    [[NSNotificationCenter defaultCenter]swizzle_postNotification:notification];


@end

播放器全屏时记录数据

2014-09-29 14:07:45.808 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: 
UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.808 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.808 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.809 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.809 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIWindowSystemGestureStateChangedNotification
2014-09-29 14:07:45.809 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.810 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.810 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.810 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.810 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.810 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.812 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.812 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.819 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIWindowSystemGestureStateChangedNotification
2014-09-29 14:07:45.825 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.825 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.825 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.825 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.826 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.826 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.826 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.826 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.826 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.826 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.827 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.827 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.827 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.827 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.827 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.828 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.828 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.828 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.828 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.828 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.829 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.830 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.830 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.830 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.831 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.831 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.831 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.831 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.832 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.832 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.832 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.832 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.833 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.833 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.838 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.839 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.839 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.839 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.839 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.839 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.840 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.840 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.840 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.840 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.840 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.841 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.841 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.841 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.841 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.841 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.842 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.842 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.842 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.842 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.843 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.843 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.843 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.843 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.844 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.844 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.844 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.844 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.844 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.844 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.845 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.845 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.845 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:45.845 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.179 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIWindowFirstResponderDidChangeNotification
2014-09-29 14:07:46.180 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.180 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.180 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.180 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.181 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:46.181 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:46.219 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.219 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.219 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.219 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.220 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.220 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.220 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.220 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.220 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.220 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.221 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:46.221 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:47.398 MyProject***[3459:194167] HOOK_NOTIFICATION_With_UserInfo: AVPixelBufferAttributeMediatorPixelBufferAttributesDidChangeNotification
2014-09-29 14:07:47.398 MyProject***[3459:194167] HOOK_NOTIFICATION_With_UserInfo: AVPixelBufferAttributeMediatorPixelBufferAttributesDidChangeNotification
2014-09-29 14:07:47.398 MyProject***[3459:194167] HOOK_NOTIFICATION_With_UserInfo: AVPixelBufferAttributeMediatorPixelBufferAttributesDidChangeNotification
2014-09-29 14:07:47.399 MyProject***[3459:194167] HOOK_NOTIFICATION_With_UserInfo: AVPixelBufferAttributeMediatorPixelBufferAttributesDidChangeNotification
2014-09-29 14:07:47.400 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: AVPixelBufferAttributeMediatorPixelBufferAttributesDidChangeNotification
2014-09-29 14:07:47.424 MyProject***[3459:193561] HOOK_NOTIFICATION_NSNotification: AVPlayerItemTimebaseChangedNotification
2014-09-29 14:07:47.426 MyProject***[3459:193561] HOOK_NOTIFICATION_NSNotification: AVPlayerItemTimeJumpedNotification
2014-09-29 14:07:47.426 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: AVPixelBufferAttributeMediatorPixelBufferAttributesDidChangeNotification
2014-09-29 14:07:47.702 MyProject***[3459:193561] HOOK_NOTIFICATION_NSNotification: AVPlayerItemTimebaseChangedNotification
2014-09-29 14:07:47.702 MyProject***[3459:193561] HOOK_NOTIFICATION_NSNotification: AVPlayerItemBecameCurrentNotification
2014-09-29 14:07:47.739 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIWindowDidCreateWindowContextNotification
2014-09-29 14:07:47.740 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIWindowContentWillRotateNotification
2014-09-29 14:07:47.741 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIWindowContentWillRotateNotification
2014-09-29 14:07:47.741 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UIWindowDidBecomeVisibleNotification
2014-09-29 14:07:47.741 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIWindowDidBecomeVisibleNotification
2014-09-29 14:07:47.741 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UIWindowDidResignKeyNotification
2014-09-29 14:07:47.741 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIWindowDidResignKeyNotification
2014-09-29 14:07:47.742 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UIWindowDidBecomeKeyNotification
2014-09-29 14:07:47.742 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIWindowDidBecomeKeyNotification
2014-09-29 14:07:47.746 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.747 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.747 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.747 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.747 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.747 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.748 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.748 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.750 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.750 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.750 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.750 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.750 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.751 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.751 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.751 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.765 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.765 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.765 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.766 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.766 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.766 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.766 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.767 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: MPRemoteCommandTargetsDidChangeNotification
2014-09-29 14:07:47.900 MyProject***[3459:193561] HOOK_NOTIFICATION_NSNotification: AVPlayerItemNewAccessLogEntry
2014-09-29 14:07:47.901 MyProject***[3459:193561] HOOK_NOTIFICATION_NSNotification: AVPlayerItemTimeJumpedNotification
2014-09-29 14:07:47.903 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: _UIApplicationDidBeginIgnoringInteractionEventsNotification
2014-09-29 14:07:47.904 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIApplicationDidBeginIgnoringInteractionEventsNotification
2014-09-29 14:07:47.904 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:47.904 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:47.920 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.386 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: _UIApplicationDidEndIgnoringInteractionEventsNotification
2014-09-29 14:07:48.387 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIApplicationDidEndIgnoringInteractionEventsNotification
2014-09-29 14:07:48.387 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.387 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:48.387 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIApplicationStatusBarHeightChangedNotification
2014-09-29 14:07:48.387 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.387 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:48.390 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:48.390 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UITextEffectsWindowDidRotateNotification
2014-09-29 14:07:48.432 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.433 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:48.437 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.437 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.446 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: _UIApplicationDidBeginIgnoringInteractionEventsNotification
2014-09-29 14:07:48.447 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIApplicationDidBeginIgnoringInteractionEventsNotification
2014-09-29 14:07:48.447 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.447 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:48.450 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: _UIApplicationDidEndIgnoringInteractionEventsNotification
2014-09-29 14:07:48.450 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIApplicationDidEndIgnoringInteractionEventsNotification
2014-09-29 14:07:48.495 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:48.496 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:48.645 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:48.696 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:48.699 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:49.491 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:49.491 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:50.037 MyProject***[3459:194254] HOOK_NOTIFICATION_NSNotification: AVURLAssetDownloadCompleteSuccessNotification
2014-09-29 14:07:50.491 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:50.491 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:51.492 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:51.492 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:52.493 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:52.493 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:52.830 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: _UIApplicationDidBeginIgnoringInteractionEventsNotification
2014-09-29 14:07:52.830 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIApplicationDidBeginIgnoringInteractionEventsNotification
2014-09-29 14:07:52.830 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:53.034 MyProject***[3459:193561] HOOK_NOTIFICATION_Without_UserInfo: _UIApplicationDidEndIgnoringInteractionEventsNotification
2014-09-29 14:07:53.034 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: _UIApplicationDidEndIgnoringInteractionEventsNotification
2014-09-29 14:07:53.035 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:53.496 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:53.496 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:54.497 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:54.497 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:55.499 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:55.500 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:56.502 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:56.502 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:57.505 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:57.506 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
2014-09-29 14:07:58.508 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidCommitNotification
2014-09-29 14:07:58.508 MyProject***[3459:193561] HOOK_NOTIFICATION_With_UserInfo: UIViewAnimationDidStopNotification
(lldb) 

【讨论】:

似乎无法检测到第二次全屏事件。 这发生在 iOS 8 上吗?让我检查一下。每当从 UIWebView 进入全屏模式时,它就会触发 AVPlayerItemBecameCurrentNotification 我的情况如下: 第一步:播放全屏视频。 (全屏) ​​第 2 步:按“完成”按钮。 (非全屏) 第 3 步:通过点击 UIWebview 上的播放图标再次播放视频。 (全屏)在第 1 步触发了 AVPlayerItemBecameCurrentNotification,但在第 3 步没有触发。 @hsienwei 是的,你是对的。我没有遇到过这个问题,因为在第 2 步之后,我再次使用 youtube URL 重新加载 webview。以便 webview 显示 youtube 视频的初始阶段。然后,如果我执行第 3 步,我会得到AVPlayerItemBecameCurrentNotification。如果您不想重新加载,那么最好观察name:UIWindowDidBecomeVisibleNotification【参考方案4】:

我已尝试使用以下代码来查找替代通知名称。

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserverForName:nil
                    object:nil
                     queue:nil
                usingBlock:^(NSNotification *notification)

     NSLog(@"%@", notification.name);
];

但没有找到。 现在我正在使用HCYoutubeParser 获取直接视频网址。 并通过 MPMoviePlayerController 播放。 但这会很危险。 您不知道 Google 什么时候更改直接 url 的规则。

【讨论】:

【参考方案5】:

你做错了。

与其将整个应用程序限制为纵向模式,然后尝试让视频播放器允许横向模式,不如在整个应用程序中允许横向模式,然后将您的单个视图控制器(或根视图控制器)限制为仅允许纵向模式,像这样:

在目标设置中,为您的应用允许横向:

在您的视图控制器中,添加此项以将其限制为纵向:

-(NSUInteger)supportedInterfaceOrientations 
    return UIInterfaceOrientationMaskPortrait;

【讨论】:

以上是关于UIMoviePlayerControllerDidEnterFullscreenNotification 在 iOS8 中不起作用的主要内容,如果未能解决你的问题,请参考以下文章