Change the audio file format depending on the browser?

76 views Asked by At

I made an image and when a user clicks certain field on that image he is able to hear sound, the problem is that the file format is mp3, so all browsers except opera plays that sound fine, how can I fix that ?
Looks like this:

<audio loop id="e" src="e.mp3" preload="auto"></audio>    
<div class="string" id="ee" -->   onclick="document.getElementById('ee').play();
  document.getElementById('a').pause(); document.getElementById('a').currentTime = 0;
  document.getElementById('d').pause(); document.getElementById('d').currentTime = 0;
  document.getElementById('g').pause(); document.getElementById('g').currentTime = 0; 
  document.getElementById('b').pause(); document.getElementById('b').currentTime = 0; 
  document.getElementById('e').pause(); document.getElementById('e').currentTime = 0;">
</div>  
1

There are 1 answers

1
mcmac On BEST ANSWER

If you want use audio element on website you must use 2 type format audio mp3 and ogg read about that

if you have only mp3 you can use this audio5js