Procházet zdrojové kódy

拟修改摄像头

warrior před 1 měsícem
rodič
revize
5e0287efc9
1 změnil soubory, kde provedl 11 přidání a 12 odebrání
  1. 11 12
      projects/live-app/src/services/live.service.ts

+ 11 - 12
projects/live-app/src/services/live.service.ts

@@ -93,7 +93,7 @@ export class LiveService {
     };
     this.timer && clearTimeout(this.timer);
     this.timer_countdown && clearInterval(this.timer_countdown);
-    this.timer_countdown = null
+    this.timer_countdown = null;
     this.options['token'] = '';
     this.options['channel'] = '';
     this.user_published_list = [];
@@ -587,16 +587,14 @@ export class LiveService {
 
   /* 切换摄像头 */
   async changeCamera() {
-    const oldCameras = await AgoraRTC.getCameras(true);
-    console.log('oldCameras:', oldCameras);
-    let newCamers = oldCameras.find(
-      (item: any) => item.deviceId !== this.currentUsedDevice.videoDevice
-    );
-    console.log(newCamers);
-    newCamers &&
-      (await this.localTracks.videoTrack.setDevice({
-        cameraId: newCamers.deviceId,
-      }));
+    // const oldCameras = await AgoraRTC.getCameras(true);
+    // console.log('oldCameras:', oldCameras);
+    // let newCamers = oldCameras.find(
+    //   (item: any) => item.deviceId !== this.currentUsedDevice.videoDevice
+    // );
+    // console.log(newCamers);
+    // newCamers &&
+    //   (await this.localTracks.videoTrack.setDevice(newCamers.deviceId));
     // .then(() => {
     //   this.tools['camera'] = !this.tools['camera'];
     //   this.currentUsedDevice.videoDevice = newCamers.deviceId;
@@ -607,8 +605,9 @@ export class LiveService {
     //   this.currentUsedDevice.videoDevice = newCamers.deviceId;
     //   this.alertTips('切换摄像头失败');
     // });
+    await this.localTracks.videoTrack.setDevice({facingMode: this.tools['camera'] ? 'user' : 'environment'})
     this.tools['camera'] = !this.tools['camera'];
-    this.currentUsedDevice.videoDevice = newCamers.deviceId;
+    // this.currentUsedDevice.videoDevice = newCamers.deviceId;
     return true;
   }
   /* 切换美颜 */