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.