|
@@ -5,7 +5,7 @@
|
|
|
backgroundImage: `url(${$tools.splitImgHost(goodsData.coverUrl, false)})`
|
|
|
}"
|
|
|
>
|
|
|
- <div id="player" v-show="!HideVideo || activeSection.playSource == 1"></div>
|
|
|
+ <div id="player" v-show="!HideVideo || viewSign == 1"></div>
|
|
|
|
|
|
<div class="recordStyle" v-if="showRecordStatus">
|
|
|
您上次看{{
|
|
@@ -55,7 +55,8 @@ export default {
|
|
|
failToRegister: false, //报名推送不通过
|
|
|
videoPauseSetTimeStatus: false,
|
|
|
player_tencent: null,
|
|
|
- firstPlay: true //是否初次播放
|
|
|
+ firstPlay: true, //是否初次播放
|
|
|
+ viewSign: null
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -90,8 +91,8 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
this.$bus.$on("toPlay", async item => {
|
|
|
+ this.viewSign = this.goodsData.viewSign;
|
|
|
if (this.player) {
|
|
|
- console.log("1");
|
|
|
this.player.HTML5 &&
|
|
|
this.player.HTML5.video.removeEventListener(
|
|
|
"timeupdate",
|
|
@@ -100,39 +101,38 @@ export default {
|
|
|
this.player.destroy(); //初始化播放器
|
|
|
}
|
|
|
if (this.player_tencent) {
|
|
|
- console.log("2");
|
|
|
this.player_tencent.dispose(); //初始化播放器
|
|
|
}
|
|
|
this.initData(); //初始化参数
|
|
|
await this.getRecordHistoryPhoto(); //获取拍照历史记录
|
|
|
await this.getRecordLast(); //获取播放记录
|
|
|
- let playSource = this.activeSection.playSource || 1;
|
|
|
- if (playSource == 2) {
|
|
|
+ let viewSign = this.viewSign || 1;
|
|
|
+ if (viewSign == 2) {
|
|
|
await this.loadPlayer_tencent(); //加载播放内容
|
|
|
} else {
|
|
|
await this.loadPlayer(); //加载播放内容
|
|
|
}
|
|
|
- this[playSource == 2 ? "player_tencent" : "player"].on(
|
|
|
- playSource == 2 ? "loadstart" : "s2j_onPlayerInitOver",
|
|
|
+ this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
+ viewSign == 2 ? "loadstart" : "s2j_onPlayerInitOver",
|
|
|
() => {
|
|
|
- this[playSource == 2 ? "player_tencent" : "player"].on(
|
|
|
- playSource == 2 ? "pause" : "s2j_onVideoPause",
|
|
|
+ this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
+ viewSign == 2 ? "pause" : "s2j_onVideoPause",
|
|
|
this.onVideoPause
|
|
|
); //视频暂停时触发
|
|
|
- this[playSource == 2 ? "player_tencent" : "player"].on(
|
|
|
- playSource == 2 ? "playing" : "s2j_onVideoPlay",
|
|
|
+ this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
+ viewSign == 2 ? "playing" : "s2j_onVideoPlay",
|
|
|
this.onVideoPlay
|
|
|
); //视频播放或由暂停恢复播放时触发
|
|
|
- this[playSource == 2 ? "player_tencent" : "player"].on(
|
|
|
- playSource == 2 ? "ended" : "s2j_onPlayOver",
|
|
|
+ this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
+ viewSign == 2 ? "ended" : "s2j_onPlayOver",
|
|
|
this.onPlayOver
|
|
|
); //当前视频播放完毕时触发
|
|
|
|
|
|
- // this[playSource == 2 ? "player_tencent" : "player"].on(
|
|
|
- // playSource == 2 ? "error" : "s2j_onPlayerError",
|
|
|
+ // this[viewSign == 2 ? "player_tencent" : "player"].on(
|
|
|
+ // viewSign == 2 ? "error" : "s2j_onPlayerError",
|
|
|
// this.onPlayerError
|
|
|
// ); //播放出现错误时触发
|
|
|
- if (playSource != 2) {
|
|
|
+ if (viewSign != 2) {
|
|
|
this.player.on("serverError", this.serverError); //发生业务逻辑错误时触发,比如授权验证失败、域名黑白名单验证不通过等错误。参数返回事件名称和错误代码。
|
|
|
}
|
|
|
}
|
|
@@ -180,7 +180,7 @@ export default {
|
|
|
},
|
|
|
//从头播放
|
|
|
seekVideo0() {
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
this.player_tencent.currentTime(0);
|
|
|
} else {
|
|
|
this.player.j2s_seekVideo(0);
|
|
@@ -219,10 +219,10 @@ export default {
|
|
|
//计算拍照逻辑
|
|
|
photoLogic() {
|
|
|
if (this.photoList.length > 0 || this.activeSection.learning == 1) return; //已从历史拍照数据获得
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
var polyvPlayerContext = this.player_tencent;
|
|
|
var totalVideoTime = polyvPlayerContext.duration();
|
|
|
- var duration = polyvPlayerContext.currentTime();
|
|
|
+ var duration = Number(this.activeSection.videoCurrentTime) || polyvPlayerContext.currentTime() || 0;
|
|
|
} else {
|
|
|
var polyvPlayerContext = this.player;
|
|
|
var totalVideoTime = polyvPlayerContext.j2s_getDuration();
|
|
@@ -332,7 +332,7 @@ export default {
|
|
|
//postTime = true 只提交随机时间 false 提交拍照
|
|
|
postCoursePhotoRecord(postTime = false, photoUrl) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
var currentTime = this.player_tencent.currentTime();
|
|
|
} else {
|
|
|
var currentTime = this.player.j2s_getCurrentTime();
|
|
@@ -428,26 +428,50 @@ export default {
|
|
|
},
|
|
|
//播放视频-腾讯
|
|
|
loadPlayer_tencent() {
|
|
|
- return new Promise(async(resolve) => {
|
|
|
+ return new Promise(async resolve => {
|
|
|
try {
|
|
|
let player_tencent_demo = document.createElement("video");
|
|
|
player_tencent_demo.id = "player-tencent";
|
|
|
document
|
|
|
.getElementById("player")
|
|
|
.insertAdjacentElement("afterend", player_tencent_demo);
|
|
|
- const {data} = await this.$request.vodvidesignid(this.activeSection.recordingUrl)
|
|
|
- console.log(data,'sign')
|
|
|
+ const { data } = await this.$request.vodvidesignid(
|
|
|
+ this.activeSection.recordingUrl
|
|
|
+ );
|
|
|
+
|
|
|
+ const autoPlay = this.goodsData.goodsPlayConfig
|
|
|
+ ? this.goodsData.goodsPlayConfig.autoPlay
|
|
|
+ : true;
|
|
|
+ const isAllowSeek =
|
|
|
+ this.activeSection.learning == 1
|
|
|
+ ? true
|
|
|
+ : this.goodsData.goodsPlayConfig
|
|
|
+ ? this.goodsData.goodsPlayConfig.isAllowSeek == "off"
|
|
|
+ ? true
|
|
|
+ : false
|
|
|
+ : false;
|
|
|
+ const playbackRate =
|
|
|
+ this.activeSection.learning == 1
|
|
|
+ ? true
|
|
|
+ : this.goodsData.goodsPlayConfig
|
|
|
+ ? this.goodsData.goodsPlayConfig.playbackRate
|
|
|
+ : false;
|
|
|
+
|
|
|
this.player_tencent = TCPlayer("player-tencent", {
|
|
|
width: 810,
|
|
|
height: 455,
|
|
|
preload: "auto",
|
|
|
- autoplay: false,
|
|
|
+ autoplay: autoPlay,
|
|
|
+ controlBar: {
|
|
|
+ progressControl: isAllowSeek,
|
|
|
+ playbackRateMenuButton: playbackRate
|
|
|
+ },
|
|
|
// 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
|
|
|
+ psign: data.psign
|
|
|
});
|
|
|
this.$emit("videoScript", this.player_tencent); //抛出播放实例
|
|
|
resolve();
|
|
@@ -458,7 +482,7 @@ export default {
|
|
|
},
|
|
|
//监听器
|
|
|
timeEvent() {
|
|
|
- console.log("监听器");
|
|
|
+ console.log("监听器执行中~");
|
|
|
this.timeEventStatus = true; //双重保障
|
|
|
// 定时提交学习记录
|
|
|
this.submitStudyRecords();
|
|
@@ -478,7 +502,7 @@ export default {
|
|
|
this.failToRegister
|
|
|
)
|
|
|
return;
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
var videoTime = this.player_tencent.currentTime();
|
|
|
} else {
|
|
|
var videoTime = this.player.j2s_getCurrentTime();
|
|
@@ -493,7 +517,7 @@ export default {
|
|
|
this.activeSection.learning != 1
|
|
|
) {
|
|
|
//不存在拍照历史,没有重修过,没有学过,则拍照
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
this.player_tencent.pause(); //暂停
|
|
|
} else {
|
|
|
this.player.j2s_pauseVideo(); //暂停
|
|
@@ -508,7 +532,7 @@ export default {
|
|
|
submitStudyRecords() {
|
|
|
let time = new Date().getTime();
|
|
|
if (time >= this.commitTime) {
|
|
|
- this.postStudyRecord(0,null,null);
|
|
|
+ this.postStudyRecord(0, null, null);
|
|
|
this.commitTime = time + 15000;
|
|
|
}
|
|
|
},
|
|
@@ -550,15 +574,16 @@ export default {
|
|
|
if (this.firstPlay) {
|
|
|
this.firstPlay = false;
|
|
|
//计算拍照逻辑
|
|
|
- // this.photoLogic();
|
|
|
+ this.photoLogic();
|
|
|
//开启上次播放位置提示
|
|
|
if (this.activeSection.videoCurrentTime) {
|
|
|
this.showRecordStatus = true;
|
|
|
+ this.player_tencent.currentTime(Number(this.activeSection.videoCurrentTime) || 0);
|
|
|
this.showRecordSetTimeOut = setTimeout(() => {
|
|
|
this.showRecordStatus = false;
|
|
|
}, 5000);
|
|
|
}
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
this.player_tencent.on("timeupdate", this.timeEvent); //当前视频播放中触发
|
|
|
} else {
|
|
|
this.player.HTML5.video.addEventListener(
|
|
@@ -568,7 +593,7 @@ export default {
|
|
|
}
|
|
|
this.timeEventStatusTimeout = setTimeout(() => {
|
|
|
if (!this.timeEventStatus) {
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
this.player_tencent.pause();
|
|
|
} else {
|
|
|
this.player.j2s_pauseVideo();
|
|
@@ -648,7 +673,7 @@ export default {
|
|
|
this.exitFullscreen();
|
|
|
}
|
|
|
setTimeout(() => {
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
this.player_tencent.pause(); //暂停
|
|
|
} else {
|
|
|
this.player.j2s_pauseVideo(); //暂停
|
|
@@ -688,7 +713,7 @@ export default {
|
|
|
); //提交记录
|
|
|
//恢复播放
|
|
|
if (STATUS) {
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
var polyvPlayerContext = this.player_tencent;
|
|
|
if (polyvPlayerContext && this.openPhotoStatus !== 1) {
|
|
|
polyvPlayerContext.play();
|
|
@@ -730,7 +755,7 @@ export default {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let currentTime = 0;
|
|
|
let PlayDuration = 0;
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
var polyvPlayerContext = this.player_tencent;
|
|
|
if (polyvPlayerContext) {
|
|
|
currentTime = polyvPlayerContext.currentTime(); //当前视频播放时刻
|
|
@@ -783,7 +808,7 @@ export default {
|
|
|
})
|
|
|
.catch(err => {
|
|
|
if (err.code === 600) {
|
|
|
- if (this.activeSection.playSource == 2) {
|
|
|
+ if (this.viewSign == 2) {
|
|
|
polyvPlayerContext.pause();
|
|
|
} else {
|
|
|
polyvPlayerContext.j2s_pauseVideo();
|
|
@@ -827,7 +852,7 @@ export default {
|
|
|
return new Promise(resolve => {
|
|
|
this.$request
|
|
|
.faceCertificationCompareFace({
|
|
|
- urlA:url,
|
|
|
+ urlA: url,
|
|
|
// imageA: url,
|
|
|
orderGoodsId: this.goodsData.orderGoodsId,
|
|
|
gradeId: this.goodsData.gradeId
|