video 播放视频禁止拖动进度条

该代码段涉及HTML视频元素的控制,包括通过ID获取视频元素,设置播放事件监听器,恢复本地存储的播放时间,并在暂停时更新存储的时间。它还包含一个定时器函数来跟踪和可能重置视频播放位置。
   <video id="my-video" class="video-js vjs-big-play-centered" controls="controls" poster=""  webkit-playsinline="true">
        <source src="/paper/questions/getVideo" type='video/mp4'>
    </video>

```css
	  var elevideo = document.getElementById('my-video');
    var that = this;
    var resetTime = 0; // 拖动后重置播放时间
    var curTime = 0;  // 当前播放时间
    var getCurTime = localStorage.getItem('remTime'); //获取本地存储
    if ( getCurTime > 0.1) {
        curTime = getCurTime;
        resetTime = getCurTime;
        elevideo.addEventListener('play',function(){
            setTimeout(function(){
                elevideo.currentTime = getCurTime;
                setInterval(timer,100)
            },2000)
        })
    } else {
        elevideo.play();
        setInterval(timer,100)
    }

    // 定时器
    function timer () {
        curTime = elevideo.currentTime;
        var apartTime = curTime - resetTime;
        if(apartTime > 2) {
            elevideo.currentTime = resetTime;
        } else {
            resetTime = curTime;
        }
        that.curTime = curTime;
    }

    elevideo.addEventListener('pause',function(){
        localStorage.setItem('remTime',that.curTime);
    })

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值