Skip to content

Commit ab8d599

Browse files
authored
fix: skip default device selection on iOS (livekit#1528)
1 parent 9007458 commit ab8d599

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.changeset/thick-pumas-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
fix: skip default device selection on iOS

src/room/Room.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
19921992
}
19931993
};
19941994

1995-
private handleDeviceChange = async () => {
1995+
/**
1996+
* attempt to select the default devices if the previously selected devices are no longer available after a device change event
1997+
*/
1998+
private async selectDefaultDevices() {
19961999
const previousDevices = DeviceManager.getInstance().previousDevices;
19972000
// check for available devices, but don't request permissions in order to avoid prompts for kinds that haven't been used before
19982001
const availableDevices = await DeviceManager.getInstance().getDevices(undefined, false);
@@ -2055,7 +2058,13 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
20552058
await this.switchActiveDevice(kind, devicesOfKind[0].deviceId);
20562059
}
20572060
}
2061+
}
20582062

2063+
private handleDeviceChange = async () => {
2064+
if (getBrowser()?.os !== 'iOS') {
2065+
// default devices are non deterministic on iOS, so we don't attempt to select them here
2066+
await this.selectDefaultDevices();
2067+
}
20592068
this.emit(RoomEvent.MediaDevicesChanged);
20602069
};
20612070

0 commit comments

Comments
 (0)