如何让嵌入式Youtube视频自动开始播放? [英] How to make an embedded Youtube video automatically start playing?
本文介绍了如何让嵌入式Youtube视频自动开始播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的项目中,有一个视频库模块。在此模块中,有两个选项:直接FLV上传,以及从YouTube添加视频嵌入代码。
In my project, there is a video gallery module. In this module, there are two options: direct FLV uploading, and adding a video embed code from YouTube.
我正在为div元素编写一些嵌入代码(实际上,嵌入代码来自数据库)。我想让这个视频开始自动播放。
I am writing some embed code for a div element (actually, the embed code comes from database). I want to make this video begin playing automatically.
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/zGPuazETKkI" frameborder="0" allowfullscreen></iframe>
这是来自YouTube的示例嵌入代码。我想用JavaScript自动制作这个视频。
This is a sample embed code from YouTube. I want to make this video play automatically using JavaScript.
推荐答案
你必须使用
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/zGPuazETKkI?autoplay=1" frameborder="0" allowfullscreen></iframe>
?autoplay = 1
而不是
& autoplay = 1
它是第一个URL参数,因此添加了一个?
its the first URL param so its added with a ?
这篇关于如何让嵌入式Youtube视频自动开始播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文