【问题标题】:Include youtube video player in html在 html 中包含 youtube 视频播放器
【发布时间】:2016-02-09 21:53:40
【问题描述】:

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

我有以下一段html:

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

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

有什么建议么?

标签: html youtube


【解决方案1】:

只需尝试将其与 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。

【讨论】:

  • 我使用了 youtube 提供的 sn-p。之前没看到你的回答。非常感谢!
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    您的 src 参数缺少 http:

    尝试

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

    【讨论】:

    • 你不应该添加http,因为协议不一定是http,它可能是https或ftp等等。实际协议是https。
    • 是的,但你必须确定协议,否则浏览器不知道如何处理给定的源。理想情况下,您可以直接从 youtube 视频页面获取 iframe 代码。
    猜你喜欢
    • 2014-05-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-18
    • 1970-01-01
    • 1970-01-01
    • 2012-08-09
    • 1970-01-01
    • 2014-09-27
    相关资源
    最近更新 更多