Подтвердить что ты не робот

UIMoviePlayerControllerDidEnterFullscreenNotification не работает в iOS8

Я использую UIWebView для воспроизведения видео с YouTube с помощью iFrame.
Я использую UIMoviePlayerControllerDidEnterFullscreenNotification для обнаружения экрана youtube в полноэкранном режиме.
Как ниже код:

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

Он работает в iOS7.
Но я пытаюсь запустить его в iOS8.
Это не работает.
Я думаю, что имя уведомления было изменено.
Есть ли альтернатива для обнаружения полноэкранного события youtube в ios8?

4b9b3361

Ответ 1

Реализация markussvensson имеет некоторые ложные тревоги, так как любая UIWindowDidBecomeVisibleNotification считается полноэкранным воспроизведением видео, что не соответствует действительности.

Реализация "AVPlayerItemBecameCurrentNotification" от Selvin может запускать начало воспроизведения фильма, но не может остановить остановку воспроизведения фильма.

Итак, я объединил обе реализации и работает как ожидалось.

  • Добавить наблюдателя как для AVPlayerItemBecameCurrentNotification, так и для UIWindowDidBecomeHiddenNotification;

  • Когда происходит AVPlayerItemBecameCurrentNotification, установите флаг:

  • Когда происходит UIWindowDidBecomeHiddenNotification, отметьте флаг, чтобы увидеть, является ли это событием воспроизведения видеоизображения.

BTW, AVPlayerItemBecameCurrentNotification недокументирован и может быть разорван для следующего релиза iOS.

Ответ 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. И я подтверждаю, что на iOS8 нет UIMoviePlayerControllerDidEnterFullscreenNotification.

В качестве альтернативы вы можете наблюдать за AVPlayerItemBecameCurrentNotification, чтобы узнать, будет ли видео YouTube выходить в полноэкранном режиме из UIWebView.

Чтобы проверить, что я написал hook на 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) 

Ответ 4

Я попытался использовать ниже код, чтобы найти альтернативное имя уведомления.

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserverForName:nil
                    object:nil
                     queue:nil
                usingBlock:^(NSNotification *notification)
{
     NSLog(@"%@", notification.name);
}];

но не найдено.
теперь я использую HCYoutubeParser, чтобы получить прямой URL-адрес видео.
и воспроизвести его через MPMoviePlayerController.
но это будет опасно.
Вы не представляете, в какое время Google изменит правило на прямой URL.

Ответ 5

Вы идете об этом неправильно.

Вместо того, чтобы ограничивать все приложение "Портрет", а затем пытаться сделать видеоплеер доступным для просмотра, вы должны позволить пейзажу повсюду, а затем ограничьте свои невидимые контроллеры представлений (или контроллер корневого представления) только для режима "Портрет", вот так:

В целевых настройках разрешите ландшафт для вашего приложения:

введите описание изображения здесь

В вашем контроллере (-ях) просмотра добавьте это, чтобы ограничить его ориентацией по книгам:

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}