This project has moved. For the latest updates, please go here.

Best format for HTML5

May 1, 2014 at 3:58 PM
I'm trying to get our corporate voicemails to play in a website. The vms are stored on an imap server. I have sucessfully retrieved the wav file attachments and converted them to mp3 using Naudio.Lame. That solution plays the voicemail on all modern desktop browsers, but no mobile browser is playing the file. What should I be converting the 8-bit mono wav file to for audio playback using HTML5 in desktop browsers as well as mobile browsers?

Thanks,
Jeremy
May 1, 2014 at 4:53 PM
Here is my current code that works to convert from wav to mp3.
using (var retMs = new MemoryStream())
            using (var ms = new MemoryStream(wavFile))
            using (var rdr = new WaveFileReader(ms))
            {
                using (var conversionStream = WaveFormatConversionStream.CreatePcmStream(rdr))
                {
                    using (var wtr = new LameMP3FileWriter(retMs, conversionStream.WaveFormat,LAMEPreset.STANDARD))
                    {
                        conversionStream.CopyTo(wtr);
                        wtr.Close();
                        return retMs.ToArray();
                    }
                }
            }
Coordinator
May 6, 2014 at 7:50 PM
unfortunately I don't think there is one format that all HTML 5 browsers are guaranteed to support, but MP3 would give you a fairly wide reach.
Coordinator
May 7, 2014 at 2:24 PM
you may need to upsample to 16kHz (or higher - try 22.05, 32 or 44.1kHz) before converting to MP3 for it to work on all mobile devices
May 7, 2014 at 2:40 PM
based on my code above - how would I would I upsample before converting to MP3?
Coordinator
May 8, 2014 at 9:06 AM
Use one of the resampler classes such as MediaFoundationResampler, WdlResamplingSampleProvider or even WaveFormatConversionStream