1***@qq.com
1***@qq.com
  • 发布:2023-09-25 11:50
  • 更新:2023-09-25 11:50
  • 阅读:978

关于uniapp video @timeupdate被频繁触发的问题

分类:uni-app

频繁触发timeupdate在真机上视频会一直转圈圈,timeupdate里面写了未观看部分禁止拖动进度条的逻辑

<video id="player" class="video" :src="videoUrl" @timeupdate="timeupdate" @play="play"  
                    @pause="pause"></video>  

    play() {  
                if (!this.firstPlay) {  
                    this.firstPlay = true  
                    this.videoContext.seek(this.nowTime)  
                    console.log(this.nowTime, 'nowTime')  
                }  
                this.playing = true  
                // clearInterval(this.timer)  
                // this.timer = null  
                this.timer = setInterval(() => {  
                    请求视频进度接口  
                }, 5000)  
            },  
            pause() {  
                console.log('pause')  
                this.playing = false  
                clearInterval(this.timer)  
                this.timer = null  
                请求视频进度接口  
            },  
    timeupdate(e) {  
                // this.lastTime = e.detail.currentTime  
                var nextTime = e.detail.currentTime  
                //往右边拖动进度条  
                if (nextTime > this.lastTime + 2) {  
                    clearInterval(this.timer)  
                    this.timer = null  
                    // 不能超过最大观看时间  
                    if (nextTime > this.maxTime) {  
                        // 强制拉回最大观看时间  
                        this.videoContext.seek(this.maxTime)  
                        return  
                    }  
                }  
                this.lastTime = nextTime  
                this.maxTime = Math.max(this.maxTime, this.lastTime)  
            },
2023-09-25 11:50 负责人:无 分享
已邀请:

要回复问题请先登录注册