Using iPhone/Mac Continuity Camera on the web

501 Views Asked by At

How to use iOS and macOS's latest feature of Continuity Camera feature with JavaScript, or how to avoid it from popping up in the process of requesting media devices, i.e. navigator.mediaDevices.getUserMedia({ video: true })? - as it actually breaks this code on Chrome whenever my iPhone is close to the laptop with the error Uncaught (in promise) DOMException: Could not start video source, even after I tried to set chrome://settings/content/camera to the original FaceTime HD Camera - seems Chrome just keeps trying to request iPhone as the webcam.


Update - To avoid Continuity Camera, I use this quick patch to prefer the FaceTime Camera if possible (while it would still be better and cool to be able to use iPhone whenever needed)

let preferredDeviceId = undefined
const availableDevices = await navigator.mediaDevices.enumerateDevices()
if (availableDevices.length > 1)
    for (let d of availableDevices)
        if (d.label.includes('FaceTime'))
            preferredDeviceId = d.deviceId

await navigator.mediaDevices.getUserMedia({
    video: {
        deviceId: preferredDeviceId,
    }
})
0

There are 0 best solutions below