html 5 video tag file without extension
I have this sample code开发者_Go百科, that works:
<video src="./ellen.ogv" width="320" height="240" type='video/ogg; codecs="theora, vorbis"' controls></video>
And this one that doesn't work:
<video src="./ellen" width="320" height="240" type='video/ogg; codecs="theora, vorbis"' controls></video>
The only change was on the name of the file. First one "point" his extension, second one does not.
This is just a simple view of my problem, where the file I want to stream CAN'T have extension, but is a theora/vorbis (ogv) file.How can I deal with this problem, i.e., make video tag works even if my filename doesn't have a ".extension" ?
First, the type
attribute is not allowed on the video tag. Place the type
attribute in a source
tag instead, like this:
<video width="320" height="240" controls>
<source src="./ellen" type='video/ogg; codecs="theora, vorbis"'>
</video>
Second, video files must be served with the proper MIME type by the web server, even when you have specified a type
attribute in the source
element. Make sure that your web server serves your video files with Content-Type: video/ogg
regardless of whether they have the .ogv
extension or not.
精彩评论