MEDIA_ERR_SRC_NOT_SUPPORTED html5音频问题

前端之家收集整理的这篇文章主要介绍了MEDIA_ERR_SRC_NOT_SUPPORTED html5音频问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用一个 html5音频播放器,当我从与html页面相同的主机服务.ogg文件时,一切正常.当我将ogg文件放在我的cdn中时,它失败,错误代码是MEDIA_ERR_SRC_NOT_SUPPORTED

例如,这工作正常

<audio src="/song.ogg" id="player">
  Your browser does not support the <code>audio</code> element.
</audio>

但是,以上错误代码失败

<audio src="http://mycdn.com/song.ogg" id="player">
  Your browser does not support the <code>audio</code> element.
</audio>

音频文件标题失败看起来像这样(这是来自不同的ogg文件,表现出相同的行为)

HTTP/1.1 200 OK
Server: CacheFlyServe v26b
Date: Sat,13 Feb 2010 21:10:48 GMT
Content-Type: application/octet-stream
Connection: close
ETag: "c6ee7d86e808cc44bbd74a8db94a5aae"
X-CF1: fA.syd1:cf:cacheD.syd1-01
Content-Length: 2398477
Last-Modified: Sat,13 Feb 2010 20:50:56 GMT
Accept-Ranges: bytes
X-Cache: MISS from deliveryD-syd1

解决方法

Content-Type =八位字节/流标题是问题,虽然如果我正确地阅读规范,它不应该是.这是一个测试用例: http://mozilla.doslash.org/stuff/video-test/video.html

filed a bug在Mozilla的bugzilla关于这个.响应:

We don’t do any content sniffing to work out what the content is – we rely on the correct mime type being provided. This is why application/octet-stream does not play and way we return “” for canPlayType.

猜你在找的HTML5相关文章