Javascript DOM onprogress Event on <audio> element

Introduction

Execute a JavaScript when the audio is downloading:

View in separate window

<!DOCTYPE html>
<html>
<body>

<audio controls onprogress="myFunction()">
  <source src="sound.ogg" type="audio/ogg">
  <source src="sound.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>//from w  w w .j a  v  a2s . c  o m

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

</body>
</html>



PreviousNext

Related