Audio ended Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Audio

Description

The ended property returns whether the playback of the audio has ended.

An audio has ended when the playback position is at the end of the audio.

This property is read-only.

Return Value

A Boolean, returns true if the playback has ended, otherwise it returns false

The following code shows how to Find out if the audio has ended:

Demo Code

ResultView the demo in separate window

<!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>/*from w ww.  j a  va  2 s .c om*/

<button onclick="myFunction()">find out if the audio has ended</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myAudio").ended;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials