如何在 uiwebview iOS 中处理 YouTube 视频事件(开始、结束等)
目前,我正在使用新的 iframe API 将 YouTube 视频嵌入 iPad 上的 uiwebview 中,并且无需用户交互即可使其自动播放。 在 iframe API 中描述了如何使用 onstatechange 事件,但在我的应用程序中它似乎不起作用,不幸的是我在 uiwebview 中看不到任何调试。
我只是想能够检测到视频何时结束,你对此有什么建议吗? 有人让它工作吗?
Currently I'm using the new iframe API to embed a YouTube video inside the uiwebview on the iPad and I've been able to make it auto play without user interactions.
In the iframe API it is described how to use the onstatechange event but in my application it doesn't seem to work and unfortunately I can't see any debug in uiwebview.
I just want to able able to detect when the video ends, have you got any advice on it?
Has anyone got it to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您是否尝试过(从文档中)为电影结束的事件分配一个整数?:
所以,类似:
Have you tried (from the documentation) to assign an integer to the event of a movie ending?:
So, something like:
要检测视频何时结束,视频的状态为 0 或 YT.PlayerState.ENDED
这是 jsfiddle a 链接!
To detect when the video ends then the video has the state of 0 or YT.PlayerState.ENDED
Here's a link to jsfiddle a link!
它可能与您的浏览器中的自动播放策略相关(在移动浏览器中默认禁用)。
如果您的浏览器是 Chrome,您可以使用附加命令行标志
--autoplay-policy=no-user-gesture-required
启动它 - 它对我有用。It may be connected with autoplay-policy in your browser (it's disabled by default in mobile browsers).
If your browser is chrome you can start it with additional commandline flag
--autoplay-policy=no-user-gesture-required
- it worked for me.可以http://code.google.com/apis/youtube/js_api_reference.html #SubscribingEvents可以帮助你
May this http://code.google.com/apis/youtube/js_api_reference.html#SubscribingEvents can help you
为此,您需要使用 JavaScript。
请参阅此链接:https://developers.google.com/youtube/js_api_reference
you need to make use of JavaScript for that.
Refer this link : https://developers.google.com/youtube/js_api_reference