Javascript examples for DOM HTML Element:Audio
The defaultPlaybackRate property sets or gets the default playback speed of the audio.
To change the current playback speed, use the playbackRate property.
Set the defaultPlaybackRate property with the following Values
Value | Description |
---|---|
number | Indicates the default playback speed of the audio. |
Example values:
The value 0.0 is invalid and throws a NOT_SUPPORTED_ERR exception
A Number, representing the default playback speed
The following code shows how to Set the audio to slow motion by default:
<!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() {/*from ww w . j a v a2s . c o m*/ console.log(x.defaultPlaybackRate); } function setPlaySpeed() { x.defaultPlaybackRate = 2; x.load(); } </script> </body> </html>