html5 video play by scrolling with the mouse wheel

后端 未结 5 987
無奈伤痛
無奈伤痛 2020-12-30 06:43

I want to be able to make a web page that plays a video forward and backward when they scroll with the mouse wheel up and down. It seems conceivable, via HTML5 and possibly

5条回答
  •  梦毁少年i
    2020-12-30 06:59

    I'm using this. It's not perfect, but it should help you.

    var videoScrollTop = $(document).scrollTop();
    $(document).scroll(function() {
        var vid = $('#video')[0];
        if(videoScrollTop < $(document).scrollTop()){
            vid.currentTime += 0.081;
        } else {
            vid.currentTime -= 0.081;
        }
        videoScrollTop = $(document).scrollTop();
    });
    

提交回复
热议问题