|
@@ -1,250 +1,359 @@
|
|
-const app = require('../../utils/util.js');
|
|
|
|
|
|
+// const app = require('../../utils/util.js');
|
|
const tools = require('../../utils/tools.js');
|
|
const tools = require('../../utils/tools.js');
|
|
|
|
+const getusersig = require('../../utils/getUserSig.js');
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
- url: '',
|
|
|
|
- title: '',
|
|
|
|
- message: '',
|
|
|
|
- playTimes: 0,
|
|
|
|
- id: 0,
|
|
|
|
- socketOpen: false,
|
|
|
|
- chatContent: [],
|
|
|
|
- inputValue: '',
|
|
|
|
- bottom: "",
|
|
|
|
- pushUrl: '',
|
|
|
|
- videoContext: '',
|
|
|
|
- fullScreenFlag: false,
|
|
|
|
- livectx: "",
|
|
|
|
- spfx: "vertical",
|
|
|
|
- spfx1: "vertical",
|
|
|
|
- isHands: false,
|
|
|
|
- timeoutObj: null,
|
|
|
|
- _timeout: 5000,
|
|
|
|
- isCloseStatus: false
|
|
|
|
|
|
+ // url: '',
|
|
|
|
+ // title: '',
|
|
|
|
+ // message: '',
|
|
|
|
+ // playTimes: 0,
|
|
|
|
+ rtcConfig: {
|
|
|
|
+ sdkAppID: '1400398825', // 必要参数 开通实时音视频服务创建应用后分配的 sdkAppID
|
|
|
|
+ userID: '', // 必要参数 用户 ID 可以由您的帐号系统指定
|
|
|
|
+ userSig: '', // 必要参数 身份签名,相当于登录密码的作用
|
|
|
|
+ template: 'grid', // 必要参数 组件模版,支持的值 1v1 grid custom ,注意:不支持动态修改, iOS 不支持 pusher 动态渲染
|
|
|
|
+ },
|
|
|
|
+ // socketOpen: false,
|
|
|
|
+ // chatContent: [],
|
|
|
|
+ // inputValue: '',
|
|
|
|
+ // bottom: "",
|
|
|
|
+ // pushUrl: '',
|
|
|
|
+ // videoContext: '',
|
|
|
|
+ // fullScreenFlag: false,
|
|
|
|
+ // livectx: "",
|
|
|
|
+ // spfx: "vertical",
|
|
|
|
+ // spfx1: "vertical",
|
|
|
|
+ // isHands: false,
|
|
|
|
+ // timeoutObj: null,
|
|
|
|
+ // _timeout: 5000,
|
|
|
|
+ // isCloseStatus: false
|
|
},
|
|
},
|
|
- statechange: function (e) {
|
|
|
|
- console.log(e)
|
|
|
|
|
|
+
|
|
|
|
+ // statechange: function (e) {
|
|
|
|
+ // console.log(e)
|
|
|
|
+ // },
|
|
|
|
+ // scrollToTop() {
|
|
|
|
+ // this.setAction({
|
|
|
|
+ // scrollTop: 0
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // onReady: function () {},
|
|
|
|
+ // bindKeyInput: function (e) {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // inputValue: e.detail.value
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // hands() {
|
|
|
|
+ // console.log("我点击举手了")
|
|
|
|
+ // this.sendSocketMessage("put up hands")
|
|
|
|
+ // },
|
|
|
|
+ // submit: function () {
|
|
|
|
+ // let input_val = this.data.inputValue;
|
|
|
|
+ // this.sendSocketMessage(input_val)
|
|
|
|
+ // this.setData({
|
|
|
|
+ // inputValue: ''
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // fullScreen: function () {
|
|
|
|
+ // let fullScreenFlag = this.data.fullScreenFlag;
|
|
|
|
+ // if (fullScreenFlag) {
|
|
|
|
+ // fullScreenFlag = false;
|
|
|
|
+ // } else {
|
|
|
|
+ // fullScreenFlag = true;
|
|
|
|
+ // }
|
|
|
|
+ // if (fullScreenFlag) {
|
|
|
|
+ // //全屏
|
|
|
|
+ // this.data.livectx.requestFullScreen({
|
|
|
|
+ // success: () => {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // fullScreenFlag: fullScreenFlag,
|
|
|
|
+ // spfx: "horizontal",
|
|
|
|
+ // spfx1: "horizontal"
|
|
|
|
+ // });
|
|
|
|
+ // if (this.data.isHands == true) {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // isHands: false
|
|
|
|
+ // })
|
|
|
|
+ // this.setData({
|
|
|
|
+ // isHands: true
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // console.log('我要全屏执行了');
|
|
|
|
+ // },
|
|
|
|
+ // fail: () => {
|
|
|
|
+ // console.log('我要全屏执行失败了');
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // } else {
|
|
|
|
+ // //缩小
|
|
|
|
+ // this.data.livectx.exitFullScreen({
|
|
|
|
+ // success: () => {
|
|
|
|
+ // console.log('fullscreen success');
|
|
|
|
+ // this.setData({
|
|
|
|
+ // fullScreenFlag: fullScreenFlag,
|
|
|
|
+ // spfx: "vertical",
|
|
|
|
+ // spfx1: "vertical"
|
|
|
|
+ // });
|
|
|
|
+ // },
|
|
|
|
+ // fail: () => {
|
|
|
|
+ // console.log('exit fullscreen success');
|
|
|
|
+ // }
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
|
|
+ // getZbArr(sessionKey) {
|
|
|
|
+ // wx.request({
|
|
|
|
+ // url: app.globalData.publicUrl + '/wx/course/selectLiveByCourseId',
|
|
|
|
+ // method: "post",
|
|
|
|
+ // data: {
|
|
|
|
+ // sessionKey: sessionKey,
|
|
|
|
+ // courseId: this.data.id
|
|
|
|
+ // },
|
|
|
|
+ // success: (e) => {
|
|
|
|
+ // console.log(e, "11111111111111111")
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // socketConnect(sessionKey) {
|
|
|
|
+ // let newSessionkey = encodeURIComponent(sessionKey);
|
|
|
|
+ // wx.connectSocket({
|
|
|
|
+ // url: app.globalData.publicSocketUrl + '/live/socket?sessionkey=' + newSessionkey + "&courseId=" + this.data.id
|
|
|
|
+ // })
|
|
|
|
+ // wx.onSocketOpen(() => {
|
|
|
|
+ // console.log("我连上啦")
|
|
|
|
+ // this.setData({
|
|
|
|
+ // socketOpen: true
|
|
|
|
+ // })
|
|
|
|
+ // this.setData({
|
|
|
|
+ // timeoutObj: setInterval(() => {
|
|
|
|
+ // this.startHeart(sessionKey)
|
|
|
|
+ // }, this.data._timeout)
|
|
|
|
+ // })
|
|
|
|
+ // })
|
|
|
|
+ // wx.onSocketError(function () {
|
|
|
|
+ // console.log("我连接出错了")
|
|
|
|
+ // })
|
|
|
|
+ // wx.onSocketClose(function () {
|
|
|
|
+ // console.log("我关了")
|
|
|
|
+ // })
|
|
|
|
+ // wx.onSocketMessage((data) => {
|
|
|
|
+ // console.log(data, "2222222222222")
|
|
|
|
+ // let res = JSON.parse(data.data);
|
|
|
|
+ // if (res.msg == "HeartBeat") {
|
|
|
|
+ // return false;
|
|
|
|
+ // }
|
|
|
|
+ // if (res.messageType == "message" || res.messageType == "system") {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // chatContent: this.data.chatContent.concat(res),
|
|
|
|
+ // bottom: 'scrollBottom'
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // if (res.msg == "socketLiveEnd") {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // url: "",
|
|
|
|
+ // })
|
|
|
|
+ // if (this.data.socketOpen) {
|
|
|
|
+ // wx.closeSocket()
|
|
|
|
+ // }
|
|
|
|
+ // this.data.videoContext.stop()
|
|
|
|
+ // wx.showModal({
|
|
|
|
+ // showCancel: false,
|
|
|
|
+ // content: "直播结束了",
|
|
|
|
+ // success(res) {
|
|
|
|
+ // if (res.confirm) {
|
|
|
|
+ // wx.switchTab({
|
|
|
|
+ // url: '../index/index'
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // if (res.messageType == "studentPushStream") {
|
|
|
|
+ // console.log(res, "我收到了举手的推流")
|
|
|
|
+ // this.data.videoContext.start();
|
|
|
|
+ // this.setData({
|
|
|
|
+ // isHands: true,
|
|
|
|
+ // pushUrl: res.pushUrl
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // if (res.messageType == "stopStudentPushStream") {
|
|
|
|
+ // console.log(res.pushUrl, "不推了")
|
|
|
|
+ // this.data.videoContext.stop()
|
|
|
|
+ // this.setData({
|
|
|
|
+ // isHands: false,
|
|
|
|
+ // pushUrl: ""
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // // 发送消息
|
|
|
|
+ // sendSocketMessage(msg) {
|
|
|
|
+ // if (this.data.socketOpen) {
|
|
|
|
+ // wx.sendSocketMessage({
|
|
|
|
+ // data: msg
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
|
|
+ // // 心跳
|
|
|
|
+ // startHeart(sessionKey) {
|
|
|
|
+ // wx.sendSocketMessage({
|
|
|
|
+ // data: "HeartBeat",
|
|
|
|
+ // success: (res) => {
|
|
|
|
+ // console.log(res, "发送心跳成功")
|
|
|
|
+ // },
|
|
|
|
+ // fail: (err) => {
|
|
|
|
+ // console.log(err, "发送心跳失败")
|
|
|
|
+ // if (this.data.isCloseStatus == false) {
|
|
|
|
+ // wx.closeSocket();
|
|
|
|
+ // clearInterval(this.data.timeoutObj);
|
|
|
|
+ // this.socketConnect(sessionKey);
|
|
|
|
+ // } else {
|
|
|
|
+ // clearInterval(this.data.timeoutObj);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // async onShow() {
|
|
|
|
+ // const sessionKey = await tools.checkSessionAndLogin();
|
|
|
|
+ // this.socketConnect(sessionKey);
|
|
|
|
+ // },
|
|
|
|
+ // onHide() {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // isCloseStatus: true
|
|
|
|
+ // })
|
|
|
|
+ // if (this.data.socketOpen) {
|
|
|
|
+ // wx.closeSocket()
|
|
|
|
+ // }
|
|
|
|
+ // clearInterval(this.data.timeoutObj);
|
|
|
|
+ // this.data.videoContext.stop()
|
|
|
|
+ // },
|
|
|
|
+ // onUnload() {
|
|
|
|
+ // this.setData({
|
|
|
|
+ // isCloseStatus: true
|
|
|
|
+ // })
|
|
|
|
+ // if (this.data.socketOpen) {
|
|
|
|
+ // wx.closeSocket()
|
|
|
|
+ // }
|
|
|
|
+ // clearInterval(this.data.timeoutObj);
|
|
|
|
+ // this.data.videoContext.stop()
|
|
|
|
+ // },
|
|
|
|
+ startPushMy() {
|
|
|
|
+ this.trtcRoomContext.publishLocalVideo();
|
|
|
|
+ this.trtcRoomContext.publishLocalAudio();
|
|
},
|
|
},
|
|
- scrollToTop() {
|
|
|
|
- this.setAction({
|
|
|
|
- scrollTop: 0
|
|
|
|
- })
|
|
|
|
|
|
+ stopPushMy(trtcRoomContext) {
|
|
|
|
+ trtcRoomContext.unpublishLocalVideo();
|
|
|
|
+ trtcRoomContext.unpublishLocalAudio();
|
|
},
|
|
},
|
|
- onReady: function () {},
|
|
|
|
- bindKeyInput: function (e) {
|
|
|
|
- this.setData({
|
|
|
|
- inputValue: e.detail.value
|
|
|
|
|
|
+ bindTRTCRoomEvent: function () {
|
|
|
|
+ const TRTC_EVENT = this.trtcRoomContext.EVENT
|
|
|
|
+ this.trtcRoomContext.on(TRTC_EVENT.LOCAL_JOIN, (event) => {
|
|
|
|
+ console.log('* room LOCAL_JOIN', event)
|
|
})
|
|
})
|
|
- },
|
|
|
|
- hands() {
|
|
|
|
- console.log("我点击举手了")
|
|
|
|
- this.sendSocketMessage("put up hands")
|
|
|
|
- },
|
|
|
|
- submit: function () {
|
|
|
|
- let input_val = this.data.inputValue;
|
|
|
|
- this.sendSocketMessage(input_val)
|
|
|
|
- this.setData({
|
|
|
|
- inputValue: ''
|
|
|
|
|
|
+ this.trtcRoomContext.on(TRTC_EVENT.LOCAL_LEAVE, (event) => {
|
|
|
|
+ console.log('* room LOCAL_LEAVE', event)
|
|
})
|
|
})
|
|
- },
|
|
|
|
- fullScreen: function() {
|
|
|
|
- let fullScreenFlag = this.data.fullScreenFlag;
|
|
|
|
- if (fullScreenFlag) {
|
|
|
|
- fullScreenFlag = false;
|
|
|
|
- } else {
|
|
|
|
- fullScreenFlag = true;
|
|
|
|
- }
|
|
|
|
- if (fullScreenFlag) {
|
|
|
|
- //全屏
|
|
|
|
- this.data.livectx.requestFullScreen({
|
|
|
|
- success: () => {
|
|
|
|
- this.setData({
|
|
|
|
- fullScreenFlag: fullScreenFlag,
|
|
|
|
- spfx: "horizontal",
|
|
|
|
- spfx1: "horizontal"
|
|
|
|
- });
|
|
|
|
- if (this.data.isHands == true) {
|
|
|
|
- this.setData({
|
|
|
|
- isHands: false
|
|
|
|
- })
|
|
|
|
- this.setData({
|
|
|
|
- isHands: true
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- console.log('我要全屏执行了');
|
|
|
|
- },
|
|
|
|
- fail: () => {
|
|
|
|
- console.log('我要全屏执行失败了');
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- //缩小
|
|
|
|
- this.data.livectx.exitFullScreen({
|
|
|
|
- success: () => {
|
|
|
|
- console.log('fullscreen success');
|
|
|
|
- this.setData({
|
|
|
|
- fullScreenFlag: fullScreenFlag,
|
|
|
|
- spfx: "vertical",
|
|
|
|
- spfx1: "vertical"
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- fail: () => {
|
|
|
|
- console.log('exit fullscreen success');
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- getZbArr(sessionKey) {
|
|
|
|
- wx.request({
|
|
|
|
- url: app.globalData.publicUrl + '/wx/course/selectLiveByCourseId',
|
|
|
|
- method: "post",
|
|
|
|
- data: {
|
|
|
|
- sessionKey: sessionKey,
|
|
|
|
- courseId: this.data.id
|
|
|
|
- },
|
|
|
|
- success: (e) => {
|
|
|
|
- console.log(e, "11111111111111111")
|
|
|
|
- this.setData({
|
|
|
|
- url: e.data.pullUrl.flvUrl,
|
|
|
|
- // url: e.data.pullUrl.rtmpUrl,
|
|
|
|
- title: e.data.course.courseName,
|
|
|
|
- message: e.data.course.courseInfo,
|
|
|
|
- playTimes: e.data.course.playTimes
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ this.trtcRoomContext.on(TRTC_EVENT.ERROR, (event) => {
|
|
|
|
+ console.log('* room ERROR', event)
|
|
})
|
|
})
|
|
- },
|
|
|
|
- socketConnect(sessionKey) {
|
|
|
|
- let newSessionkey = encodeURIComponent(sessionKey);
|
|
|
|
- wx.connectSocket({
|
|
|
|
- url: app.globalData.publicSocketUrl + '/live/socket?sessionkey=' + newSessionkey + "&courseId=" + this.data.id
|
|
|
|
|
|
+ // 远端用户进入房间
|
|
|
|
+ this.trtcRoomContext.on(TRTC_EVENT.REMOTE_USER_JOIN, (event) => {
|
|
|
|
+ console.log('远端用户进入房间')
|
|
})
|
|
})
|
|
- wx.onSocketOpen(() => {
|
|
|
|
- console.log("我连上啦")
|
|
|
|
- this.setData({
|
|
|
|
- socketOpen: true
|
|
|
|
- })
|
|
|
|
- this.setData({
|
|
|
|
- timeoutObj: setInterval( ()=> {
|
|
|
|
- this.startHeart(sessionKey)
|
|
|
|
- }, this.data._timeout)
|
|
|
|
|
|
+ // 远端用户退出
|
|
|
|
+ this.trtcRoomContext.on(TRTC_EVENT.REMOTE_USER_LEAVE, (event) => {
|
|
|
|
+ console.log('远端用户退出', event, this.trtcRoomContext.getRemoteUserList())
|
|
|
|
+ const userList = this.trtcRoomContext.getRemoteUserList()
|
|
|
|
+ this.handleOnUserList(userList).then(() => {
|
|
|
|
+ console.log(this.data.userList)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
- wx.onSocketError(function () {
|
|
|
|
- console.log("我连接出错了")
|
|
|
|
- })
|
|
|
|
- wx.onSocketClose(function () {
|
|
|
|
- console.log("我关了")
|
|
|
|
- })
|
|
|
|
- wx.onSocketMessage((data) => {
|
|
|
|
- console.log(data, "2222222222222")
|
|
|
|
- let res = JSON.parse(data.data);
|
|
|
|
- if (res.msg == "HeartBeat") {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (res.messageType == "message" || res.messageType == "system") {
|
|
|
|
- this.setData({
|
|
|
|
- chatContent: this.data.chatContent.concat(res),
|
|
|
|
- bottom: 'scrollBottom'
|
|
|
|
|
|
+ // 远端用户推送音频
|
|
|
|
+ this.trtcRoomContext.on(TRTC_EVENT.REMOTE_AUDIO_ADD, (event) => {
|
|
|
|
+ if (this.data.userList.length < 6) {
|
|
|
|
+ // 订阅音频
|
|
|
|
+ const data = event.data
|
|
|
|
+ // 如果不订阅就不会自动播放音频
|
|
|
|
+ const userList = this.trtcRoomContext.getRemoteUserList()
|
|
|
|
+ this.handleOnUserList(userList).then(() => {
|
|
|
|
+ console.log(this.data.userList)
|
|
})
|
|
})
|
|
- }
|
|
|
|
- if (res.msg == "socketLiveEnd") {
|
|
|
|
- this.setData({
|
|
|
|
- url: "",
|
|
|
|
- })
|
|
|
|
- if (this.data.socketOpen) {
|
|
|
|
- wx.closeSocket()
|
|
|
|
- }
|
|
|
|
- this.data.videoContext.stop()
|
|
|
|
- wx.showModal({
|
|
|
|
- showCancel: false,
|
|
|
|
- content: "直播结束了",
|
|
|
|
- success(res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- wx.switchTab({
|
|
|
|
- url: '../index/index'
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- if (res.messageType == "studentPushStream") {
|
|
|
|
- console.log(res, "我收到了举手的推流")
|
|
|
|
- this.data.videoContext.start();
|
|
|
|
- this.setData({
|
|
|
|
- isHands: true,
|
|
|
|
- pushUrl: res.pushUrl
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- if (res.messageType == "stopStudentPushStream") {
|
|
|
|
- console.log(res.pushUrl, "不推了")
|
|
|
|
- this.data.videoContext.stop()
|
|
|
|
- this.setData({
|
|
|
|
- isHands: false,
|
|
|
|
- pushUrl: ""
|
|
|
|
|
|
+ console.log('远端用户推送音频', event, this.trtcRoomContext.getRemoteUserList())
|
|
|
|
+ this.trtcRoomContext.subscribeRemoteAudio({
|
|
|
|
+ userID: data.userID
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
- },
|
|
|
|
- // 发送消息
|
|
|
|
- sendSocketMessage(msg) {
|
|
|
|
- if (this.data.socketOpen) {
|
|
|
|
- wx.sendSocketMessage({
|
|
|
|
- data: msg
|
|
|
|
|
|
+ // 远端用户取消推送音频
|
|
|
|
+ this.trtcRoomContext.on(TRTC_EVENT.REMOTE_AUDIO_REMOVE, (event) => {
|
|
|
|
+ console.log('远端用户取消推送音频', event, this.trtcRoomContext.getRemoteUserList())
|
|
|
|
+ const userList = this.trtcRoomContext.getRemoteUserList()
|
|
|
|
+ this.handleOnUserList(userList).then(() => {
|
|
|
|
+ console.log(this.data.userList)
|
|
})
|
|
})
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 心跳
|
|
|
|
- startHeart(sessionKey) {
|
|
|
|
- wx.sendSocketMessage({
|
|
|
|
- data: "HeartBeat",
|
|
|
|
- success: (res) => {
|
|
|
|
- console.log(res, "发送心跳成功")
|
|
|
|
- },
|
|
|
|
- fail: (err) => {
|
|
|
|
- console.log(err, "发送心跳失败")
|
|
|
|
- if (this.data.isCloseStatus == false) {
|
|
|
|
- wx.closeSocket();
|
|
|
|
- clearInterval(this.data.timeoutObj);
|
|
|
|
- this.socketConnect(sessionKey);
|
|
|
|
- } else {
|
|
|
|
- clearInterval(this.data.timeoutObj);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- async onShow() {
|
|
|
|
- const sessionKey = await tools.checkSessionAndLogin();
|
|
|
|
- this.socketConnect(sessionKey);
|
|
|
|
- },
|
|
|
|
- onHide() {
|
|
|
|
- this.setData({
|
|
|
|
- isCloseStatus: true
|
|
|
|
|
|
+ // handleOnUserList: function (userList) {
|
|
|
|
+ // return new Promise((resolve, reject) => {
|
|
|
|
+ // const newUserList = []
|
|
|
|
+ // let index = 0
|
|
|
|
+ // const oldUserList = this.data.userList
|
|
|
|
+ // userList.forEach((item) => {
|
|
|
|
+ // if (item.hasMainAudio) {
|
|
|
|
+ // const user = this.judgeWhetherExist({
|
|
|
|
+ // userID: item.userID,
|
|
|
|
+ // streamType: 'main'
|
|
|
|
+ // }, oldUserList)
|
|
|
|
+ // index += 1
|
|
|
|
+ // if (user) {
|
|
|
|
+ // // 已存在
|
|
|
|
+ // newUserList.push(Object.assign(user, {
|
|
|
|
+ // index: index
|
|
|
|
+ // }))
|
|
|
|
+ // } else {
|
|
|
|
+ // newUserList.push({
|
|
|
|
+ // userID: item.userID,
|
|
|
|
+ // streamType: 'main',
|
|
|
|
+ // index: index,
|
|
|
|
+ // hasMainAudio: item.hasMainAudio,
|
|
|
|
+ // volume: 0,
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // this.setData({
|
|
|
|
+ // userList: newUserList,
|
|
|
|
+ // }, () => {
|
|
|
|
+ // console.log('handleOnUserList newUserList', newUserList)
|
|
|
|
+ // resolve()
|
|
|
|
+ // })
|
|
|
|
+ // })
|
|
|
|
+ // },
|
|
|
|
+ // judgeWhetherExist: function(target, userList) {
|
|
|
|
+ // userList.forEach( (item) => {
|
|
|
|
+ // if (target.userID === item.userID && target.streamType === item.streamType) {
|
|
|
|
+ // return item
|
|
|
|
+ // }
|
|
|
|
+ // })
|
|
|
|
+ // return false
|
|
|
|
+ // },
|
|
|
|
+ async onLoad() {
|
|
|
|
+ wx.setKeepScreenOn({
|
|
|
|
+ keepScreenOn: true,
|
|
})
|
|
})
|
|
- if (this.data.socketOpen) {
|
|
|
|
- wx.closeSocket()
|
|
|
|
- }
|
|
|
|
- clearInterval(this.data.timeoutObj);
|
|
|
|
- this.data.videoContext.stop()
|
|
|
|
- },
|
|
|
|
- onUnload() {
|
|
|
|
|
|
+ const sig = await getusersig.genTestUserSig("12") //学生id
|
|
|
|
+ console.log(sig, "我是sig")
|
|
|
|
+ let userSig = 'rtcConfig.userSig';
|
|
|
|
+ let userID = 'rtcConfig.userID';
|
|
this.setData({
|
|
this.setData({
|
|
- isCloseStatus: true
|
|
|
|
|
|
+ [userSig]: sig.userSig,
|
|
|
|
+ [userID]: "12", //学生id
|
|
|
|
+ // trtcRoomContext: this.selectComponent('#trtcroom')
|
|
})
|
|
})
|
|
- if (this.data.socketOpen) {
|
|
|
|
- wx.closeSocket()
|
|
|
|
- }
|
|
|
|
- clearInterval(this.data.timeoutObj);
|
|
|
|
- this.data.videoContext.stop()
|
|
|
|
- },
|
|
|
|
- async onLoad(options) {
|
|
|
|
- this.setData({
|
|
|
|
- id: options.id,
|
|
|
|
- videoContext: wx.createLivePusherContext("video-livePusher"),
|
|
|
|
- livectx: wx.createLivePlayerContext('livectx')
|
|
|
|
|
|
+ this.trtcRoomContext = this.selectComponent('#trtcroom')
|
|
|
|
+ this.bindTRTCRoomEvent()
|
|
|
|
+ this.trtcRoomContext.enterRoom({
|
|
|
|
+ roomID: 9 //课程id
|
|
})
|
|
})
|
|
- const sessionKey = await tools.checkSessionAndLogin();
|
|
|
|
- this.getZbArr(sessionKey);
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
})
|
|
})
|