Audio playbackRate Property - Set the audio to play fast: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Audio

Description

Audio playbackRate Property - Set the audio to play fast:

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><br>

<button onclick="getPlaySpeed()" type="button">What is playback speed?</button>
<button onclick="setPlaySpeed()" type="button">Set audio to be play fast</button>

<script>
var x = document.getElementById("myAudio");

function getPlaySpeed() {/*  w  w w  .ja v  a2  s. co  m*/
    console.log(x.playbackRate);
}

function setPlaySpeed() {
    x.playbackRate = 2;
}
</script>

</body>
</html>

Related Tutorials