html5 视频标签 + Flash视频:如何更改优先级
我正在玩 html5 视频,因为有 iphone/ipad 的后备是很好的。 html5 video 首先检查 元素,如果不支持任何格式,它将回退到
标记内提供的任何内容(例如 flash)。
我很想扭转这种行为以节省带宽:默认使用 Flash,如果不可用,则回退到 html5 视频。
有没有任何方法可以在不使用 JavaScript 的情况下获得此行为? (那么解决方案就变得非常明显)。
最好,hansi,-
ps我确实尝试将元素“由内而外”(而不是
,但这会导致视频显示两次)
pps我当前的解决方案是
if( navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ){ ... }
else{ ... }
次优的,因为它适用于iphone/ipad,但在使用时会导致一团糟没有安装 Flash 的旧浏览器。
i'm playing around with html5 video cause it's nice to have fallback for iphone/ipad.
html5 video first checks for <source>
elements, if no formats are supported it falls back to whatever content is provided inside the <video>
tag (e.g. flash).
i'd love to reverse the behaviour to save bandwidth: use flash by default, if not available fall back to html5 video.
is there any way to get this behaviour without using javascript? (then the solution gets quite obvious).
best, hansi,-
p.s. i did try turning the elements "inside-out" (<object><video/></object>
instead of <video><object/></video>
, but that results the video displayed twice)
p.p.s. my current solution is
if( navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ){ ... }
else{ ... }
which is sub-optimal, cause it works for iphone/ipad, but results in a big mess when using old browsers without flash installed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢“zach at longtail”!,成功了!
作为参考,以下是如何获得“首先是 flash,然后是 html5”行为:
为 youtube/vimeo 嵌入提供 html5 替代品:
请注意,拥有
thanks "zach at longtail"!, that worked!
for reference, here's how to get the "flash first, then html5" behaviour:
For providing html5-alternatives to youtube/vimeo embeds:
Please note that having the
<object data="..." />
attribute is crucial and that it is missing in the embedding code that youtube/vimeo/etc. provide.Make sure to change that, just throwing the
<video/>
tag in the code you copy+pasted will give you exactly the headache i had.