Firefox won't play .WAV files using the HTML5 <audio> tag?

26,581

Solution 1

What's the bit depth on your WAV files? Firefox supports 8-bit and 16-bit PCM, but not other bit depths (12, 20, 24, 32).

Solution 2

Firefox expects one of the following codecs to be returned as the MIME type:

  • audio/wave (preferred)
  • audio/wav
  • audio/x-wav
  • audio/x-pn-wav

Make sure your server returns one of those MIME types for wav files.

Share:
26,581
David Byers
Author by

David Byers

Updated on August 05, 2022

Comments

  • David Byers
    David Byers almost 2 years

    I'm building a page that will allow a user to upload an MP3 file. That MP3 file is converted in the back end to a .WAV file using LAME.

    The lame execution script is here:

    LAME --resample 44.1 -decode myDirectoryPath/Master.mp3 myDirectoryPath/Master.wav
    

    However, when I use the HTML5 audio tag to create a player for that audio file in Firefox, it doesn't work.

    <!DOCTYPE HTML>
    <html>
    
    <head>
        <meta charset="UTF-8">
        <title>Test</title>
    </head>
    
    <body>
        <audio controls>
            <source src="myDirectoryPath/Master.mp3">
            <source src="myDirectoryPath/Master.wav">
        </audio>
    </body>
    </html>
    

    Everything I've read says that Firefox supports .wav files... and I can't find a simple .mp3 to .ogg command line tool to use that will convert the master.mp3 to .ogg format. Can someone offer some suggestions on what to try next?

    I've posted code that works in Safari and Chrome here: http://www.wgbh.org/byers/Audio/index.html

    For whatever reason, FF doesn't like it.

    UPDATE (With accompanying facepalm) The issue lies with my LAME decode. The correct syntax is --decode with two dashes instead of one. The system was actually encoding it from mp3 to mp3, naming it wav and Safari / Chrome on the Mac was assuming the file type.

  • David Byers
    David Byers about 12 years
    Done. I've tried using type="audio/wave" and "audio/wav" with no results.
  • albert
    albert about 12 years
    u tried using those types, but did you make sure your server can handle them?
  • Brian Hadaway
    Brian Hadaway about 12 years
    Webkit browsers will assume a file type based on file extension when a MIME type isn't returned by the server so that could be why your code works in Safari but not Firefox.
  • Daniel F
    Daniel F over 10 years
    In addition to this, it won't play back wav files using alaw or ulaw encoding.
  • cs_alumnus
    cs_alumnus over 9 years
    Up votes because I didn't think to check if my wav files were encoding PCM or ulaw.
  • JNYRanger
    JNYRanger about 9 years
    This has an accepted answer from 3 years ago, why would you post?
  • XAMelleOH
    XAMelleOH about 6 years
    As for today, Firefox will play all bitrates up to 32 if it has PCM encoding