Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MEDIA_ERR_SRC_NOT_SUPPORTED html5 audio woes

Tags:

html

audio

I am working on an html5 audio player and everything is working fine when I server the .ogg file from the same host as the html page. When I put the ogg file in my cdn it fails and the error code is MEDIA_ERR_SRC_NOT_SUPPORTED

For example, this works fine

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

But this fails with the above error code

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

The headers for the audio file that fails look something like this (this is from a different ogg file which exhibits the same behavior)

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
like image 699
jshen Avatar asked Feb 14 '10 06:02

jshen


2 Answers

The Content-Type=octet/stream header is the problem, although if I'm reading the spec correctly, it shouldn't be. Here's a testcase: http://mozilla.doslash.org/stuff/video-test/video.html

I filed a bug in Mozilla's bugzilla about this. [edit] the response:

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.

like image 184
Nickolay Avatar answered Nov 10 '22 08:11

Nickolay


The problem is the mime type you are serving the audio file with. It needs to be 'audio/ogg', 'application/ogg' or 'video/ogg' for Firefox to play it. Firefox doesn't do any form of 'content sniffing' to work out what format the file is in - it relies entirely on the mime type.

like image 26
user273187 Avatar answered Nov 10 '22 08:11

user273187