如何使嵌入的 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屋!
查看全文