1

I couldn't find an answer on StackOverflow that dealt with audio formats. I've come across some methods on how to implement sounds in UI (like this one), but what type of audio file type should I be using that will work across all devices including PCs, tablets, and phones for an HTML/CSS/JS based web app? Right now, my sounds only work on a PC and not on mobile when a certain button is clicked. I am using .ogg as my audio file.

// Source: https://codereview.stackexchange.com/questions/21604/playing-sound-on-a-button-click/42755#42755
$(document).ready(function() { 
    var obj = document.createElement("audio"); 
    obj.setAttribute("src", "link/to/audio/click.mp3"); 
    $.get(); 

    $(".playSound").click(function() { 
        obj.play(); 
    }); 
}); 

Thank you.

Community
  • 1
  • 1
kaoscify
  • 1,743
  • 7
  • 37
  • 74

1 Answers1

1

Check this documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats

Android has a chrome-based browser and webview by default, and iOS safari.

Windows phone has a IE browser.

Mou
  • 2,027
  • 1
  • 18
  • 29
  • Thank you. That's a really informational chart. But when I use a .mp3 file using the code above, the sound still doesn't work in mobile. – kaoscify Dec 14 '14 at 20:28
  • 2
    http://stackoverflow.com/questions/10900816/playing-audio-with-html5-in-android-browser – Mou Dec 14 '14 at 20:39