Notification after Video playback in mobile safari

2019-09-03 19:50发布

问题:

I am trying to play some videos in a UIWebView and required to get some feedback when the video playback is finished, without any user interaction. I am looking for something similar to MPMoviePlayerPlaybackDidFinishNotification, but in UIWebView. Appreciate if anyone can share a work around.

回答1:

I can't vouch for all video types but when I play a YouTube video in a UIWebView I can capture the event when the user presses 'Done' by subscribing to a private notification type:

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

This works in iOS 4.3 and 5.0.