Home  >  Article  >  Web Front-end  >  How to change the playback speed of a video in HTML5?

How to change the playback speed of a video in HTML5?

王林
王林forward
2023-09-16 13:45:031783browse

How to change the playback speed of a video in HTML5?

Use the playbackRate property to set the current playback speed of audio/video. Through this attribute, the defaultPlaybackRate attribute sets the default playback speed of audio/video.

You can try running the following code to change the playback speed of the video −

/* play video thrice as fast */
document.querySelector('video').defaultPlaybackRate = 3.0;
document.querySelector('video').play();

Here’s how to play the video at twice the speed −

/* play video twice as fast */
document.querySelector('video').playbackRate = 2;

The above is the detailed content of How to change the playback speed of a video in HTML5?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete