Skip to content

Commit f82e3ee

Browse files
authored
fix: set roomOptions after trying switchCamera on track (#851)
The `setVideoInputDevice(...)` method breaks if we set `roomOptions` before, it does not actually switch to the new `deviceId`.
1 parent fb84e27 commit f82e3ee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/src/core/room.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,17 +1102,17 @@ extension RoomHardwareManagementMethods on Room {
11021102
final currentDeviceId =
11031103
engine.roomOptions.defaultCameraCaptureOptions.deviceId;
11041104

1105-
// Always update roomOptions so future tracks use the correct device
1106-
engine.roomOptions = engine.roomOptions.copyWith(
1107-
defaultCameraCaptureOptions: roomOptions.defaultCameraCaptureOptions
1108-
.copyWith(deviceId: device.deviceId),
1109-
);
1110-
11111105
try {
11121106
if (track != null && selectedVideoInputDeviceId != device.deviceId) {
11131107
await track.switchCamera(device.deviceId);
11141108
Hardware.instance.selectedVideoInput = device;
11151109
}
1110+
1111+
// Always update roomOptions so future tracks use the correct device
1112+
engine.roomOptions = engine.roomOptions.copyWith(
1113+
defaultCameraCaptureOptions: roomOptions.defaultCameraCaptureOptions
1114+
.copyWith(deviceId: device.deviceId),
1115+
);
11161116
} catch (e) {
11171117
// if the switching actually fails, reset it to the previous deviceId
11181118
engine.roomOptions = engine.roomOptions.copyWith(

0 commit comments

Comments
 (0)