i have written some simple html and javascript that should play a sound file. The page displays the two buttons but when i click the play button it does nothing . I know that my browser can play my mp3 file because it works with just the audio tag ex:
<audio src="soundtest.mp3" ></audio>
If anyone could tell me what i am doing wrong i would greatly appreciate it.
<!DOCTYPE html>
<html>
<body>
<button onclick="playSong()" type="button">play</button>
<button onclick="pauseSong()" type="button">pause</button>
<br>
<audio id="audio1">
<source src="soundtest.mp3" type="audio/mp3" >
Your browser does not support the audio tag!
</audio>
<script>
var mySong=document.getElementById("audio1");
function playSong()
{
mySong.play();
}
function pauseSong()
{
mySong.pause();
}
</script>
</body>
</html>