Javascript examples for DOM HTML Element:Audio
Play audio and restart it onclick
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <audio id="audio1" src="http://your test.mp3"></audio> <button onclick="play()">play</button> <script type="text/javascript"> function play() {// ww w . jav a 2 s . c o m var audio = document.getElementById('audio1'); if (audio.paused) { audio.play(); }else{ audio.pause(); audio.currentTime = 0 } } </script> </body> </html>