Html 如何将 Youtube 视频嵌入 HTML5 <video> 标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13177359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Embed Youtube Videos into HTML5 <video> Tag?
提问by Rishi Jogle
I am implementing site where i required to embed youtube videos into tag in HTML5.
can you tell me how should i embedd into this without using <iframe>
我正在实施网站,我需要在 HTML5 中将 youtube 视频嵌入到标签中。你能告诉我我应该如何在不使用的情况下嵌入到这个中吗<iframe>
回答by kinabalu
There's no way to do this without Javascript. But the wonderful MediaElement.js library will work wonderfully for this purpose:
没有 Javascript 就没有办法做到这一点。但是出色的 MediaElement.js 库可以很好地用于此目的:
The example above shows using a YouTube video with a <video>
tag, but also has a fallback to Flash for browsers that don't support it.
上面的示例展示了如何使用带有<video>
标签的 YouTube 视频,但对于不支持 Flash 的浏览器,也可以使用 Flash。
回答by Greg Schechter
You can't extract the source of the video without violating YouTube's terms of service. The only supported way to embed a video in a web page is using the iframe embed.
您无法在不违反 YouTube 服务条款的情况下提取视频来源。在网页中嵌入视频的唯一支持的方法是使用 iframe 嵌入。