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

Naidu
  • 95
  • 1
  • 10

1 Answers1

1

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.

chrisguttandin
  • 7,025
  • 15
  • 21
  • We have only compressed wav files, so there is no way we can provide alternate sources. – Naidu Aug 22 '20 at 08:03
  • I'm not sure if I understand that. In your question you're saying that you are compressing the files with sox. Can't you just provide the original files as a fallback? – chrisguttandin Aug 22 '20 at 20:13
  • We receive audio files from one more service and we compress that file and store that in the storage. We use that file in the UI for playing. After compressing the file, we don't have access to the original file. – Naidu Aug 23 '20 at 04:34
  • Well in that case your only option is to ship a custom decoder. – chrisguttandin Aug 24 '20 at 11:28