Commit c2868e6f by wangshuo

播放页学习进度

parent 7e26dc24
......@@ -75,6 +75,7 @@ class Video extends Component {
previousPlaybackRate = 1
currentPlaybackRate = 1
reconnect = true
timeEnough = false
recordSocket
recordTimer
......@@ -381,12 +382,24 @@ class Video extends Component {
})
this.ws.addEventListener('message', e => {
const data = JSON.parse(e.data);
data.code == 4040 && (this.reconnect = false)
data.code == 4040 && (this.reconnect = false);
data.code == 5001 && (this.timeEnough = true);
})
}
sendMessage = message => {
this.ws && this.ws.send(JSON.stringify(message))
let readyState = this.ws.readyState, _this = this;
if(readyState === 1) {
this.ws && this.ws.send(JSON.stringify(message))
}else if(readyState === 3) {
this.ws.close();
this.ws = null;
let reconnect = setTimeout(function() {
clearTimeout(reconnect);
reconnect = null;
_this.ws = new WebSocket(PROCESS_URL);
}, 500);
}
}
//视频结束请求接口
......@@ -407,6 +420,11 @@ class Video extends Component {
console.log('免费课程 拦截');
return;
}
// 时间足够不发送
if(this.timeEnough) {
console.log('5001 时间足够');
return;
}
if(course.is_aist) {
// 返现课程
this.sendMessage({
......@@ -441,6 +459,11 @@ class Video extends Component {
if(Number(sec) === 0) {
return;
}
// 时间足够不发送
if(this.timeEnough) {
console.log('5001 时间足够');
return;
}
let info_type = 'c_watch_time';
if(course.is_aist) {
info_type = 'watch_time';
......@@ -454,7 +477,7 @@ class Video extends Component {
v_course_id: vCourseId,
uid: this.props.user.data.uid,
token: this.token,
platform: 0
platform: 5
})
}
......@@ -501,9 +524,13 @@ class Video extends Component {
this.previousPlaybackRate = this.currentPlaybackRate
})
this.player.on('ended', () => {
console.log('ended');
this.sendWatchTime(this.watchSec, this.currentPlaybackRate)
this.countSchedule(); // 计算进度
this.getShareProgressInfo()
// 返现课程才出现打卡记录
if(this.state.course.is_aist) {
this.getShareProgressInfo()
}
clearInterval(this.timer)
})
this.player.on('seeked', () => {
......@@ -534,7 +561,7 @@ class Video extends Component {
if (index === this.state.activeIndex) {
return
}
console.log('selectVideo');
this.countSchedule(); // 计算进度
this.setState(
......@@ -592,9 +619,15 @@ class Video extends Component {
if (Number(course.course_id) === 0 || course.course_id === '') {
console.log('免费课程 拦截');
}else{
let _this = this;
this.setupWS();
this.setupTimer();
this.countSchedule();
console.log('playSetup');
let scheduleTime = setTimeout(function () {
clearTimeout(scheduleTime);
scheduleTime = null;
_this.countSchedule();
}, 1000);
}
let index = this.getLastVideoIndex(course.last_video_id);
index = index >= 0 ? index : 0;
......
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