From 6d0697cf2f05653c81b94d7e4a9edc47bb32e24f Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 19 May 2025 18:44:48 +0200 Subject: [PATCH] inform ios about earpice mode --- src/livekit/MediaDevicesContext.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/livekit/MediaDevicesContext.tsx b/src/livekit/MediaDevicesContext.tsx index 165ba6ca..a85b687c 100644 --- a/src/livekit/MediaDevicesContext.tsx +++ b/src/livekit/MediaDevicesContext.tsx @@ -36,6 +36,8 @@ import { } from "../controls"; import { useUrlParams } from "../UrlParams"; +// This hardcoded id is used in EX ios! It can only be changed in coordination with +// the ios swift team. export const EARPIECE_CONFIG_ID = "earpiece-id"; export type DeviceLabel = @@ -369,16 +371,12 @@ function useControlledOutput(): MediaDeviceHandle { const [asEarpice, setAsEarpiece] = useState(false); useEffect(() => { - let selectForController = selectedId; - const earpiece = selectedId === EARPIECE_CONFIG_ID; - - setAsEarpiece(earpiece); - if (earpiece && physicalDeviceForEarpiceMode !== undefined) - selectForController = physicalDeviceForEarpiceMode.id; - - if (selectForController) - window.controls.onOutputDeviceSelect?.(selectForController); - }, [physicalDeviceForEarpiceMode, selectedId]); + // In earpice mode we just sent the EARPIECE_CONFIG_ID to the native code + // This only happens on ios where we use the native picker. + // So this only is needed so that ios can know if the proximity sensor should be used or not. + if (selectedId) window.controls.onOutputDeviceSelect?.(selectedId); + setAsEarpiece(selectedId === EARPIECE_CONFIG_ID); + }, [selectedId]); return useMemo( () => ({