YouTube 视频在 iPhone PhoneGap 应用程序上自动播放
在phonegap中,如果您嵌入视频,则会出现滚动不良的情况(如果您用手指在视频缩略图上滚动页面,则整个视口都会滚动,而不是正确的div)。为了避免这种情况,我尝试使用中心有一个播放按钮的缩略图:当按下播放按钮时,js 代码会渲染一个隐藏的 div,其中包含一个对象标签(即视频)。此时最酷的事情是让视频加载在假缩略图之上并自动播放(因此控件会自动转到本机 YouTube 应用程序)!
除了自动播放之外,我的代码中的所有内容都有效:我已经尝试了自动播放和自动启动参数:
<object style="margin-left:0px;margin-top:10px;" id="video" width="296" height="222" data="http://www.youtube.com/v/R6Z7xceSLy4" type="application/x-shockwave-flash">
<param name="allowfullscreen" value="true" />
<param name="autoplay" value="true">
<param name="autoStart" value="0">
<param name="wmode" value="transparent" />
<param name="src" value="http://www.youtube.com/v/R6Z7xceSLy4" />
</object>
以及视频地址中尾随的 &autoplay=1 或 ?autoplay=1 (我在某处读到 '&'某些原因应替换为“?”)
<object style="margin-left:0px;margin-top:10px;" id="video" width="296" height="222" data="http://www.youtube.com/v/R6Z7xceSLy4?autoplay=1" type="application/x-shockwave-flash">
<param name="allowfullscreen" value="true" />
<param name="autoplay" value="true">
<param name="autoStart" value="0">
<param name="wmode" value="transparent" />
<param name="src" value="http://www.youtube.com/v/R6Z7xceSLy4?autoplay=1" />
</object>
您有什么建议吗?我认为解决问题的另一件事是在按下播放按钮时自动启动 YouTube 本机应用程序中的视频。我尝试使用
window.location = 'http://www.youtube.com/v/R6Z7xceSLy4';
一切似乎都是正确的,除了完成后它不会将控制权返回给我的应用程序,但它仍然卡在 YouTube 应用程序中。 有人可以帮忙吗?
In phonegap if you embed a video you come up with a bad scrolling (if you scroll the page with a finger on the video thumbnail, the whole viewport scrolls, instead of the correct div). To avoid this I'm trying to use a thumbnail image with a play button in its center: when the play button is pushed a js code renders an hidden div with an object tag inside (that's the video). The coolest thing at this point would be to let the video load on top of the fake thumbnail and autoplay (so the control goes automatically to the native youtube app)!
Everything works in my code, except for the autoplay: I've tried both the autoplay and autostart params:
<object style="margin-left:0px;margin-top:10px;" id="video" width="296" height="222" data="http://www.youtube.com/v/R6Z7xceSLy4" type="application/x-shockwave-flash">
<param name="allowfullscreen" value="true" />
<param name="autoplay" value="true">
<param name="autoStart" value="0">
<param name="wmode" value="transparent" />
<param name="src" value="http://www.youtube.com/v/R6Z7xceSLy4" />
</object>
and the &autoplay=1 or ?autoplay=1 trailing in the video address (I read somewhere that the '&' for some reason should be replaced by '?')
<object style="margin-left:0px;margin-top:10px;" id="video" width="296" height="222" data="http://www.youtube.com/v/R6Z7xceSLy4?autoplay=1" type="application/x-shockwave-flash">
<param name="allowfullscreen" value="true" />
<param name="autoplay" value="true">
<param name="autoStart" value="0">
<param name="wmode" value="transparent" />
<param name="src" value="http://www.youtube.com/v/R6Z7xceSLy4?autoplay=1" />
</object>
Do you have any suggestion? Another thing I thought to resolve my problem was to launch automatically the video in the youtube native app on play button push. I've tryed using
window.location = 'http://www.youtube.com/v/R6Z7xceSLy4';
everything seems correct, except that when done it doesn't give the control back to my app but it remains stucked in youtube app.
Can anybody help please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论