|
@@ -42,7 +42,6 @@ export default {
|
|
// 初始化
|
|
// 初始化
|
|
async initclient() {
|
|
async initclient() {
|
|
this.userMainId = 'sub-' + this.user.userid;
|
|
this.userMainId = 'sub-' + this.user.userid;
|
|
- console.log(this.userMainId);
|
|
|
|
// const res = await this.gensignFetch({ userid: this.userMainId });
|
|
// const res = await this.gensignFetch({ userid: this.userMainId });
|
|
// if (this.$checkRes(res)) {
|
|
// if (this.$checkRes(res)) {
|
|
this.client_ = await TRTC.createClient({
|
|
this.client_ = await TRTC.createClient({
|
|
@@ -60,15 +59,15 @@ export default {
|
|
this.microphones = await TRTC.getMicrophones();
|
|
this.microphones = await TRTC.getMicrophones();
|
|
},
|
|
},
|
|
async toLook() {
|
|
async toLook() {
|
|
- console.log(`roomid:98${this.liveInfo.number}89`);
|
|
|
|
- await this.client_.join({ roomId: `98${this.liveInfo.number}89`, role: 'anchor' });
|
|
|
|
|
|
+ let roomNumber = `98${this.liveInfo.number}89`;
|
|
|
|
+ await this.client_.join({ roomId: roomNumber, role: 'anchor' });
|
|
|
|
+ this.joinRoom(roomNumber);
|
|
// 订阅其他用户音视频
|
|
// 订阅其他用户音视频
|
|
this.client_.on('stream-subscribed', event => {
|
|
this.client_.on('stream-subscribed', event => {
|
|
const remoteStream = event.stream;
|
|
const remoteStream = event.stream;
|
|
console.log(remoteStream);
|
|
console.log(remoteStream);
|
|
// 远端流订阅成功,播放远端音视频流
|
|
// 远端流订阅成功,播放远端音视频流
|
|
const usertempid_ = remoteStream.getUserId();
|
|
const usertempid_ = remoteStream.getUserId();
|
|
- console.log('111' + remoteStream.getUserId());
|
|
|
|
remoteStream.play('liveScreen');
|
|
remoteStream.play('liveScreen');
|
|
// if (usertempid_) {
|
|
// if (usertempid_) {
|
|
// const usersplit_ = usertempid_.substring(0, 5);
|
|
// const usersplit_ = usertempid_.substring(0, 5);
|
|
@@ -88,7 +87,6 @@ export default {
|
|
// 监听远端流增加事件
|
|
// 监听远端流增加事件
|
|
this.client_.on('stream-added', event => {
|
|
this.client_.on('stream-added', event => {
|
|
const remoteStream = event.stream;
|
|
const remoteStream = event.stream;
|
|
- console.log('222' + remoteStream.getType());
|
|
|
|
// 订阅远端音频和视频流
|
|
// 订阅远端音频和视频流
|
|
this.client_.subscribe(remoteStream, { audio: true, video: true }).catch(e => {
|
|
this.client_.subscribe(remoteStream, { audio: true, video: true }).catch(e => {
|
|
console.error('failed to subscribe remoteStream');
|
|
console.error('failed to subscribe remoteStream');
|
|
@@ -118,13 +116,16 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ async joinRoom(number) {
|
|
|
|
+ const { userid, name } = this.user;
|
|
|
|
+ this.$emit('count', { userid, name, number });
|
|
|
|
+ },
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
liveInfo: {
|
|
liveInfo: {
|
|
immediate: true,
|
|
immediate: true,
|
|
deep: true,
|
|
deep: true,
|
|
handler(val) {
|
|
handler(val) {
|
|
- console.log(val);
|
|
|
|
if (val && val.number && !this.init) {
|
|
if (val && val.number && !this.init) {
|
|
this.initclient();
|
|
this.initclient();
|
|
this.getDevices();
|
|
this.getDevices();
|