streaming audio with html5 `<audio>` tag

ⅰ亾dé卋堺 提交于 2019-12-01 15:28:14

问题


I am trying to stream audio on a site hosted by Dreamhost from a lecture series using the <audio> tag in html5, but without much success. The actual code is

<audio id="playerTwo" class="player" controls="controls" preload="none">
<source src="audio.ogg" type="audio/ogg; codecs='vorbis'"/>
<source src="audio.mp3" type="audio/mpeg"/>
</audio>

I also have an .htaccess file to include the correct mime-types for apache.

AddType audio/ogg .ogg

AddType audio/mpeg .mp3

The ogg files are about 8 megs and mp3 files are about 13 megs. Each file was exported from Audacity.

Everything plays fine in FF, Chrome and Safari when served locally on my windows 7 machine (running a win32 version of apache 2.2.14 and php 5.3.1).

Things do not go so well on Dreamhost. (They run apache 2.2.15 and php 5.2.14.) FF stops playing the audio file after 5 seconds. Chrome plays the audio file, but the audio skips frequently. Safari plays the audio correctly, but the lag between clicking the play button and the audio actually starting to stream and play is about three minutes.

If instead of using the <audio> tag, I play the mp3 files from Dreamhost with a Silverlight player, they stream and play correctly.

Any suggestions about what I need to do to get the <audio> tag to work correctly. As far as I know, html5 audio is client-side technology, as is Silverlight. So, in theory, Dreamhost should have no effect on how the <audio> tag performs.

Anyway, anyone have any ideas about what is amiss.

Thanks.


回答1:


Problem caused by uploading audio files through filezilla in ascii transfer type, rather than binary transfer type. The audio files were corrupted during upload, so no big surprise that they didn't play well. The surprise is that the mp3 files did play acceptably, though the ogg files did not.

That's the answer here.



来源:https://stackoverflow.com/questions/3809519/streaming-audio-with-html5-audio-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!