Nadav
Nadav

Reputation: 2727

firefox not playing sound

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">

Upvotes: 1

Views: 3398

Answers (2)

Zaheer Ahmed
Zaheer Ahmed

Reputation: 28588

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.

Upvotes: 1

mch
mch

Reputation: 1279

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

Upvotes: 2

Related Questions