简体   繁体   English

使用html5流式传输音频` <audio> `标签

[英]streaming audio with html5 `<audio>` tag

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. 我正在尝试使用html5中的<audio>标签从讲座系列中在Dreamhost托管的网站上传输音频,但没有太大成功。 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. 我还有一个.htaccess文件,包含apache的正确mime-types。

AddType audio/ogg .ogg AddType audio / ogg .ogg

AddType audio/mpeg .mp3 AddType audio / mpeg .mp3

The ogg files are about 8 megs and mp3 files are about 13 megs. ogg文件大约是8兆,mp3文件大约是13兆。 Each file was exported from Audacity. 每个文件都是从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). 当我在Windows 7机器上本地提供服务时,一切都在FF,Chrome和Safari中运行良好(运行win32版本的apache 2.2.14和php 5.3.1)。

Things do not go so well on Dreamhost. 在Dreamhost上,事情并没有那么顺利。 (They run apache 2.2.15 and php 5.2.14.) FF stops playing the audio file after 5 seconds. (他们运行apache 2.2.15和php 5.2.14。)FF在5秒后停止播放音频文件。 Chrome plays the audio file, but the audio skips frequently. Chrome会播放音频文件,但音频会频繁跳过。 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. Safari正确播放音频,但点击播放按钮和实际开始播放和播放的音频之间的延迟大约是三分钟。

If instead of using the <audio> tag, I play the mp3 files from Dreamhost with a Silverlight player, they stream and play correctly. 如果不是使用<audio>标签,而是使用Silverlight播放器播放Dreamhost中的mp3文件,它们会正确播放和播放。

Any suggestions about what I need to do to get the <audio> tag to work correctly. 有关如何使<audio>标记正常工作的任何建议。 As far as I know, html5 audio is client-side technology, as is Silverlight. 据我所知,html5音频是客户端技术,Silverlight也是如此。 So, in theory, Dreamhost should have no effect on how the <audio> tag performs. 因此,从理论上讲,Dreamhost应该对<audio>标签的执行方式没有影响。

Anyway, anyone have any ideas about what is amiss. 无论如何,任何人都对什么是错误有任何想法。

Thanks. 谢谢。

Problem caused by uploading audio files through filezilla in ascii transfer type, rather than binary transfer type. 通过ascii传输类型的filezilla上传音频文件而不是二进制传输类型导致的问题。 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. 令人惊讶的是,mp3文件确实可以播放,尽管ogg文件没有。

That's the answer here. 这就是答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM