Audio controller Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Audio

Description

The controller property returns the current media controller of the audio.

Return Value

Type Description
MediaController Object Represents the media controller of the audio.

MediaController Object properties/methods:

  • buffered - get the buffered ranges of the audio
  • seekable - get the seekable ranges of the audio
  • duration - get the duration of the audio
  • currentTime - get or set the current playback position of the audio
  • paused - check if the audio is paused
  • play() - play the audio
  • pause() - pause the audio
  • played - check if the audio has been played
  • defaultPlaybackRate - get or set the default playback rate of the audio
  • playbackRate - get or set the current playback rate of the audio
  • volume - get or set the volume of the audio
  • muted - get or set if the audio is muted

The following code shows how to Find out if the audio has a media controller:

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 w  w.  ja  v a 2 s. c  o  m

<button onclick="myFunction()">check if the audio has a media controller</button>

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

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

</body>
</html>

Related Tutorials