Audio seekable Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Audio

Description

The seekable property returns a TimeRanges object, which represents ranges of the audio that are available for seeking for user.

This property is read-only.

Return Value

Type Description
TimeRanges Object Represents the seekable parts of the audio.

TimeRanges Object Properties:

  • length - the number of seekable ranges
  • start - the start position of a seekable range
  • end - the end position of a seekable range

The first seekable range is index 0

The following code shows how to get the first seekable range of the audio in seconds:

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   www  .java2  s  .  com

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
    var x = document.getElementById("myAudio");
    document.getElementById("demo").innerHTML = "Start: " + x.seekable.start(0) + " End: " + x.seekable.end(0);
}
</script>

</body>
</html>

Related Tutorials