1

hello i am abit new in client side programming and html, i am trying to excute the following line in firefox and other browsers , the code should play a sound, problem is that the code works and play the sound on IE and Chrome but not on firefox here is my code:

<!DOCTYPE html>
<html>

<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>Untitled 1</title>
    <script type="text/javascript">
       function playsound()
       {
       var sound= document.getElementById("check");
       sound.play();
       }
    </script>
</head>

<body>
<audio id = "check" preload = "auto">
    <source src = "check.mp3" type = "audio/mpeg"></audio>

<input type="button" onclick="playsound()" value="play">

Nadav
  • 2,589
  • 9
  • 44
  • 63

2 Answers2

2

Firefox doesn't support the MP3 format as audio source. If you add a second source file in OGG format, the script should work in Firefox too. See this Link for more info

Community
  • 1
  • 1
mch
  • 1,259
  • 15
  • 23
1

The fact is that firefox and opera do not support mp3 files in html5 audio tag. You can check supported browser in w3schools. Its work around is that you need a fallback flash audio player.

Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110