Javascript DOM onloadstart Event on <audio>

Introduction

Execute a JavaScript when the audio is starting to load:

View in separate window

<!DOCTYPE html>
<html>
<body>

<audio controls onloadstart="myFunction()">
  <source src="sound.ogg" type="audio/ogg">
  <source src="sound.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>//w  ww. j  a  v a2s.com

<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Starting to load audio";
}
</script>

</body>
</html>



PreviousNext

Related