http headers to send file to html5 <audio>
I want use html5's new tag to play a wav file (currently only supported in FF.)
https://developer.mozilla.org/En/HTML/Element/Audio
I"m using php's readfile command to get the wav file off the hdd, and write it to the http response.
But its not working. The audio widget in firefox just has the loading animation running constantly.
The tag seems to be fine as I can put a different url in it's src/source and it works fine. I can use an tag and that downloads the file and it plays using Quicktime fine.
So I thinking perhaps its one/all of the content headers.
Using the FF Extension httpfox I can see these response headers arrive from the server:
(Status-Line) HTTP/1.1 200 OK
Date Mon, 12 Oct 2009 03:04:33 GMT
Server securesauce
Cache-Control private
Expires Mon, 26 Jul 1997 05:00:00 GMT
Pragma private
Vary Accept-Encoding
Content-Encoding gzip
Content-Length 8217
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Content-Type audio/x-wav
So everything looks how I'd expect it to. The only headers I'm explicitly setting in the script (others are set elsewhere in the app) are:
Cache-Control private
Pragma private
Content-Type audio/x-wav
When I tried a different wav file (random one off the internet) httpfox didn't list any response headers.
Because its a php file sending out the content, I can't just send no headers, as I'd have to at least send the content-type.
Any ideas?
Source excerpt:
header('Cache-Control: private');
header('Pragma: private');
header("Content-Type: $contentType");
readfile($filepath);
exit;
Which formats and MIME types are supported by Mozilla is documented on their wiki. It doesn't look like the MIME type is your problem, but it's quite possible that this WAVE file isn't using the plain PCM audio which Firefox supports. WAVE can actually contain other formats like ADPCM, MP3 and whatnot. These may be supported by QuickTime, but there's no guarantee that it will play in a HTML5 browser. To be sure, try opening the file in a audio editor and saving it again as a WAVE PCM file.
You're missing X-Content-Duration
. It's needed for the client to seek accurately during playback, and some clients refuse media content unless the duration is included. Also include Content-Duration
, which is slowly replacing X-Content-Duration
.
Here is some more information: Configuring web servers for HTML5 Ogg video and audio
Also, I would avoid using gzip or encryption on your output.
Have you tried the url of the audio file directly in your browser? If it contains an error or a warning that will make your header obsolete. and also try to open the audio file from the browser, see if it is correct.
链接地址: http://www.djcxy.com/p/60726.html上一篇: 通过带有HTML5 <audio>标签的流式MP3文件进行搜索
下一篇: http头文件发送到html5 <音频>