From 50ddfebfd4db00fb386c61061477aec8c26f765e Mon Sep 17 00:00:00 2001 From: hyrious Date: Sat, 6 May 2023 12:22:24 +0800 Subject: [PATCH] fix(service-providers): fix device id after creating tracks (#1914) --- .../agora-rtc/agora-rtc-web/src/agora-rtc-web.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts b/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts index 6afa1139d2c..f01f764f8a6 100644 --- a/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts +++ b/service-providers/agora-rtc/agora-rtc-web/src/agora-rtc-web.ts @@ -496,6 +496,12 @@ export class AgoraRTCWeb extends IServiceVideoChat { if (this._pJoiningRoom) { await this._pJoiningRoom; } + + // If there is setCameraID() called during the promises above, + // the actually used camera ID may be different, so correct it here. + if (this._cameraID) { + this.localCameraTrack.setDevice(this._cameraID); + } } return this.localCameraTrack; }); @@ -514,6 +520,12 @@ export class AgoraRTCWeb extends IServiceVideoChat { if (this._pJoiningRoom) { await this._pJoiningRoom; } + + // If there is setMicID() called during the promises above, + // the actually used microphone ID may be different, so correct it here. + if (this._micID) { + this.localMicTrack.setDevice(this._micID); + } } return this.localMicTrack; });