在浏览器中播放wav文件的最佳方式?

时间:2022-02-13 19:43:00

I have no choice but to play wav files directly in the browser (serverside encoding to mp3 isn't an option, unfortunately.)

我别无选择,只能直接在浏览器中播放wav文件(不幸的是,服务器端编码为mp3不是一种选择。)

What's the best way to do this? I'd really like to take advantage of the HTML 5 audio tag but my target audience includes many, many teens using IE6. As far as I'm aware flash isn't an option, but speedy playback really is critical.

最好的方法是什么?我真的很想利用HTML 5音频标签,但我的目标受众包括许多使用IE6的青少年。据我所知,闪存不是一种选择,但快速播放确实至关重要。

Thanks.

3 个解决方案

#1


Nowadays, the best way is probably just to use the HTML5 <audio> tag. In the past, you might have done it like this:

如今,最好的方法可能就是使用HTML5

Background:

<embed src="bgsound.wav" hidden="true" autostart="true" loop="1">

On Click:

<a href="success.wav">Play Sound</a>

#2


It's been a few years since the last answer. Embed tag was good but I had an issue trying to trigger it to play in JavaScript. New audio tag works well is most browsers.

距离最后一个答案已有几年了。嵌入标签很好,但我试图触发它在JavaScript中播放有一个问题。新的音频标签适用于大多数浏览器。

<audio src="cat9.wav" preload></audio>

You can trigger it manually with audioElement.play()

您可以使用audioElement.play()手动触发它

#3


<audio controls="controls"><source src="http://blablabla.com/hghghgh/my%20file.wav" type="audio/x-wav" /></audio>

Due to unfixed bug (issue from 2012 year?) sometimes Chromium-like browsers cannot play .wav from redirected URLs because they "think" that file size is zero. But .mp3 is OK.

由于未修复的bug(2012年的问题?),有时类似Chromium的浏览器无法从重定向的URL播放.wav,因为它们“认为”文件大小为零。但.mp3还可以。

Opera 12.14 and Firefox play from < audio > tag normally in the same case (redirected URL).

Opera 12.14和Firefox通常在相同的情况下(重定向的URL)从

I tried JPlayer's 2.9.* lib in Drupal 7 with 3 players, but not successful (was black inactive rectangle 300*14 pixels for each player).

我在Drupal 7中尝试了JPlayer的2.9。* lib,有3个玩家,但没有成功(每个玩家的黑色非活动矩形300 * 14像素)。

#1


Nowadays, the best way is probably just to use the HTML5 <audio> tag. In the past, you might have done it like this:

如今,最好的方法可能就是使用HTML5

Background:

<embed src="bgsound.wav" hidden="true" autostart="true" loop="1">

On Click:

<a href="success.wav">Play Sound</a>

#2


It's been a few years since the last answer. Embed tag was good but I had an issue trying to trigger it to play in JavaScript. New audio tag works well is most browsers.

距离最后一个答案已有几年了。嵌入标签很好,但我试图触发它在JavaScript中播放有一个问题。新的音频标签适用于大多数浏览器。

<audio src="cat9.wav" preload></audio>

You can trigger it manually with audioElement.play()

您可以使用audioElement.play()手动触发它

#3


<audio controls="controls"><source src="http://blablabla.com/hghghgh/my%20file.wav" type="audio/x-wav" /></audio>

Due to unfixed bug (issue from 2012 year?) sometimes Chromium-like browsers cannot play .wav from redirected URLs because they "think" that file size is zero. But .mp3 is OK.

由于未修复的bug(2012年的问题?),有时类似Chromium的浏览器无法从重定向的URL播放.wav,因为它们“认为”文件大小为零。但.mp3还可以。

Opera 12.14 and Firefox play from < audio > tag normally in the same case (redirected URL).

Opera 12.14和Firefox通常在相同的情况下(重定向的URL)从

I tried JPlayer's 2.9.* lib in Drupal 7 with 3 players, but not successful (was black inactive rectangle 300*14 pixels for each player).

我在Drupal 7中尝试了JPlayer的2.9。* lib,有3个玩家,但没有成功(每个玩家的黑色非活动矩形300 * 14像素)。

相关文章