带有后备的HTML5视频代码 [英] HTML5 Video tag with fallback

查看:239
本文介绍了带有后备的HTML5视频代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在html中嵌入视频和音频的解决方案。新的录像带支持.ogg和.mp4,但有.flv和其他格式的后备解决方案吗?


例如,如果我想嵌入.ogg,它将检查是否支持html5,如果不支持,则使用后备。如果我想嵌入.flv则使用后备。

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.

推荐答案

html5标签支持回退任何元素,如果浏览器无法解释视频标签。这是一个回退到flash文件的快速示例。

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>  

而不是embed标签,你可以使用任何html元素(带有文字的跨度你的浏览器无法解释html5 ..或图片或任何你想要的东西)。基本上,html5浏览器采用他们可以播放的视频源,而非html5浏览器忽略视频和源标签,并在最后获取falback元素。

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.

这篇关于带有后备的HTML5视频代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆