slide-drive
slide-drive copied to clipboard
Media served from HTTP/1.0 server breaks audio element
Headers not causing the error
HTTP/1.1 206 Partial Content
X-Powered-By: Express
Date: Tue, 12 Jun 2012 19:31:22 GMT
Cache-Control: public, max-age=0
Last-Modified: Tue, 29 May 2012 18:37:52 GMT
ETag: "1636628-1338316672000"
Content-Type: audio/ogg
Accept-Ranges: bytes
Content-Range: bytes 0-1636627/1636628
Content-Length: 1636628
Set-Cookie: connect.sid=AwDDNAmAymrNPigoH3kRDxnj.olJWNdnzjJ2ZcT2oepIPhNC4yBuxOCgaWPAbr3DylU8; path=/; expires=Tue, 12 Jun 2012 23:31:22 GMT; httpOnly
Connection: keep-alive
Headers causing the error
HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/2.7.1
Date: Tue, 12 Jun 2012 19:30:37 GMT
Content-type: audio/ogg
Content-Length: 1636628
Last-Modified: Tue, 29 May 2012 18:37:52 GMT
It seems like this is the result of using an HTTP/1.0 server, which lacks support for Content-Range
. For example, this has happened when using Python's SimpleHTTPServer
/http.server
. I'm not sure if it always happens.
In Chrome this causes assignment to the .currentTime
property to be ignored. In Firefox it causes .duration
to be NaN
.
I'd expect it to work regardless once it has downloaded the entire media file, but apparently not.
We may want to detect this and handle it in some way. It currently causes confusing silently failures. Maybe we should throw an exception if we're unable to change .currentTime
after the content has loaded.
I noticed Firefox returning a duration
of NaN without the headers and some Googling backs this up, but now I can't seem to replicate the issue again. Nevertheless, I'm going to add a check for that, too.