2014-08-29 14 views
23

Używam UIWebView do odtwarzania wideo z youtube z iFrame.
Używam UIMoviePlayerControllerDidEnterFullscreenNotification do wykrywania ekranu youtube na pełnym ekranie.
jak poniżej kodu:UIMoviePlayerControllerDidEnterFullscreenNotification nie działa w iOS8

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

Działa w iOS7.
Ale staram się uruchomić go w iOS8.
To nie działa.
Myślę, że nazwa powiadomienia została zmieniona.
Czy istnieje jakaś alternatywa dla wykrycia zdarzenia pełnego ekranu youtube w ios8?

+0

Mam ten sam problem ... :( – duongvanthai

+0

Jakiekolwiek obejścia? – iPP

+0

przechodząc przez ten sam problem, anyhelp byłby świetny –

Odpowiedz

14

wdrożenia przez markussvensson ma kilka fałszywych alarmów, ponieważ każdy UIWindowDidBecomeVisibleNotification jest traktowany jako pełnoekranowego odtwarzania wideo, która nie jest prawdą.

Implementacja "AVPlayerItemBecameCurrentNotification" autorstwa Selvina może rozpocząć odtwarzanie filmu, ale nie może zatrzymać zatrzymania odtwarzania filmu.

Połączyłem więc obydwie implementacje i działa zgodnie z oczekiwaniami.

  1. Dodaj obserwatora zarówno AVPlayerItemBecameCurrentNotification & UIWindowDidBecomeHiddenNotification;

  2. Gdy nastąpi AVPlayerItemBecameCurrentNotification, ustaw flagę;

  3. Kiedy nastąpi UIWindowDidBecomeHiddenNotification, zaznacz flagę, aby sprawdzić, czy jest to "zdarzenie zatrzymania odtwarzania wideo".

BTW, AVPlayerItemBecameCurrentNotification jest nieudokumentowane i może zostać złamane w następnej wersji głównej iOS.

+1

+1 dobra myśl! Jedynym zastrzeżeniem w moim podejściu jest to, że po drugim uruchomieniu odtwarzania nie otrzymujemy 'AVPlayerItemBecameCurrentNotification'. Zobacz komentarze poniżej mojej odpowiedzi. – Selvin

+2

Jakieś przemyślenia na temat pracy w WKWebView? "AVPlayerItemBecameCurrentNotification" nie zostanie wyzwolone w WKWebView. Wygląda jednak na to, że działa w UIWebView. –

0

Próbowałem użyć poniższego kodu, aby znaleźć alternatywną nazwę powiadomienia.

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

ale nie znaleziono.
teraz używam HCYoutubeParser, aby uzyskać bezpośredni URL wideo.
i zagraj w MPMoviePlayerController.
, ale będzie to niebezpieczne.
Nie masz pojęcia, o której godzinie Google zmieni regułę na bezpośredni adres URL.

10

Mam ten sam problem. Nie znalazłem żadnego prawdziwego rozwiązania, ale udało mi się go obejść za pomocą powiadomień 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"); 
} 
5

Zgadzam się z @markussvensson. I potwierdzam, że nie ma UIMoviePlayerControllerDidEnterFullscreenNotification umieszczonego na iOS8.

Możesz też obejrzeć na stronie AVPlayerItemBecameCurrentNotification, aby sprawdzić, czy wideo z youtube jest wyświetlane na pełnym ekranie od UIWebView.

Aby sprawdzić, czy napisałem hak na NSNotificationCenter, aby obserwować wszystkie powiadomienia przekazywane podczas odtwarzania wideo.

#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 

danych dziennika, gdy gracz staje pełnoekranowym

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) 
+0

wydaje się, że nie można wykryć po raz drugi zdarzenia pełnoekranowego. – hsienwei

+0

czy dzieje się to na iOS 8? Pozwól mi to sprawdzić. Wystrzelił "AVPlayerItemBecameCurrentNotification" po wejściu do trybu pełnoekranowego z UIWebView. – Selvin

+0

Moja sytuacja, jak poniżej: Krok 1: odtworzyć wideo na pełnym ekranie. (pełny ekran) Krok 2: naciśnij przycisk "Gotowe". (nie w trybie pełnoekranowym) Krok 3: Odtwórz ponownie wideo, dotykając ikony odtwarzania w interfejsie użytkownika interfejsu użytkownika. (pełny ekran) W kroku 1, AVPlayerItemBecameCurrentNotification jest wyzwalane, ale nie jest wyzwalane w kroku 3. – hsienwei

0

Podejmujesz się tego w niewłaściwy sposób.

Zamiast ograniczać całą aplikację do portretu, a następnie próbować sprawić, aby odtwarzacz wideo zezwalał na krajobraz, należy zamiast tego zezwolić krajobrazowi na całą aplikację, a następnie ograniczyć swoje pojedyncze kontrolery widoku (lub kontroler widoku root), aby zezwolić tylko na portret. tryb, jak ten:

w ustawieniach systemu docelowego, pozwalają krajobrazu dla swojej aplikacji:

enter image description here

w kontrolerze widoku (s), dodać to do ograniczenia go do orientacji pionowej:

-(NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 
Powiązane problemy