繁体   English   中英

Mousewheel滚动HTML5视频jQuery

[英]Mousewheel Scroll HTML5 Video jQuery

我希望能够使用鼠标滚轮控制我的视频。 到目前为止,我已经做到了。 我要走的Mac Pro网站的路线。 我已将其绑定到鼠标滚轮,并且当用户向下滚动时它开始播放。

我想做的是在达到特定间隔(例如2秒)后停止播放视频。 但是,由于帧的长度,视频可能会跳过此时间,即从1.98变为2.05s ...

为了解决这个问题,我使用了Math.floor函数。 但是,随之而来的另一个问题是-这将发生多次。

是否有人对阈值函数等更好的解决方案有任何想法?

        // Do stuff when specific time intervals are reached
        $(video).on('timeupdate', function() {

            if (Math.floor(video.currentTime) == 2){
                video.pause();
                console.log("Pausing video... ");
            }
            else if(video.ended){
                // Move to next section
                return true;
            }
        });

您不能使用>=比较而不是检查下限时间吗?

            if (video.currentTime >= 2){
                video.pause();
                console.log("Pausing video... ");
            }
            else if(video.ended){
                // Move to next section
                return true;
            }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM