Javascript examples for DOM HTML Element:Audio
Audio autoplay Property - Enable autoplay, and reload the video:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio><br> <button onclick="enableAutoplay()" type="button">Enable autoplay</button> <button onclick="disableAutoplay()" type="button">Disable autoplay</button> <button onclick="checkAutoplay()" type="button">Check autoplay status</button> <script> var x = document.getElementById("myAudio"); function enableAutoplay() {/*from w ww. j a v a2s.c o m*/ x.autoplay = true; x.load(); } function disableAutoplay() { x.autoplay = false; x.load(); } function checkAutoplay() { console.log(x.autoplay); } </script> </body> </html>