I'm looking for a solution for embedding video and audio in html. The new videotag supports .ogg and .mp4, but is there a fallback solution for .flv and other formats?
For example, if I want to embed an .ogg, it will check whether or not html5 is supported, if not, it uses the fallback. If I want to embed a .flv is uses the fallback.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
html5 tag supports a fallback to any element, if the browser cannot interpret the video tag. here s a quick example for a fallback to a flash-file.
<video controls width="500">
<!-- if Firefox -->
<source src="video.ogg" type="video/ogg" />
<!-- if Safari/Chrome-->
<source src="video.mp4" type="video/mp4" />
<!-- If the browser doesn't understand the <video> element, then reference a Flash file. -->
<embed src="your_flash_file" type="application/x-shockwave-flash" width="1024" height="798" allowscriptaccess="always" allowfullscreen="true"></embed>
</video>
instead of the embed tag, you can take any html-element (f.e. a span with text "your browser cannot interpret html5.." or a picture or anything you want). basically, html5 browser take the videosource they can play, while non-html5 browser ignore the video and source tag and take the falback element at the end.