问题
I'm currently showing a dailymotion url directly into a UIWebview. When tapping on the thumbnail image, the video starts playing in fullscreen mode.
The problem is: when the video stops playing or the user tapps the "done" button, the original thumbnail has disapeared from the UIWebview, making it impossible to launch the video again. I would like to control when the video has finished playing or the user has tapped the done button to reload the UIWebView.
I've been looking around and playing with the Notification center but I couldn't get any response, can you tell me what code I should use ?
loading the video
NSURLRequest *requestObject = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.dailymotion.com/embed/video/xh7cgv_cine-pocket-a-candidate_creation"]];
[self.webv loadRequest:requestObject];
notification catch
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerDidExitFullscreen:)
name:MPMoviePlayerDidExitFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerDidEnterFullscreenNotification:)
name:MPMoviePlayerDidEnterFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
thanks, Louis
回答1:
corresponding to this thread the MediaPlayer doesn't send out any notifications when started from within the UIWebView (no source given however). you could try these hacks: visible-hidden events hack, timed key window checking-hack, subview events-hack. If you had luck, please share some code!
来源:https://stackoverflow.com/questions/5628691/get-notifications-when-a-dailymotion-video-is-played-into-a-uiwebview