Commit ad554b2e by kyle

播放轨迹

parent adb90dc7
......@@ -12,7 +12,6 @@
</view>
<view class="" style="width: 50rpx;height: 50rpx;padding-right: 20rpx;">
<image class="image" @click="reinvite" src="../../static/fastentry/Slice122.png" mode=""></image>
</view>
<view class="" style="width: 50rpx;height: 50rpx; ">
<image class="image" @click="shareToggle" src="../../static/fastentry/Slice12.png" mode=""></image>
......@@ -22,7 +21,7 @@
<!-- 课程banner图 -->
<!-- v-show="!sliceshare" -->
<view class="courseBannerBox" v-if="!sliceshare">
<video v-if="isRenderVideo" id="myVideo" :src="courseInfo.filePathOss" :initial-time="initialTimev"
<video v-if="isRenderVideo" id="myVideo" :src="courseInfo.filePathOss" :initial-time="viewTime"
object-fit="contain" class="videoBox" :poster="courseInfo.fileFirstImage"
:title="courseInfo.fileTitle" @loadedmetadata="loadedmetadata" @play="playVideo" @pause="pause"
@ended="ended" @timeupdate="timeupdate" style="width: 100vw;height: 320rpx;"></video>
......@@ -32,7 +31,7 @@
<view class="courseTitleContent">
<view class="courseTitle">
<view class="" style="width: 70%;">
<h4>{{courseInfo.fileTitle}}---{{videoPlaybackInfo.viewTime}}---{{initialTimev}}</h4>
<h4>{{courseInfo.fileTitle}}{{viewTime}}</h4>
</view>
<view class="shareF">
<view class="awakenApp" @click="jumpapp()" v-if="coursesharing == 1">
......@@ -141,6 +140,7 @@
},
data() {
return {
isPauseFlag:true,
isRenderVideo: false,
fileId: null,
lecturerId: null,
......@@ -172,7 +172,6 @@
shareCode: null,
sharelogin: false,
startTime: '',
initialTimev:0
};
},
methods: {
......@@ -331,6 +330,7 @@
},
// 课程详情页面
courseDetail() {
console.log('courseDetail')
api.courseDetail({
fileId: this.fileId,
userId: this.coursesharing == '1' ? uni.getStorageSync('h5_userId') : uni.getStorageSync(
......@@ -341,11 +341,12 @@
this.courseInfo = res['data']['data'];
this.lecturerId = res['data']['data']['fileLecturerId'];
this.lecturerQuery();
this.relatedCoursesList();
if (uni.getStorageSync('h5_coursesharing')) {
this.coursesharing = uni.getStorageSync('h5_coursesharing')
this.getshareData()
}
if (this.courseInfo.status === 2) {
if (this.courseInfo.status == 2) {
this.findVideoPlayback();
}else{
this.isRenderVideo = true;
......@@ -374,6 +375,8 @@
return dataHandling.secondsTransferPipe(value)
},
async play(item) {
console.log('play')
// 相关列表点击播放
if (this.courseInfo.status == 1) {
// 不可播放
uni.showToast({
......@@ -382,36 +385,49 @@
duration: 2000
});
} else {
await this.saveVideoPlayback();
this.playbackId = null;
this.fileId = item.fileId;
this.courseInfo.packFileId = item.packFileId;
this.courseDetail()
this.videoContext.pause();
if(this.fileId != item.fileId){
if(!this.isPauseFlag){
await this.saveVideoPlayback();
}
console.log('保存之后执行这里')
// 当点击的课程和当前播放的课程不一致时,执行此方法
uni.showLoading({
title: '加载中'
});
this.playbackId = null;
this.fileId = item.fileId;
this.courseInfo.packFileId = item.packFileId;
this.courseDetail()
}
}
},
saveVideoPlayback() {
// 视频播放轨迹保存
const param = {
id: this.playbackId ? this.playbackId : null,
systemType: 1,
userId: this.userId,
fileId: this.fileId,
packFileId: this.courseInfo.packFileId,
totalTime: Math.floor(this.totalTime),
viewTime: Math.floor(this.viewTime),
playbackStatus: this.viewTime >= this.totalTime ? '2' : '1'
}
console.log('saveVideoPlayback')
return new Promise((resolve,reject)=>{
// 视频播放轨迹保存
const param = {
id: this.playbackId ? this.playbackId : null,
systemType: 1,
userId: this.userId,
fileId: this.fileId,
packFileId: this.courseInfo.packFileId,
totalTime: Math.floor(this.totalTime),
viewTime: Math.floor(this.viewTime),
playbackStatus: this.viewTime >= this.totalTime ? '2' : '1'
}
api.saveVideoPlayback(param).then(res => {
if (res['success']) {
this.playbackId = res['data']['id'];
resolve()
console.log('执行保存了===========',param.viewTime)
console.log('执行了保存成功,入参=======',param)
resolve();
}
})
})
},
findVideoPlayback() {
console.log('findVideoPlayback')
// 查询视频播放最新记录
const param = {
systemType: 1,
......@@ -422,20 +438,30 @@
api.findVideoPlayback(param).then(res => {
if (res['success']) {
this.videoPlaybackInfo = res['data'];
this.initialTimev = this.videoPlaybackInfo.viewTime;
console.log('查询视频播放轨迹结果=====',this.videoPlaybackInfo)
if(this.videoPlaybackInfo.viewTime < this.videoPlaybackInfo.totalTime){
this.viewTime = this.videoPlaybackInfo.viewTime;
this.totalTime = this.videoPlaybackInfo.totalTime;
}else{
this.totalTime = this.viewTime = 0;
}
this.isRenderVideo = true;
this.$forceUpdate();
}else{
this.isRenderVideo = true;
this.totalTime = this.viewTime = 0;
}
// 跳转到指定位置
this.videoContext.seek(this.viewTime);
uni.hideLoading();
})
},
loadedmetadata(e) {
this.totalTime = e.detail.duration;
},
playVideo(e) {
if(this.videoPlaybackInfo.viewTime >= this.videoPlaybackInfo.totalTime){
this.videoPlaybackInfo.viewTime = 0;
console.log('playVideo')
this.isPauseFlag = false;
console.log(this.viewTime,this.totalTime)
if(this.viewTime>=this.totalTime){
this.viewTime = 0;
this.videoContext.seek(this.viewTime);
}
// 开始/继续播放
if (this.courseInfo.status === 2) {
......@@ -448,6 +474,8 @@
}
},
pause(e) {
console.log('pause')
this.isPauseFlag = true;
// 暂停播放
if (this.timer) {
clearInterval(this.timer)
......@@ -460,6 +488,7 @@
}
},
ended(e) {
console.log('ended')
// 播放到末尾
if (this.timer) {
clearInterval(this.timer)
......@@ -542,7 +571,6 @@
let dataForm = uni.getStorageSync('userinfodataForm')
this.realName = dataForm.realName
// this.switchTab(1);
},
onShow() {
this.switchTab(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment