|
@@ -587,26 +587,27 @@ export class LiveService {
|
|
|
|
|
|
|
|
|
async changeCamera() {
|
|
|
-
|
|
|
+ const oldCameras = await AgoraRTC.getCameras(true);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- await this.localTracks.videoTrack.setDevice({facingMode: this.tools['camera'] ? 'user' : 'environment'})
|
|
|
- this.tools['camera'] = !this.tools['camera'];
|
|
|
+ let newCamers = oldCameras.find(
|
|
|
+ (item: any) => item.deviceId !== this.currentUsedDevice.videoDevice
|
|
|
+ );
|
|
|
+ console.log(newCamers);
|
|
|
+ newCamers &&
|
|
|
+ this.localTracks.videoTrack
|
|
|
+ .setDevice(newCamers.deviceId)
|
|
|
+ .then(() => {
|
|
|
+ this.tools['camera'] = !this.tools['camera'];
|
|
|
+ this.currentUsedDevice.videoDevice = newCamers.deviceId;
|
|
|
+ })
|
|
|
+ .catch((err: any) => {
|
|
|
+ console.log('set device error', err);
|
|
|
+ this.tools['camera'] = !this.tools['camera'];
|
|
|
+ this.currentUsedDevice.videoDevice = newCamers.deviceId;
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
|
|
|
return true;
|
|
|
}
|