|
@@ -32,7 +32,7 @@
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="videoBtn">
|
|
|
- <el-button type="success" round @click="liveon()" size="mini"><i class="el-icon-camera-solid"></i></el-button>
|
|
|
+ <el-button :type="typevalue" round @click="liveon()" size="mini"><i class="el-icon-camera-solid"></i></el-button>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="down">
|
|
@@ -43,7 +43,7 @@
|
|
|
聊天
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="submit">
|
|
|
- <el-input v-model="input"></el-input>
|
|
|
+ <el-input v-model="content"></el-input>
|
|
|
<el-button type="primary" size="mini">发送</el-button>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
@@ -83,7 +83,8 @@ export default {
|
|
|
total: 0,
|
|
|
content: '',
|
|
|
activeName: 'first',
|
|
|
- input: '',
|
|
|
+ iscamera: false,
|
|
|
+ typevalue: 'warning',
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -117,7 +118,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onSubmit() {
|
|
|
- console.log(this.sendmemo);
|
|
|
+ console.log(this.content);
|
|
|
},
|
|
|
async initclient() {
|
|
|
this.userId_ = this.user.uid;
|
|
@@ -147,26 +148,44 @@ export default {
|
|
|
const remoteStream = event.stream;
|
|
|
console.log('222' + remoteStream.getType());
|
|
|
// 订阅远端音频和视频流
|
|
|
- this.client_.subscribe(remoteStream, { audio: false, video: true }).catch(e => {
|
|
|
+ this.client_.subscribe(remoteStream, { audio: true, video: true }).catch(e => {
|
|
|
console.error('failed to subscribe remoteStream');
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
async liveon() {
|
|
|
- this.localStream_ = await TRTC.createStream({
|
|
|
- audio: true,
|
|
|
- video: true,
|
|
|
- // cameraId: this.cameraId,
|
|
|
- // microphoneId: this.microphoneId,
|
|
|
- userId: this.userId_,
|
|
|
- });
|
|
|
- this.localStream_.setVideoProfile('480p');
|
|
|
- await this.localStream_.initialize();
|
|
|
- console.log('initialize local stream success');
|
|
|
- // publish the local stream
|
|
|
- await this.client_.publish(this.localStream_);
|
|
|
- this.localStream_.play('look-video-8');
|
|
|
+ if (this.iscamera) {
|
|
|
+ const videoTrack = this.localStream_.getVideoTrack();
|
|
|
+ if (videoTrack) {
|
|
|
+ this.localStream_.removeTrack(videoTrack).then(() => {
|
|
|
+ console.log('remove video call success');
|
|
|
+ // 关闭摄像头
|
|
|
+ videoTrack.stop();
|
|
|
+ this.client_.unpublish(this.localStream_).then(() => {
|
|
|
+ // 取消发布本地流成功
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.iscamera = false;
|
|
|
+ this.typevalue = 'warning';
|
|
|
+ } else {
|
|
|
+ this.iscamera = true;
|
|
|
+ this.typevalue = 'success';
|
|
|
+ this.localStream_ = await TRTC.createStream({
|
|
|
+ audio: true,
|
|
|
+ video: true,
|
|
|
+ // cameraId: this.cameraId,
|
|
|
+ // microphoneId: this.microphoneId,
|
|
|
+ userId: this.userId_,
|
|
|
+ });
|
|
|
+ this.localStream_.setVideoProfile('480p');
|
|
|
+ await this.localStream_.initialize();
|
|
|
+ console.log('initialize local stream success');
|
|
|
+ // publish the local stream
|
|
|
+ await this.client_.publish(this.localStream_);
|
|
|
+ this.localStream_.play('look-video-8');
|
|
|
+ }
|
|
|
},
|
|
|
imgclick(url) {
|
|
|
location.href = url;
|
|
@@ -237,7 +256,7 @@ export default {
|
|
|
}
|
|
|
.submit {
|
|
|
.el-input {
|
|
|
- width: 85%;
|
|
|
+ width: 80%;
|
|
|
}
|
|
|
}
|
|
|
}
|