How to change the playing speed of videos in HTML5?

前端 未结 4 835
刺人心
刺人心 2020-11-28 18:45

How to change the video play speed in HTML5? I\'ve checked video tag\'s attributes in w3school but couldn\'t approach that.Any help would be appreciated!

相关标签:
4条回答
  • 2020-11-28 19:10

    Just type

    document.querySelector('video').playbackRate = 1.25;
    

    in JS console of your modern browser.

    0 讨论(0)
  • 2020-11-28 19:15
    javascript:document.getElementsByClassName("video-stream html5-main-video")[0].playbackRate = 0.1;
    

    you can put any number here just don't go to far so you don't overun your computer.

    0 讨论(0)
  • 2020-11-28 19:15

    You can use this code:

    var vid = document.getElementById("video1");
    
    function slowPlaySpeed() { 
        vid.playbackRate = 0.5;
    } 
    
    function normalPlaySpeed() { 
        vid.playbackRate = 1;
    } 
    
    function fastPlaySpeed() { 
        vid.playbackRate = 2;
    }
    
    0 讨论(0)
  • 2020-11-28 19:31

    According to this site, this is supported in the playbackRate and defaultPlaybackRate attributes, accessible via the DOM. Example:

    /* play video twice as fast */
    document.querySelector('video').defaultPlaybackRate = 2.0;
    document.querySelector('video').play();
    
    /* now play three times as fast just for the heck of it */
    document.querySelector('video').playbackRate = 3.0;
    

    The above works on Chrome 43+, Firefox 20+, IE 9+, Edge 12+.

    0 讨论(0)
提交回复
热议问题