liuyu 4 år sedan
förälder
incheckning
8759714134
1 ändrade filer med 12 tillägg och 4 borttagningar
  1. 12 4
      src/layout/live/detailInfo.vue

+ 12 - 4
src/layout/live/detailInfo.vue

@@ -37,12 +37,12 @@
       </el-col>
     </el-row>
     <el-dialog title="摄像头" :visible.sync="shexiangDia" width="30%" :before-close="handleClose">
-      <el-select v-model="cameraId" filterable placeholder="请选择摄像头">
+      <el-select @change="cameraChange" v-model="cameraId" filterable placeholder="请选择摄像头">
         <el-option v-for="item in cameras" :key="item.deviceId" :label="item.label" :value="item.deviceId"> </el-option>
       </el-select>
     </el-dialog>
     <el-dialog title="麦克风" :visible.sync="tianchongDia" width="30%" :before-close="handleClose">
-      <el-select v-model="microphoneId" filterable placeholder="请选择麦克风">
+      <el-select @change="micrChange" v-model="microphoneId" filterable placeholder="请选择麦克风">
         <el-option v-for="item in microphones" :key="item.deviceId" :label="item.label" :value="item.deviceId"> </el-option>
       </el-select>
     </el-dialog>
@@ -119,6 +119,7 @@ export default {
         microphoneId: this.microphoneId,
         userId: this.userId_,
       });
+      this.localStream_.setVideoProfile('480p');
       await this.localStream_.initialize();
       console.log('initialize local stream success');
       // publish the local stream
@@ -138,7 +139,8 @@ export default {
         });
         shareClient.setDefaultMuteRemoteStreams(true);
         await shareClient.join({ roomId: this.name });
-        const localStream = TRTC.createStream({ audio: false, screen: true });
+        const localStream = TRTC.createStream({ audio: true, screen: true });
+        //localStream.setScreenProfile({ width: 200, height: 200, float: 'left', frameRate: 5, bitrate: 1600 /* kbps */ });
         await localStream.initialize();
         console.log('initialize share stream success');
         await shareClient.publish(localStream);
@@ -165,13 +167,19 @@ export default {
             console.log('remove video call success');
             // 关闭摄像头
             videoTrack.stop();
-            this.client_.unpublish(localStream).then(() => {
+            this.client_.unpublish(this.localStream_).then(() => {
               // 取消发布本地流成功
             });
           });
         }
       }
     },
+    async cameraChange() {
+      await this.localStream_.switchDevice('video', this.cameraId);
+    },
+    async micrChange() {
+      await this.localStream_.switchDevice('audio', this.microphoneId);
+    },
     // 选择打开摄像头
     shexiangBtn() {
       this.shexiangDia = true;