提交 c2ad5604 编写于 作者: haochangdi's avatar haochangdi

优化视频逻辑

上级 b902d2a0
...@@ -279,16 +279,16 @@ class RtcClient { ...@@ -279,16 +279,16 @@ class RtcClient {
console.log(`${event.type} player is ${event.state}`); console.log(`${event.type} player is ${event.state}`);
// 远端流是播放还是暂停状态(显示按钮等画面不同) // 远端流是播放还是暂停状态(显示按钮等画面不同)
if (event.type == 'video' && event.state == 'STOPPED') { if (event.type == 'video' && event.state == 'STOPPED') {
console.log('远端流为停止'); console.log(`${uid}----------远端流为停止`);
this.changeView(id, 'mask', true) this.changeView(uid, 'mask', true)
} }
if (event.type == 'video' && event.state == 'PAUSED') { if (event.type == 'video' && event.state == 'PAUSED') {
console.log('远端流为暂停'); console.log(`${uid}----------远端流为暂停`);
this.changeView(id, 'mask', true) this.changeView(uid, 'mask', true)
} }
if (event.type == 'video' && event.state == 'PLAYING') { if (event.type == 'video' && event.state == 'PLAYING') {
console.log('远端流为播放'); console.log(`${uid}----------远端流为播放`);
this.changeView(id, 'mask', false) this.changeView(uid, 'mask', false)
} }
}); });
...@@ -336,7 +336,7 @@ class RtcClient { ...@@ -336,7 +336,7 @@ class RtcClient {
const remoteStream = evt.stream; const remoteStream = evt.stream;
const id = remoteStream.getId(); const id = remoteStream.getId();
const uid = remoteStream.userId_; const uid = remoteStream.userId_;
console.log('远程流被移除时触发'); console.log(`${uid}------------远程流被移除时触发`);
// 停止播放并删除相应<video>标签 // 停止播放并删除相应<video>标签
remoteStream.stop(); remoteStream.stop();
this.inmembers_.delete(uid) this.inmembers_.delete(uid)
...@@ -402,7 +402,7 @@ class RtcClient { ...@@ -402,7 +402,7 @@ class RtcClient {
remove(userId) { remove(userId) {
for(let i = 0; i < this.viewslist.length; i++) { for(let i = 0; i < this.viewslist.length; i++) {
if (this.viewslist[i] && this.viewslist[i].userId == userId) { if (this.viewslist[i] && this.viewslist[i].userId == userId) {
this.viewslist.splice(i, 1) this.viewslist[i] = null
} }
} }
this.vueInstance.removeMember(userId) this.vueInstance.removeMember(userId)
......
...@@ -374,6 +374,7 @@ export default { ...@@ -374,6 +374,7 @@ export default {
// client离开房间 // client离开房间
leave() { leave() {
this.rtc.leave() this.rtc.leave()
this.clearSession()
this.$router.go(-1) this.$router.go(-1)
}, },
// 结束会话 // 结束会话
...@@ -440,16 +441,17 @@ export default { ...@@ -440,16 +441,17 @@ export default {
clearInterval(this.answerTimeFn) clearInterval(this.answerTimeFn)
clearInterval(this.useTimeFn) clearInterval(this.useTimeFn)
clearInterval(this.loseTimeFn) clearInterval(this.loseTimeFn)
},
// 清除直播时间相关的seession
clearSession() {
sessionStorage.removeItem('TIME_askTime')
sessionStorage.removeItem('TIME_answerTime')
sessionStorage.removeItem('TIME_useTime')
sessionStorage.removeItem('TIME_loseTime')
} }
}, },
beforeDestroy() { beforeDestroy() {
console.log('===========this.askTimeFn========================='); this.clearTime()
console.log(this.askTimeFn);
console.log('====================================');
clearInterval(this.askTimeFn)
clearInterval(this.answerTimeFn)
clearInterval(this.useTimeFn)
clearInterval(this.loseTimeFn)
} }
} }
</script> </script>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册