Audio defaultPlaybackRate Property - Set the audio to play faster by default: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Audio

Description

Audio defaultPlaybackRate Property - Set the audio to play faster by default:

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 the default playback speed?</button>
<button onclick="setPlaySpeed()" type="button">Set video to be play fast</button>

<script>
var x = document.getElementById("myAudio");
function getPlaySpeed() {/*  w ww . j a  v a2  s. c om*/
    console.log(x.defaultPlaybackRate);
}

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

</body>
</html>

Related Tutorials