HTML5 Video tag with fallback

点点圈 提交于 2020-01-04 06:25:29

问题


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.



来源:https://stackoverflow.com/questions/11116730/html5-video-tag-with-fallback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!