在 html 中包含 YouTube 视频播放器

Include youtube video player in html

好的,可能还有一个类似的问题,但没找到。 说实话,我什至不知道要找什么。

我有以下一段 html:

<html>
    <body>
        <iframe width="560" height="315"
            src="//www.youtube.com/embed/q3rhteIierY" frameborder="0" allowfullscreen>
        </iframe>
    </body>
</html>

这就是所有人。据说这应该有效。
但事实并非如此。我 运行 它在本地没有网络服务器。
我只想嵌入一个 youtube 播放器!

有什么建议吗?

您的 src 参数丢失 http:

尝试

        <iframe width="560" height="315"
            src="http://www.youtube.com/embed/q3rhteIierY" frameborder="0" allowfullscreen>
        </iframe>

试试这个与 iframe 一起使用:

<iframe id="ytplayer" type="text/html" width="640" height="390"
src="http://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com"
frameborder="0"/>

来自 Google 的开发站点:https://developers.google.com/youtube/player_parameters

用您自己的值替换 URL。

<iframe width="560" height="315"
            src="//www.youtube.com/embed/q3rhteIierY" frameborder="0" allowfullscreen>
        </iframe>