Skip to content

Instantly share code, notes, and snippets.

@Moln
Created October 11, 2017 04:40
Show Gist options
  • Save Moln/7ce607d8575477fe3fdfe6315d35464a to your computer and use it in GitHub Desktop.
Save Moln/7ce607d8575477fe3fdfe6315d35464a to your computer and use it in GitHub Desktop.

Html_video倒序播放功能

HTMLVideoElement.prototype.playBackwards = function() {
    this.pause();
    var video = this;
    var fps = video.fps || 25;
    var wait = 1000 / fps;
    var intervalRewind = setInterval(function() {
        //if (video.seeking) return ;
        if(video.currentTime == 0){
           clearInterval(intervalRewind);
           video.pause();
        }
        else {
            video.currentTime += -(1/fps);
            //console.log(video.currentTime)
        }
    }, wait);
};

问题/缺陷: 视频文件较长较大情况, 每一次的 currentTime 变化, video 都在 seeking 状态,而且时间较长, 不适用于大视频倒放

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment