Get notifications when a Dailymotion video is played into a UIWebView

别来无恙 提交于 2019-12-08 08:23:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!