3

I'm targeting modern browsers (only those that support <audio>) and specifically the iPad. I've tested here and wav works on chromium, firefox 4.0 (both mac 10.6) and on the iPad. I have a couple dozen audio files so I'd like to avoid multiple versions if possible.

I'll be starting and stopping the audio programmatically, no browser default controls (just buttons I attach), in case that's relevant.

Someone gave me a vague warning against using .wav; to wit:

be careful with that unless you intend to have the .wav be a pcm stream

So, any reason I shouldn't use wav for cross browser support and call it a day?

5

WAV files are pretty large in size. Especially when compared to mp3s which are ~90% smaller in size. Ogg Vorbis should also be much smaller. Naturally the smaller file size is ideal for the web. Unfortunately support for different formats is varied amongst browsers.

Fortunately you can work around this by specifying multiple files and letting the browser choose the first one they support. This way .wav files are only loaded if nothing else is supported.

<audio preload="auto" autobuffer> 
  <source src="file.mp3" />
  <source src="file.ogg" />
  <source src="file.wav" />
</audio>

Update

This is the <audio> version of progressive enhancement. You can list the formats in order of preference with .wav, the largest file format, being last so only users who don't have browsers supporting .mp3 or .ogg need to load that file. Based on your requirements these users should be few and far between. If you're sure your users will support either .mp3 or .ogg then you can leave the .wav off entirely.

6
  • Hmm... well this solution is certainly solid but now I have THREE sets of files to maintain, more than my worst-case scenario at the start (maintain two sets). Given that I'm targeting only the iPad and modern webkit/gecko, what's the reasoning behind adding the .wav fallback? mp3 works for iOS and ogg works for the others... is there something I'm missing? Mar 24 '11 at 13:29
  • My example was just to demonstrate how you can use fallbacks to cover the browsers you wish to support. If you don't need .wav files then definitely leave them off. One less format to manage is always a good thing.
    – John Conde
    Mar 24 '11 at 13:51
  • There are likely tools out there that can help you manage the files and auto convert. In other words you can keep your WAVs as the "base" format but run some script to convert them into better formats. Mar 24 '11 at 17:32
  • Yep, WAV files are uncompressed so are huge. I wouldn't recommend using them on the web. Mar 24 '11 at 21:03
  • 1
    @sequoia, is that update satisfactory?
    – John Conde
    Mar 25 '11 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.