inform ios about earpice mode

This commit is contained in:
Timo
2025-05-19 18:44:48 +02:00
parent 5d6ec19ca0
commit 6d0697cf2f

View File

@@ -36,6 +36,8 @@ import {
} from "../controls"; } from "../controls";
import { useUrlParams } from "../UrlParams"; 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 const EARPIECE_CONFIG_ID = "earpiece-id";
export type DeviceLabel = export type DeviceLabel =
@@ -369,16 +371,12 @@ function useControlledOutput(): MediaDeviceHandle {
const [asEarpice, setAsEarpiece] = useState(false); const [asEarpice, setAsEarpiece] = useState(false);
useEffect(() => { useEffect(() => {
let selectForController = selectedId; // In earpice mode we just sent the EARPIECE_CONFIG_ID to the native code
const earpiece = selectedId === EARPIECE_CONFIG_ID; // 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.
setAsEarpiece(earpiece); if (selectedId) window.controls.onOutputDeviceSelect?.(selectedId);
if (earpiece && physicalDeviceForEarpiceMode !== undefined) setAsEarpiece(selectedId === EARPIECE_CONFIG_ID);
selectForController = physicalDeviceForEarpiceMode.id; }, [selectedId]);
if (selectForController)
window.controls.onOutputDeviceSelect?.(selectForController);
}, [physicalDeviceForEarpiceMode, selectedId]);
return useMemo( return useMemo(
() => ({ () => ({