|
@@ -35,6 +35,7 @@ export default {
|
|
|
microphones: [],
|
|
|
localStream_: [], //流
|
|
|
isInit: false,
|
|
|
+ roomNumber: '',
|
|
|
};
|
|
|
},
|
|
|
created() {},
|
|
@@ -60,28 +61,16 @@ export default {
|
|
|
},
|
|
|
async toLook() {
|
|
|
let roomNumber = `98${this.liveInfo.number}89`;
|
|
|
+ this.$set(this, `roomNumber`, roomNumber);
|
|
|
await this.client_.join({ roomId: roomNumber, role: 'anchor' });
|
|
|
- this.joinRoom(roomNumber);
|
|
|
+ this.channel();
|
|
|
+ this.joinRoom();
|
|
|
// 订阅其他用户音视频
|
|
|
this.client_.on('stream-subscribed', event => {
|
|
|
const remoteStream = event.stream;
|
|
|
- console.log(remoteStream);
|
|
|
// 远端流订阅成功,播放远端音视频流
|
|
|
const usertempid_ = remoteStream.getUserId();
|
|
|
remoteStream.play('liveScreen');
|
|
|
- // if (usertempid_) {
|
|
|
- // const usersplit_ = usertempid_.substring(0, 5);
|
|
|
- // if (usersplit_ === 'other') {
|
|
|
- // const id_ = 'othe-video-' + usertempid_;
|
|
|
- // remoteStream.play(id_);
|
|
|
- // } else if (usersplit_ === 'wxxcx') {
|
|
|
- // const id_ = 'look-video-' + usertempid_;
|
|
|
- // remoteStream.play(id_);
|
|
|
- // } else if (usersplit_ === 'meetu') {
|
|
|
- // const id_ = 'look-video-' + usertempid_;
|
|
|
- // remoteStream.play(id_);
|
|
|
- // }
|
|
|
- // }
|
|
|
});
|
|
|
|
|
|
// 监听远端流增加事件
|
|
@@ -92,34 +81,54 @@ export default {
|
|
|
console.error('failed to subscribe remoteStream');
|
|
|
});
|
|
|
});
|
|
|
- this.client_.on('stream-removed', event => {
|
|
|
- const remoteStream = event.stream;
|
|
|
- console.log('stop----');
|
|
|
- const usertempid_ = remoteStream.getUserId();
|
|
|
- if (usertempid_) {
|
|
|
- const usersplit_ = usertempid_.substring(0, 5);
|
|
|
- if (usersplit_ === 'other') {
|
|
|
- this.index_ = this.index_ - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- remoteStream.stop();
|
|
|
- });
|
|
|
- this.client_.on('mute-video', event => {
|
|
|
- const remoteStream = event.stream;
|
|
|
- // 订阅远端音频和视频流
|
|
|
- const usertempid_ = remoteStream.getUserId();
|
|
|
- if (usertempid_) {
|
|
|
- const usersplit_ = usertempid_.substring(0, 4);
|
|
|
- if (usersplit_ === 'othe') {
|
|
|
- this.index_ = this.index_ - 1;
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ // this.client_.on('stream-removed', event => {
|
|
|
+ // const remoteStream = event.stream;
|
|
|
+ // console.log('stop----');
|
|
|
+ // const usertempid_ = remoteStream.getUserId();
|
|
|
+ // if (usertempid_) {
|
|
|
+ // const usersplit_ = usertempid_.substring(0, 5);
|
|
|
+ // if (usersplit_ === 'other') {
|
|
|
+ // this.index_ = this.index_ - 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // remoteStream.stop();
|
|
|
+ // });
|
|
|
+ // this.client_.on('mute-video', event => {
|
|
|
+ // const remoteStream = event.stream;
|
|
|
+ // // 订阅远端音频和视频流
|
|
|
+ // const usertempid_ = remoteStream.getUserId();
|
|
|
+ // if (usertempid_) {
|
|
|
+ // const usersplit_ = usertempid_.substring(0, 4);
|
|
|
+ // if (usersplit_ === 'othe') {
|
|
|
+ // this.index_ = this.index_ - 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
},
|
|
|
async joinRoom(number) {
|
|
|
const { userid, name } = this.user;
|
|
|
this.$emit('count', { userid, name, number });
|
|
|
},
|
|
|
+ // 订阅人数
|
|
|
+ channel() {
|
|
|
+ if (!this.roomNumber) {
|
|
|
+ console.warn('未获取到房间号,无法进行订阅');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$stomp({
|
|
|
+ [`/exchange/liveroom-personcount/${this.roomNumber}`]: this.onMessage,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onMessage(message) {
|
|
|
+ let body = _.get(message, 'body');
|
|
|
+ console.log(body);
|
|
|
+ if (body) {
|
|
|
+ if (body == '消息已查收') return;
|
|
|
+ body = JSON.parse(body);
|
|
|
+ console.log(body);
|
|
|
+ // this.chatList.push(body);
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
liveInfo: {
|