当 Dailymotion 视频播放到 UIWebView 中时获取通知

发布于 2024-10-31 16:12:13 字数 1434 浏览 0 评论 0原文

我目前正在将 dailymotion url 直接显示到 UIWebview 中。 点击缩略图时,视频开始以全屏模式播放。

问题是:当视频停止播放或用户点击“完成”按钮时,原始缩略图已从 UIWebview 中消失,从而无法再次启动视频。 我想控制视频何时完成播放或用户点击完成按钮来重新加载 UIWebView。

我一直在环顾四周并使用通知中心,但我无法得到任何响应,你能告诉我应该使用什么代码吗?

加载视频

    NSURLRequest *requestObject = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.dailymotion.com/embed/video/xh7cgv_cine-pocket-a-candidate_creation"]];
[self.webv loadRequest:requestObject];

通知捕获,

[[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];

谢谢, 路易斯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

平生欢 2024-11-07 16:12:13

与此线程相对应,MediaPlayer 在以下情况下不会发送任何通知从 UIWebView 内部开始(但是没有给出来源)。你可以尝试这些技巧: 可见隐藏事件黑客定时关键窗口检查黑客子视图事件黑客< /a>.如果您幸运的话,请分享一些代码!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文