问题描述
我收到了一些youtube网址,例如。当我把它放到html视频标签时,它会说无效的源码。
如何解决这个问题?
。
这是我的HTML :
< video width =300height =autoautoplay =controls =name =media >< source src =https://www.youtube.com/embed/LaXGkW_-Nvc?list=RDTDDDvaoGiDg>< / video>
您无法在YouTube上使用HTML5视频代码视频,它只支持MP4,WebM和Ogg文件。
YouTube已经为您提供了一个嵌入功能,可以为您自动生成iFrame。 还有其他一些方法,但不再使用它们(不推荐)。
由于对于与IE的问题,也许看看这个类似的问题:
如果您想使用HTML5视频标签是以指定格式之一下载Youtube视频。
I got some youtube urls, such as https://www.youtube.com/embed/LaXGkW_-Nvc?list=RDTDDDvaoGiDg. When I put it to html video tag, it said "Invalid source".
How to solve this problem?
When I used iframe to display videos, I had another problem as described here: Video not showing in iframe on IE, but showing on firefox and chrome.
This is my HTML:
<video width="300" height="auto" autoplay="" controls="" name="media"><source src="https://www.youtube.com/embed/LaXGkW_-Nvc?list=RDTDDDvaoGiDg"></video>
You can't use the HTML5 video tag for youtube videos, it only supports files that are either MP4, WebM and Ogg. W3C Schools
Youtube already provides you with an "embed" function on their page which auto generates the iFrame for you. Youtube Embed There are a few other methods but they are no longer used (deprecated). Youtube API
As for the issue with IE, maybe have a look at this similar question: YouTube iframe embed code not working in IE
The only way around the issue if you want to use the HTML5 video tag is to download the Youtube video in one of the specified formats.
这篇关于HTML视频标签显示Youtube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!