Not able to play compressed wav file using html <audio> in chrome,firexfox browsers

580 Views Asked by At
<html>
<body>
<audio controls>
  <source src="one.wav" type="audio/wav">
</audio>
</body>
</html>

We are compressing the audio files(.wav) files using sox api. It's playing(.wav) perfectly fine when its not compressed. After compressing it's playing only in safari browser and not working in other browsers.The same audio file i can play with any audio player.Is there anything we need to do in order to work this in all browsers?

we are using following sox command to compress file

sox source.wav -e ima-adpcm target.wav

1

There are 1 best solutions below

4
On

Unfortunately there is no set of codecs that browsers are required to support. If one browser is capable of decoding a file it does not guarantee that another browser can do that as well. The only thing that helps is testing, testing and testing...

There is for example AreWePlayingYet which is an old site from SoundCloud which has basic checks for various formats. Although it only checks for uncompressed wav.

The good news is that you can always provide fallbacks by specifying more than one <source/> within your <audio/> tag. The browser will go through the list until it finds a file it can decode.