|
@@ -33,29 +33,29 @@ export default {
|
|
|
type: Object,
|
|
|
default: () => {
|
|
|
return {};
|
|
|
- },
|
|
|
+ }, //当前节数据
|
|
|
},
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
vodPlayerJs: "https://player.polyv.net/script/player.js",
|
|
|
player: null,
|
|
|
- HideVideo: false,
|
|
|
- photoList: [],
|
|
|
- photoHistoryList: [],
|
|
|
- photoIndex: 0,
|
|
|
- showRecordStatus: false,
|
|
|
- showRecordSetTimeOut: null,
|
|
|
- openPhotoStatus: 0,
|
|
|
- commitTime: null,
|
|
|
- commitTimePhoto: null,
|
|
|
- timeEventStatus: false,
|
|
|
- timeEventStatusTimeout: null,
|
|
|
- videoPauseSetTimeout: null,
|
|
|
- failToRegister: false,
|
|
|
+ HideVideo: false, //是否隐藏播放器
|
|
|
+ photoList: [], //抓拍时间拍照数组
|
|
|
+ photoHistoryList: [], //历史和已拍照数据
|
|
|
+ photoIndex: 0, //当前拍照对应索引
|
|
|
+ showRecordStatus: false, //是否显示从头播放提示
|
|
|
+ showRecordSetTimeOut: null, //从头播放提示计时器函数
|
|
|
+ openPhotoStatus: 0, //暂存学习状态
|
|
|
+ commitTime: null, //暂存时间-节流
|
|
|
+ commitTimePhoto: null, //判断拍照时刻-节流
|
|
|
+ timeEventStatus: false, //双重保障状态
|
|
|
+ timeEventStatusTimeout: null, //双重保障定时器
|
|
|
+ videoPauseSetTimeout: null, //定时器停留太久触发
|
|
|
+ failToRegister: false, //报名推送不通过
|
|
|
videoPauseSetTimeStatus: false,
|
|
|
player_tencent: null,
|
|
|
- firstPlay: true,
|
|
|
+ firstPlay: true, //是否初次播放
|
|
|
viewSign: null,
|
|
|
};
|
|
|
},
|
|
@@ -65,9 +65,17 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
watch: {
|
|
|
+ // HideVideo: function(newVal, oldVal) {
|
|
|
+ // if (newVal) {
|
|
|
+ // document.getElementById("player-tencent").setAttribute("style","visibility:hidden");
|
|
|
+ // } else {
|
|
|
+ // document.getElementById("player-tencent").setAttribute("style","visibility:visible");
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ //因为刚开始获取不到goodsData的数据 所以需要监听
|
|
|
goodsData: function (newVal, oldVal) {
|
|
|
if (newVal) {
|
|
|
- this.getBeforeWork();
|
|
|
+ this.getBeforeWork(); //处理前置任务
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@@ -75,7 +83,9 @@ export default {
|
|
|
if (!window.polyvPlayer) {
|
|
|
const myScript = document.createElement("script");
|
|
|
myScript.setAttribute("src", this.vodPlayerJs);
|
|
|
- myScript.onload = () => {};
|
|
|
+ myScript.onload = () => {
|
|
|
+ console.log("加载成功");
|
|
|
+ };
|
|
|
document.body.appendChild(myScript);
|
|
|
}
|
|
|
},
|
|
@@ -87,20 +97,20 @@ export default {
|
|
|
this.player.HTML5.video.removeEventListener(
|
|
|
"timeupdate",
|
|
|
this.timeEvent
|
|
|
- );
|
|
|
- this.player.destroy();
|
|
|
+ ); //监听器
|
|
|
+ this.player.destroy(); //初始化播放器
|
|
|
}
|
|
|
if (this.player_tencent) {
|
|
|
- this.player_tencent.dispose();
|
|
|
+ this.player_tencent.dispose(); //初始化播放器
|
|
|
}
|
|
|
- this.initData();
|
|
|
- await this.getRecordHistoryPhoto();
|
|
|
- await this.getRecordLast();
|
|
|
+ this.initData(); //初始化参数
|
|
|
+ await this.getRecordHistoryPhoto(); //获取拍照历史记录
|
|
|
+ await this.getRecordLast(); //获取播放记录
|
|
|
let viewSign = this.viewSign || 1;
|
|
|
if (viewSign == 2) {
|
|
|
- await this.loadPlayer_tencent();
|
|
|
+ await this.loadPlayer_tencent(); //加载播放内容
|
|
|
} else {
|
|
|
- await this.loadPlayer();
|
|
|
+ await this.loadPlayer(); //加载播放内容
|
|
|
}
|
|
|
this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
viewSign == 2 ? "loadstart" : "s2j_onPlayerInitOver",
|
|
@@ -108,23 +118,38 @@ export default {
|
|
|
this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
viewSign == 2 ? "pause" : "s2j_onVideoPause",
|
|
|
this.onVideoPause
|
|
|
- );
|
|
|
+ ); //视频暂停时触发
|
|
|
+ // this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
+ // viewSign == 2 ? "playing" : "s2j_onVideoPlay",
|
|
|
+ // this.onVideoPlay
|
|
|
+ // );
|
|
|
if (viewSign == 2) {
|
|
|
this.player_tencent.on("playing", this.onVideoPlay);
|
|
|
} else {
|
|
|
this.player.on("s2j_onPlayStart", this.onVideoPlay);
|
|
|
this.player.on("s2j_onVideoPlay", this.onVideoPlay);
|
|
|
}
|
|
|
+ //视频播放或由暂停恢复播放时触发
|
|
|
this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
viewSign == 2 ? "ended" : "s2j_onPlayOver",
|
|
|
this.onPlayOver
|
|
|
- );
|
|
|
+ ); //当前视频播放完毕时触发
|
|
|
+
|
|
|
+ // this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
+ // viewSign == 2 ? "error" : "s2j_onPlayerError",
|
|
|
+ // this.onPlayerError
|
|
|
+ // ); //播放出现错误时触发
|
|
|
+ if (viewSign != 2) {
|
|
|
+ this.player.on("serverError", this.serverError); //发生业务逻辑错误时触发,比如授权验证失败、域名黑白名单验证不通过等错误。参数返回事件名称和错误代码。
|
|
|
+ }
|
|
|
}
|
|
|
- );
|
|
|
+ ); //播放器初始化完毕时触发。播放器提供的方法需要在此事件发生后才可以调用。
|
|
|
});
|
|
|
+ // document.addEventListener("visibilitychange", this.pauseVideo);
|
|
|
},
|
|
|
methods: {
|
|
|
getBeforeWork() {},
|
|
|
+ //初始化参数
|
|
|
initData() {
|
|
|
this.timeEventStatus = false;
|
|
|
this.commitTime = null;
|
|
@@ -132,9 +157,10 @@ export default {
|
|
|
this.openPhotoStatus = 0;
|
|
|
this.videoPauseSetTimeStatus = false;
|
|
|
this.firstPlay = true;
|
|
|
- clearTimeout(this.videoPauseSetTimeout);
|
|
|
- clearTimeout(this.timeEventStatusTimeout);
|
|
|
+ clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
|
|
|
+ clearTimeout(this.timeEventStatusTimeout); //删除双重保障定时器
|
|
|
},
|
|
|
+ //获取播放记录
|
|
|
getRecordLast() {
|
|
|
return new Promise((resolve) => {
|
|
|
clearTimeout(this.showRecordSetTimeOut);
|
|
@@ -159,6 +185,7 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ //从头播放
|
|
|
seekVideo0() {
|
|
|
if (this.viewSign == 2) {
|
|
|
this.player_tencent.currentTime(0);
|
|
@@ -167,6 +194,7 @@ export default {
|
|
|
}
|
|
|
this.showRecordStatus = false;
|
|
|
},
|
|
|
+ //获取拍照历史记录
|
|
|
getRecordHistoryPhoto() {
|
|
|
return new Promise((resolve) => {
|
|
|
var data = {
|
|
@@ -179,10 +207,12 @@ export default {
|
|
|
moduleId: this.activeSection.moduleId,
|
|
|
};
|
|
|
this.$request.getPhotoLastRecord(data).then((res) => {
|
|
|
+ //清空历史数据
|
|
|
this.photoList = [];
|
|
|
this.photoHistoryList = [];
|
|
|
this.photoIndex = 0;
|
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
|
+ //-2存储随机拍照数组
|
|
|
if (res.data[i].photoIndex == -2 && res.data[i].timeInterval) {
|
|
|
this.photoList = res.data[i].timeInterval.split(",");
|
|
|
} else {
|
|
@@ -193,20 +223,26 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ //计算拍照逻辑
|
|
|
photoLogic() {
|
|
|
- if (this.photoList.length > 0 || this.activeSection.learning == 1) return;
|
|
|
+ if (this.photoList.length > 0 || this.activeSection.learning == 1) return; //已从历史拍照数据获得
|
|
|
if (this.viewSign == 2) {
|
|
|
var polyvPlayerContext = this.player_tencent;
|
|
|
var totalVideoTime = polyvPlayerContext.duration();
|
|
|
- var duration = polyvPlayerContext.currentTime() || 0;
|
|
|
+ var duration =
|
|
|
+ Number(this.activeSection.videoCurrentTime) ||
|
|
|
+ polyvPlayerContext.currentTime() ||
|
|
|
+ 0;
|
|
|
} else {
|
|
|
var polyvPlayerContext = this.player;
|
|
|
var totalVideoTime = polyvPlayerContext.j2s_getDuration();
|
|
|
- var duration = polyvPlayerContext.j2s_getCurrentTime() || 0;
|
|
|
+ var duration =
|
|
|
+ Number(this.activeSection.videoCurrentTime) ||
|
|
|
+ polyvPlayerContext.j2s_getCurrentTime();
|
|
|
}
|
|
|
if (this.goodsData.erJianErZao) {
|
|
|
this.photoList = this.randomConfig(totalVideoTime, duration);
|
|
|
- } else if (this.goodsData.jjShiGongYuan) {
|
|
|
+ } else if (this.goodsData.jjShiGongYuan && this.goodsData.orderYears) {
|
|
|
this.photoList = this.ShiPhotoList(totalVideoTime, duration);
|
|
|
} else if (this.goodsData.goodsPhotographConfig.photoNum > 0) {
|
|
|
this.photoList = this.getPhotoList(
|
|
@@ -214,36 +250,43 @@ export default {
|
|
|
this.goodsData.goodsPhotographConfig.photoNum
|
|
|
);
|
|
|
}
|
|
|
+ //兼容已有观看历史
|
|
|
for (let i = 0; i < this.photoList.length - 1; i++) {
|
|
|
if (this.photoList[i] < duration && this.photoList[i + 1] > duration) {
|
|
|
this.photoIndex = i + 1;
|
|
|
break;
|
|
|
}
|
|
|
if (duration > this.photoList[this.photoList.length - 1]) {
|
|
|
- this.photoIndex = this.photoList.length - 1;
|
|
|
+ this.photoIndex = this.photoList.length - 1; //取最后一个下标
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ //普通拍照
|
|
|
getPhotoList(totalVideoTime, photoNum) {
|
|
|
let photoList = [];
|
|
|
if (totalVideoTime >= 900) {
|
|
|
+ //大于15分钟
|
|
|
if (photoNum == 1) {
|
|
|
+ //开头拍1张
|
|
|
photoList.push(1);
|
|
|
} else if (photoNum == 3) {
|
|
|
- photoList.push(0);
|
|
|
- let centerTime = Math.floor(totalVideoTime / 2);
|
|
|
- let centerMinTime = centerTime - 300;
|
|
|
+ //拍3张
|
|
|
+ photoList.push(0); //开头拍一张
|
|
|
+ let centerTime = Math.floor(totalVideoTime / 2); //获取中间时间
|
|
|
+ let centerMinTime = centerTime - 300; //前后5分钟
|
|
|
let centerMaxTime = centerTime + 300;
|
|
|
let centerTakeTime = this.randomNum(centerMinTime, centerMaxTime);
|
|
|
- photoList.push(centerTakeTime);
|
|
|
+ photoList.push(centerTakeTime); //中间拍一张
|
|
|
let endMaxTime = totalVideoTime - 60;
|
|
|
let endMinTime = totalVideoTime - 300;
|
|
|
let endTakeTime = this.randomNum(endMinTime, endMaxTime);
|
|
|
- photoList.push(endTakeTime);
|
|
|
+ photoList.push(endTakeTime); //最后拍一张
|
|
|
}
|
|
|
} else {
|
|
|
+ //小于15分钟,只拍前后各一张
|
|
|
if (photoNum == 1) {
|
|
|
+ //开头拍1张
|
|
|
photoList.push(1);
|
|
|
} else if (photoNum == 3) {
|
|
|
photoList.push(1);
|
|
@@ -259,16 +302,18 @@ export default {
|
|
|
photoList.push(endTakeTime);
|
|
|
}
|
|
|
}
|
|
|
- this.postCoursePhotoRecord(true);
|
|
|
+ this.postCoursePhotoRecord(true); //提交随机拍照时间数组
|
|
|
return photoList;
|
|
|
},
|
|
|
+ //施工继教
|
|
|
ShiPhotoList(totalVideoTime) {
|
|
|
+ //施工继教带年份的订单拍照设置
|
|
|
if (totalVideoTime < 2760) {
|
|
|
- var time1 = 46 * 60 - 1;
|
|
|
+ var time1 = 46 * 60 - 1; //拍照间隔多久一张 46分钟
|
|
|
} else {
|
|
|
- var time1 = 45 * 60 - 1;
|
|
|
+ var time1 = 45 * 60 - 1; //拍照间隔多久一张 45分钟
|
|
|
}
|
|
|
- let num = Math.ceil(totalVideoTime / time1);
|
|
|
+ let num = Math.ceil(totalVideoTime / time1); //拍照数量
|
|
|
let photoList = [];
|
|
|
if (num == 1) {
|
|
|
photoList.push(parseInt(totalVideoTime / 2));
|
|
@@ -279,6 +324,8 @@ export default {
|
|
|
}
|
|
|
return photoList;
|
|
|
},
|
|
|
+
|
|
|
+ // 随机拍摄时间(二建)
|
|
|
randomConfig(totalVideoTime, duration) {
|
|
|
this.photoHistoryList = [];
|
|
|
let photoList = [duration];
|
|
@@ -294,6 +341,7 @@ export default {
|
|
|
}
|
|
|
return photoList;
|
|
|
},
|
|
|
+ //postTime = true 只提交随机时间 false 提交拍照
|
|
|
postCoursePhotoRecord(postTime = false, photoUrl) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
if (this.viewSign == 2) {
|
|
@@ -311,7 +359,7 @@ export default {
|
|
|
sectionId: this.activeSection.sectionId,
|
|
|
photo: postTime ? "" : photoUrl,
|
|
|
photoTime: parseInt(currentTime > 0 ? currentTime : 0),
|
|
|
- photoIndex: postTime ? -2 : parseInt(this.photoIndex),
|
|
|
+ photoIndex: postTime ? -2 : parseInt(this.photoIndex), //从0算起,-2只提交随机时间
|
|
|
photoNum: parseInt(this.goodsData.goodsPhotographConfig.photoNum),
|
|
|
timeInterval: postTime ? this.photoList.join(",") : "",
|
|
|
};
|
|
@@ -325,16 +373,21 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ //随机拍摄时间
|
|
|
randomNum(minNum, maxNum) {
|
|
|
switch (arguments.length) {
|
|
|
case 1:
|
|
|
return parseInt(Math.random() * minNum + 1, 10);
|
|
|
+ break;
|
|
|
case 2:
|
|
|
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
|
|
|
+ break;
|
|
|
default:
|
|
|
return 0;
|
|
|
+ break;
|
|
|
}
|
|
|
},
|
|
|
+ // 播放视频
|
|
|
loadPlayer() {
|
|
|
return new Promise((resolve) => {
|
|
|
var self = this;
|
|
@@ -361,30 +414,31 @@ export default {
|
|
|
wrap: "#player",
|
|
|
width: 810,
|
|
|
height: 455,
|
|
|
- preventKeyboardEvent: true,
|
|
|
- showLine: true,
|
|
|
- ban_history_time: "on",
|
|
|
+ preventKeyboardEvent: true, //是否屏蔽键盘事件,为true时屏蔽。
|
|
|
+ showLine: true, //是否显示线路选择按钮
|
|
|
+ ban_history_time: "on", //是否禁用续播功能,取值:{on,off}。
|
|
|
vid: self.activeSection.recordingUrl,
|
|
|
- autoplay: autoPlay,
|
|
|
- ban_seek: isAllowSeek,
|
|
|
- speed: playbackRate,
|
|
|
- teaser_show: 1,
|
|
|
- tail_show: 1,
|
|
|
- hideSwitchPlayer: true,
|
|
|
- watchStartTime: self.activeSection.videoCurrentTime || 0,
|
|
|
- ts: res.data.ts,
|
|
|
- sign: res.data.sign,
|
|
|
+ autoplay: autoPlay, // 是否自动播放。
|
|
|
+ ban_seek: isAllowSeek, //是否禁止拖拽进度条,取值:{on,off}。
|
|
|
+ speed: playbackRate, //当speed参数值为boolean类型时,代表是否显示倍速切换的按钮。
|
|
|
+ teaser_show: 1, //是否播放片头:0 不播放,1 播放。片头可在管理后台进行设置。
|
|
|
+ tail_show: 1, //是否播放片尾:0 不播放,1 播放。片尾可在管理后台进行设置。
|
|
|
+ hideSwitchPlayer: true, //是否隐藏H5和Flash播放器的切换按钮。
|
|
|
+ watchStartTime: self.activeSection.videoCurrentTime || 0, // 播放开始时间,表示视频从第几秒开始播放,参数值需小于视频时长。
|
|
|
+ ts: res.data.ts, //移动播放加密视频需传入的时间戳。
|
|
|
+ sign: res.data.sign, //移动端播放加密视频所需的签名。
|
|
|
playsafe: function (vid, next) {
|
|
|
self.$request.obtainpolyvvideopcsign(vid).then((res) => {
|
|
|
next(res.data);
|
|
|
});
|
|
|
- },
|
|
|
+ }, //PC端播放加密视频所需的授权凭证。
|
|
|
});
|
|
|
- self.$emit("videoScript", this.player);
|
|
|
+ self.$emit("videoScript", this.player); //抛出播放实例
|
|
|
resolve();
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ //播放视频-腾讯
|
|
|
loadPlayer_tencent() {
|
|
|
return new Promise(async (resolve) => {
|
|
|
try {
|
|
@@ -424,25 +478,34 @@ export default {
|
|
|
progressControl: isAllowSeek,
|
|
|
playbackRateMenuButton: playbackRate,
|
|
|
},
|
|
|
- fileID: this.activeSection.recordingUrl,
|
|
|
- appID: data.appID,
|
|
|
- licenseUrl: data.licenseUrl,
|
|
|
+ // player-tencent 为播放器容器 ID,必须与 html 中一致
|
|
|
+ fileID: this.activeSection.recordingUrl, // 请传入需要播放的视频 fileID(必须)
|
|
|
+ appID: data.appID, // 请传入点播账号的 appID(必须)
|
|
|
+ licenseUrl: data.licenseUrl, // 请传入点播账号的 appID(必须)
|
|
|
+ //私有加密播放需填写 psign, psign 即播放器签名,签名介绍和生成方式参见链接:https://cloud.tencent.com/document/product/266/42436
|
|
|
psign: data.psign,
|
|
|
});
|
|
|
- this.$emit("videoScript", this.player_tencent);
|
|
|
+ this.$emit("videoScript", this.player_tencent); //抛出播放实例
|
|
|
resolve();
|
|
|
- } catch (error) {}
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error, "error");
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
+ //监听器
|
|
|
timeEvent() {
|
|
|
- this.timeEventStatus = true;
|
|
|
+ console.log("监听器执行中~");
|
|
|
+ this.timeEventStatus = true; //双重保障
|
|
|
+ // 定时提交学习记录
|
|
|
this.submitStudyRecords();
|
|
|
+ //拍照监听执行
|
|
|
let time = new Date().getTime();
|
|
|
if (time >= this.commitTimePhoto) {
|
|
|
this.watchPhoto();
|
|
|
this.commitTimePhoto = time + 1000;
|
|
|
}
|
|
|
},
|
|
|
+ //拍照监听执行
|
|
|
watchPhoto() {
|
|
|
if (
|
|
|
this.photoList.length == 0 ||
|
|
@@ -456,38 +519,48 @@ export default {
|
|
|
} else {
|
|
|
var videoTime = this.player.j2s_getCurrentTime();
|
|
|
}
|
|
|
- let photoTime = 0;
|
|
|
+ let photoTime = 0; //获取拍照秒数
|
|
|
for (let i = 0; i < this.photoList.length; i++) {
|
|
|
- photoTime = Number(this.photoList[i]);
|
|
|
+ photoTime = Number(this.photoList[i]); //获取拍照秒数
|
|
|
if (photoTime < videoTime && photoTime > videoTime - 8) {
|
|
|
+ //3秒区间内才触发拍照,避免拉动滚动条
|
|
|
if (
|
|
|
this.photoHistoryList.indexOf(i) < 0 &&
|
|
|
this.activeSection.learning != 1
|
|
|
) {
|
|
|
+ //不存在拍照历史,没有重修过,没有学过,则拍照
|
|
|
if (this.viewSign == 2) {
|
|
|
- this.player_tencent.pause();
|
|
|
+ this.player_tencent.pause(); //暂停
|
|
|
} else {
|
|
|
- this.player.j2s_pauseVideo();
|
|
|
+ this.player.j2s_pauseVideo(); //暂停
|
|
|
}
|
|
|
this.photoIndex = i;
|
|
|
- this.openPhoto();
|
|
|
+ this.openPhoto(); //启动拍照
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ // 定时提交学习记录
|
|
|
submitStudyRecords() {
|
|
|
let time = new Date().getTime();
|
|
|
if (time >= this.commitTime) {
|
|
|
+ if (!this.commitTime) {
|
|
|
+ //防止发生获取不到视频播放时长
|
|
|
+ this.commitTime = time + 3000;
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.postStudyRecord(0, null, null);
|
|
|
this.commitTime = time + 15000;
|
|
|
}
|
|
|
},
|
|
|
+ //视频暂停时触发
|
|
|
onVideoPause() {
|
|
|
if (
|
|
|
this.activeSection.learning != 1 &&
|
|
|
this.goodsData.erJianErZao &&
|
|
|
!this.failToRegister
|
|
|
) {
|
|
|
+ console.log("拍照停留过长计时开始");
|
|
|
this.videoPauseSetTimeout = setTimeout(() => {
|
|
|
if (this.isFullScreen()) {
|
|
|
this.exitFullscreen();
|
|
@@ -510,26 +583,35 @@ export default {
|
|
|
this.$router.go(0);
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
- }, 300000);
|
|
|
+ }, 300000); //300000
|
|
|
}
|
|
|
},
|
|
|
+ //视频恢复播放时触发
|
|
|
onVideoPlay() {
|
|
|
+ console.log("触发一下吧");
|
|
|
if (this.firstPlay) {
|
|
|
this.firstPlay = false;
|
|
|
+ //计算拍照逻辑
|
|
|
this.photoLogic();
|
|
|
+ //开启上次播放位置提示
|
|
|
if (this.activeSection.videoCurrentTime) {
|
|
|
this.showRecordStatus = true;
|
|
|
+ if (this.viewSign == 2) {
|
|
|
+ this.player_tencent.currentTime(
|
|
|
+ Number(this.activeSection.videoCurrentTime) || 0
|
|
|
+ );
|
|
|
+ }
|
|
|
this.showRecordSetTimeOut = setTimeout(() => {
|
|
|
this.showRecordStatus = false;
|
|
|
}, 5000);
|
|
|
}
|
|
|
if (this.viewSign == 2) {
|
|
|
- this.player_tencent.on("timeupdate", this.timeEvent);
|
|
|
+ this.player_tencent.on("timeupdate", this.timeEvent); //当前视频播放中触发
|
|
|
} else {
|
|
|
this.player.HTML5.video.addEventListener(
|
|
|
"timeupdate",
|
|
|
this.timeEvent
|
|
|
- );
|
|
|
+ ); //监听器
|
|
|
}
|
|
|
this.timeEventStatusTimeout = setTimeout(() => {
|
|
|
if (!this.timeEventStatus) {
|
|
@@ -555,17 +637,21 @@ export default {
|
|
|
}, 5000);
|
|
|
}
|
|
|
clearTimeout(this.videoPauseSetTimeout);
|
|
|
+ console.log("视频恢复播放时触发");
|
|
|
},
|
|
|
+ //当前视频播放完毕时触发
|
|
|
onPlayOver() {
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
message: "播放完毕",
|
|
|
});
|
|
|
this.isFullScreen();
|
|
|
- clearTimeout(this.videoPauseSetTimeout);
|
|
|
+ clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
|
|
|
this.postStudyRecord(1);
|
|
|
+ console.log("当前视频播放完毕时触发");
|
|
|
},
|
|
|
|
|
|
+ //判断是全屏则退出全屏
|
|
|
isFullScreen() {
|
|
|
if (!!(document.webkitIsFullScreen || this.fullele())) {
|
|
|
try {
|
|
@@ -589,6 +675,7 @@ export default {
|
|
|
null
|
|
|
);
|
|
|
},
|
|
|
+ //播放出现错误时触发
|
|
|
onPlayerError(title, msg) {
|
|
|
this.$router.go(-1);
|
|
|
this.$notify.error({
|
|
@@ -597,20 +684,27 @@ export default {
|
|
|
message: msg || "视频播放错误,请及时反馈教务人员处理",
|
|
|
});
|
|
|
},
|
|
|
+ //发生业务逻辑错误
|
|
|
+ serverError() {
|
|
|
+ clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
|
|
|
+ this.$message.error("视频错误或解码失败");
|
|
|
+ },
|
|
|
+ //启动拍照
|
|
|
openPhoto() {
|
|
|
if (this.isFullScreen()) {
|
|
|
this.exitFullscreen();
|
|
|
}
|
|
|
setTimeout(() => {
|
|
|
if (this.viewSign == 2) {
|
|
|
- this.player_tencent.pause();
|
|
|
+ this.player_tencent.pause(); //暂停
|
|
|
} else {
|
|
|
- this.player.j2s_pauseVideo();
|
|
|
+ this.player.j2s_pauseVideo(); //暂停
|
|
|
}
|
|
|
}, 1000);
|
|
|
this.$refs.takePicture.openPhoto();
|
|
|
this.HideVideo = true;
|
|
|
},
|
|
|
+ //拍照成功回显 url
|
|
|
async returnParameter(url) {
|
|
|
let file = this.$tools.convertBase64UrlToBlob(url);
|
|
|
try {
|
|
@@ -623,7 +717,9 @@ export default {
|
|
|
type: "warning",
|
|
|
message: "上传接口报错,请重新拍照上传",
|
|
|
});
|
|
|
- this.openPhoto();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.openPhoto();
|
|
|
+ }, 1500);
|
|
|
return;
|
|
|
}
|
|
|
let compareFaceData = await this.faceRecognition(photoUrl);
|
|
@@ -636,7 +732,8 @@ export default {
|
|
|
0,
|
|
|
photoUrl,
|
|
|
compareFaceData
|
|
|
- );
|
|
|
+ ); //提交记录
|
|
|
+ //恢复播放
|
|
|
if (STATUS) {
|
|
|
if (this.viewSign == 2) {
|
|
|
var polyvPlayerContext = this.player_tencent;
|
|
@@ -652,6 +749,7 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
+ console.log(err, "err");
|
|
|
this.$message({
|
|
|
type: "warning",
|
|
|
message: "上传接口报错,请重新拍照上传",
|
|
@@ -670,6 +768,11 @@ export default {
|
|
|
}, 1500);
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交观看记录
|
|
|
+ * status 1 学完 0未学完
|
|
|
+ */
|
|
|
postStudyRecord(status = 0, imgUrl, compareFaceData) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let currentTime = 0;
|
|
@@ -677,14 +780,14 @@ export default {
|
|
|
if (this.viewSign == 2) {
|
|
|
var polyvPlayerContext = this.player_tencent;
|
|
|
if (polyvPlayerContext) {
|
|
|
- currentTime = polyvPlayerContext.currentTime();
|
|
|
- PlayDuration = currentTime;
|
|
|
+ currentTime = polyvPlayerContext.currentTime(); //当前视频播放时刻
|
|
|
+ PlayDuration = currentTime; //本次看的时长--与保利威的不一致
|
|
|
}
|
|
|
} else {
|
|
|
var polyvPlayerContext = this.player;
|
|
|
if (polyvPlayerContext) {
|
|
|
- currentTime = polyvPlayerContext.j2s_getCurrentTime();
|
|
|
- PlayDuration = polyvPlayerContext.j2s_realPlayVideoTime();
|
|
|
+ currentTime = polyvPlayerContext.j2s_getCurrentTime(); //当前视频播放时刻
|
|
|
+ PlayDuration = polyvPlayerContext.j2s_realPlayVideoTime(); //本次看的时长
|
|
|
}
|
|
|
}
|
|
|
let data = {
|
|
@@ -695,7 +798,7 @@ export default {
|
|
|
moduleId: this.activeSection.moduleId,
|
|
|
chapterId: this.activeSection.chapterId,
|
|
|
sectionId: this.activeSection.sectionId,
|
|
|
- fromPlat: 2,
|
|
|
+ fromPlat: 2, //来源平台 1小程序 2网站
|
|
|
photo: imgUrl || "",
|
|
|
studyDuration: parseInt(PlayDuration > 0 ? PlayDuration : 0),
|
|
|
videoCurrentTime: parseInt(currentTime > 0 ? currentTime : 0),
|
|
@@ -703,11 +806,12 @@ export default {
|
|
|
};
|
|
|
|
|
|
if (imgUrl) {
|
|
|
- data.similarity = compareFaceData;
|
|
|
+ data.similarity = compareFaceData; // 相似度
|
|
|
}
|
|
|
if (status > 0) {
|
|
|
data.status = status;
|
|
|
}
|
|
|
+ // /study/record 学习记录
|
|
|
this.$request
|
|
|
.studyRecord(data)
|
|
|
.then((res) => {
|
|
@@ -731,7 +835,7 @@ export default {
|
|
|
} else {
|
|
|
polyvPlayerContext.j2s_pauseVideo();
|
|
|
}
|
|
|
- this.failToRegister = true;
|
|
|
+ this.failToRegister = true; //报名推送不通过
|
|
|
this.$confirm(`您的信息正在推送中,请稍后再进入学习!`, "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
closeOnClickModal: false,
|
|
@@ -741,12 +845,15 @@ export default {
|
|
|
showClose: false,
|
|
|
})
|
|
|
.then((_) => {
|
|
|
+ //停止执行-退出页面
|
|
|
this.$router.back(-1);
|
|
|
})
|
|
|
.catch((_) => {
|
|
|
+ //停止执行-退出页面
|
|
|
this.$router.back(-1);
|
|
|
});
|
|
|
} else if (err.code === 559) {
|
|
|
+ console.log("拍照不够触发");
|
|
|
this.$message.error(err.msg);
|
|
|
this.openPhotoStatus = 1;
|
|
|
setTimeout(() => {
|
|
@@ -762,11 +869,13 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ //人脸校验
|
|
|
faceRecognition(url) {
|
|
|
return new Promise((resolve) => {
|
|
|
this.$request
|
|
|
.faceCertificationCompareFace({
|
|
|
urlA: url,
|
|
|
+ // imageA: url,
|
|
|
orderGoodsId: this.goodsData.orderGoodsId,
|
|
|
gradeId: this.goodsData.gradeId,
|
|
|
})
|
|
@@ -789,6 +898,7 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ //页面显示隐藏逻辑
|
|
|
pauseVideo() {
|
|
|
if (
|
|
|
this.$refs.takePicture.takePhotoModal ||
|
|
@@ -811,17 +921,23 @@ export default {
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
this.$bus.$off("toPlay");
|
|
|
- clearTimeout(this.videoPauseSetTimeout);
|
|
|
+ clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
|
|
|
+ // document.removeEventListener("visibilitychange", this.pauseVideo);
|
|
|
if (this.player) {
|
|
|
- this.player.HTML5.video.removeEventListener("timeupdate", this.timeEvent);
|
|
|
- this.player.destroy();
|
|
|
+ this.player.HTML5.video.removeEventListener("timeupdate", this.timeEvent); //监听器
|
|
|
+ this.player.destroy(); //初始化播放器
|
|
|
}
|
|
|
if (this.player_tencent) {
|
|
|
this.player_tencent.off();
|
|
|
- this.player_tencent.dispose();
|
|
|
+ this.player_tencent.dispose(); //初始化播放器
|
|
|
}
|
|
|
this.timeEventStatus = false;
|
|
|
- clearTimeout(this.timeEventStatusTimeout);
|
|
|
+ clearTimeout(this.timeEventStatusTimeout); //删除双重保障定时器
|
|
|
+ try {
|
|
|
+ this.$msgbox.close();
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error, "element ui - msgBox close error");
|
|
|
+ }
|
|
|
},
|
|
|
};
|
|
|
</script>
|