I am using UIWebView
to play a youtube video with iFrame.
I am using UIMoviePlayerControllerDidEnterFullscreenNotification
to detect youtube screen into fullscreen.
Like below code :
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(myMovieEnterFullScreen:) name: @"UIMoviePlayerControllerDidEnterFullscreenNotification" object: nil];
It works in iOS7.
But I try to run it in iOS8.
It doesn't work.
I think the notification name has be changed.
Has any alternative to detect the youtube fullscreen event in ios8?
The implementation by markussvensson has some false alarms, since any UIWindowDidBecomeVisibleNotification is considered as a full screen video playback which is not true.
The implementation "AVPlayerItemBecameCurrentNotification" by Selvin can catch movie playback start, but cannot catch movie playback stop.
So I combined both implementations and it works as expected.
Add observer to both AVPlayerItemBecameCurrentNotification & UIWindowDidBecomeHiddenNotification;
When AVPlayerItemBecameCurrentNotification happens, set a flag;
When UIWindowDidBecomeHiddenNotification happens, check the flag to see if it is a "video stop playing event".
BTW, AVPlayerItemBecameCurrentNotification is undocumented and might be broken for the next iOS major release.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With