videoTime
This commit is contained in:
parent
49a375042c
commit
42ef4fb444
|
@ -51,6 +51,14 @@ export function getVideoPlayCode(id) {
|
|||
}
|
||||
|
||||
export function getMyView(id, data) {
|
||||
return request({
|
||||
url: `/vod/video/${id}/myview/`,
|
||||
method: 'get',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function refreshMyView(id, data) {
|
||||
return request({
|
||||
url: `/vod/video/${id}/myview/`,
|
||||
method: 'put',
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</el-header>
|
||||
<el-main style="margin-top: 70px;">
|
||||
<div style="margin:20px 12%;">
|
||||
<div class="content" @click="clicknub">
|
||||
<div class="content">
|
||||
<video
|
||||
:id="tcPlayerId"
|
||||
width="1000"
|
||||
|
@ -39,7 +39,7 @@
|
|||
</el-container>
|
||||
</template>
|
||||
<script>
|
||||
import {getVideo, getMyView, getVideoPlayCode} from "@/api/video";
|
||||
import {getVideo, getMyView,refreshMyView, getVideoPlayCode} from "@/api/video";
|
||||
export default {
|
||||
name: 'TencentPlayer',
|
||||
props: {
|
||||
|
@ -61,11 +61,11 @@
|
|||
description: '',
|
||||
name: '',
|
||||
videoFileid:false,
|
||||
userName:""
|
||||
userName:"",
|
||||
playTimer:null,
|
||||
};
|
||||
},
|
||||
mounted(){
|
||||
//debugger;
|
||||
this.userName = this.$store.state.user.name;
|
||||
if(this.player!==null){
|
||||
this.player.null;
|
||||
|
@ -94,7 +94,6 @@
|
|||
this.getPlayCode(this.videoFileId);
|
||||
this.getVideo();
|
||||
},
|
||||
|
||||
methods: {
|
||||
getVideo() {
|
||||
getVideo(this.id).then((response) => {
|
||||
|
@ -108,8 +107,6 @@
|
|||
let that = this;
|
||||
getVideoPlayCode(id).then(res=>{
|
||||
if(res.data){
|
||||
//debugger;
|
||||
console.log(res.data);
|
||||
that.videoFileid = true;
|
||||
that.videoPsign = res.data.psign;
|
||||
that.initVideo();
|
||||
|
@ -118,48 +115,66 @@
|
|||
},
|
||||
//视频观看次数
|
||||
clicknub() {
|
||||
debugger;
|
||||
getMyView(this.id).then((response) => {});
|
||||
},
|
||||
initVideo() {
|
||||
//debugger;
|
||||
console.log(this.userName);
|
||||
let that = this;
|
||||
let text = "用户:"+that.userName;
|
||||
const playerParm = {
|
||||
fileID: that.videoFileId,
|
||||
appID: that.videoAppId,
|
||||
psign: that.videoPsign,
|
||||
plugins:{
|
||||
DynamicWatermark: {
|
||||
speed: 0.1,
|
||||
content: "用户:"+that.userName
|
||||
getMyView(that.id,{}).then((response) => {
|
||||
debugger;
|
||||
console.log(response.data);
|
||||
let current = response.data.current;
|
||||
let playerParm = {
|
||||
fileID: that.videoFileId,
|
||||
appID: that.videoAppId,
|
||||
psign: that.videoPsign,
|
||||
plugins:{
|
||||
DynamicWatermark: {
|
||||
speed: 0.1,
|
||||
content: "用户:"+that.userName
|
||||
},
|
||||
}
|
||||
};
|
||||
if (!that.player) {
|
||||
that.player = window.TCPlayer(that.tcPlayerId, playerParm);
|
||||
} else {
|
||||
that.player.loadVideoByID(playerParm);
|
||||
that.player.loadVideoByID(that.tcPlayerId);
|
||||
}
|
||||
};
|
||||
/*
|
||||
* plugins: {
|
||||
ContinuePlay: { // 开启续播功能
|
||||
// auto: true, //[可选] 是否在视频播放后自动续播
|
||||
// text:'上次播放至 ', //[可选] 提示文案
|
||||
// btnText: '恢复播放' //[可选] 按钮文案
|
||||
},
|
||||
}
|
||||
* */
|
||||
//debugger;
|
||||
if (!that.player) {
|
||||
that.player = window.TCPlayer(that.tcPlayerId, playerParm);
|
||||
that.player.currentTime(current);
|
||||
//视频播放
|
||||
that.player.on('play', function(error) {
|
||||
// 做一些处理
|
||||
getMyView(that.id).then((response) => {});
|
||||
if(that.playTimer!==null){
|
||||
clearInterval(that.playTimer);
|
||||
that.playTimer = null;
|
||||
}
|
||||
that.playTimer = setInterval(function(){
|
||||
let currentTimeNum = 0;
|
||||
currentTimeNum = that.player.currentTime();
|
||||
console.log(currentTimeNum);
|
||||
refreshMyView(that.id,{current:currentTimeNum}).then((response) => {});
|
||||
},10000)
|
||||
});
|
||||
} else {
|
||||
that.player.loadVideoByID(playerParm);
|
||||
that.player.loadVideoByID(that.tcPlayerId);
|
||||
}
|
||||
//视频暂停
|
||||
that.player.on('pause', function(error) {
|
||||
let currentTimeNum = 0;
|
||||
currentTimeNum = that.player.currentTime();
|
||||
console.log(currentTimeNum);
|
||||
refreshMyView(that.id,{current:currentTimeNum}).then((response) => {});
|
||||
clearInterval(that.playTimer);
|
||||
that.playTimer = null;
|
||||
});
|
||||
//视频观看中
|
||||
that.player.on('playing', function(error) {
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
beforeDestroy () {
|
||||
if(that.playTimer!==null){
|
||||
clearInterval(that.playTimer);
|
||||
that.playTimer = null;
|
||||
}
|
||||
this.player.dispose()
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue