|
@@ -587,26 +587,27 @@ export class LiveService {
|
|
|
|
|
|
/* 切换摄像头 */
|
|
|
async changeCamera() {
|
|
|
- // const oldCameras = await AgoraRTC.getCameras(true);
|
|
|
+ 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;
|
|
|
- // })
|
|
|
- // .catch((err: any) => {
|
|
|
- // console.log('set device error', err);
|
|
|
- // this.tools['camera'] = !this.tools['camera'];
|
|
|
- // this.currentUsedDevice.videoDevice = newCamers.deviceId;
|
|
|
- // this.alertTips('切换摄像头失败');
|
|
|
- // });
|
|
|
- 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;
|
|
|
+ // this.alertTips('切换摄像头失败');
|
|
|
+ });
|
|
|
+ // await this.localTracks.videoTrack.setDevice({facingMode: this.tools['camera'] ? 'user' : 'environment'})
|
|
|
+ // this.tools['camera'] = !this.tools['camera'];
|
|
|
// this.currentUsedDevice.videoDevice = newCamers.deviceId;
|
|
|
return true;
|
|
|
}
|