Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to play wav files in the browser?

Tags:

audio

wav

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

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.

Thanks.

like image 499
Splatzone Avatar asked Jul 24 '09 02:07

Splatzone


People also ask

Can browsers play WAV files?

WAV files have a . wav extension and are supported by Google Chrome, Firefox, Opera, and Safari browsers.

How do I play a .WAV file in HTML?

The HTML <audio> element is used to play an audio file on a web page.

Can safari play WAV files?

Wav audio format is Fully Supported on Safari 15, which means that any user who'd be accessing your page through Safari 15 can see it perfectly.


2 Answers

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

Background:

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

On Click:

<a href="success.wav">Play Sound</a>
like image 90
Robert Harvey Avatar answered Sep 17 '22 18:09

Robert Harvey


<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.

Opera 12.14 and Firefox play from < audio > tag normally in the same case (redirected 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).

like image 28
user5937847 Avatar answered Sep 17 '22 18:09

user5937847