Javascript examples for DOM HTML Element:Audio
The playbackRate property sets or gets the current playback speed of the audio.
Set the playbackRate property with the following Values
Value | Description |
---|---|
playbackspeed | Indicates the current playback speed of the audio. |
Example values:
A Number, representing the current playback speed
The following code shows how to set the audio to play in slow motion:
<!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() {/*from w w w . ja v a2 s . c o m*/ console.log(x.playbackRate); } function setPlaySpeed() { x.playbackRate = 2; } </script> </body> </html>