liuyu 4 anos atrás
pai
commit
4ef0b559f5
1 arquivos alterados com 19 adições e 37 exclusões
  1. 19 37
      src/views/live/roomDetail.vue

+ 19 - 37
src/views/live/roomDetail.vue

@@ -419,43 +419,25 @@ export default {
       this.othedivshow = true;
       this.oheight = '270px';
       this.otheheight = '70px';
-      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(() => {
-              // 取消发布本地流成功
-              if (this.index_ > 0) {
-                this.index_ = this.index_ - 1;
-              }
-            });
-          });
-        }
-        this.iscamera = false;
-      } else {
-        this.iscamera = true;
-        const _userid = 'meetu-' + this.userId_;
-        this.localStream_ = await TRTC.createStream({
-          audio: true,
-          video: true,
-          // cameraId: this.cameraId,
-          // microphoneId: this.microphoneId,
-          userId: _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.index_ = this.index_ + 1;
-        if (this.index_ < 6) {
-          const id_ = 'othe-video-' + this.index_;
-          console.log(id_);
-          this.localStream_.play(id_);
-        }
+      this.iscamera = true;
+      const _userid = 'meetu-' + this.userId_;
+      this.localStream_ = await TRTC.createStream({
+        audio: true,
+        video: true,
+        // cameraId: this.cameraId,
+        // microphoneId: this.microphoneId,
+        userId: _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.index_ = this.index_ + 1;
+      if (this.index_ < 6) {
+        const id_ = 'othe-video-' + this.index_;
+        console.log(id_);
+        this.localStream_.play(id_);
       }
     },
     async questSearch() {