playA(videoId) {
let num = 0;
var that = this;
// var resetTime = 0; // 拖动后重置播放时间
var curTime = 0; // 当前播放时间
var vd = document.querySelector(videoId); //获取video对象//获取本地存储(一般获取不到)
function tiemr() {
let nowTime = vd.currentTime;
let oldTime = curTime + 2; //如果在不拖拽的情况下,定时器,每一秒执行后都
if (oldTime < nowTime) {
vd.currentTime = curTime;
that.$toast("视频不允许前进");
return;
}
// 将1秒钱的视频时间赋值给curTime
let time = nowTime;
curTime = time;
// 视频学习到70%就可以代表已经学完视频
if (that.toatCurtimr * 0.1 < curTime) {
that.flage=true
}
}
vd.addEventListener("play", function () {
//当前视频的播放
that.toatCurtimr = vd.duration; //获取视频的时长
if (!num) {
setInterval(tiemr, 1000);
num = 1;
}
});
// 视频播放结束执行
vd.addEventListener("ended", function () {
// that.flage = true;
});
},