Javascript DOM onloadeddata Event on <audio> element

Introduction

Execute a JavaScript when data for the current frame is available for <audio>.

View in separate window

<!DOCTYPE html>
<html>
<body>

<audio controls onloadeddata="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 ww .  j a  va2 s.  co  m*/

<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Browser has loaded the current frame";
}
</script>

</body>
</html>



PreviousNext

Related