kylemcdonald / voice-in-my-head

Other
4 stars 1 forks source link

add device change notification and send to backend #57

Open kylemcdonald opened 10 months ago

kylemcdonald commented 10 months ago

something like this will help tell us when there is a device change on the iPhones:

if (navigator.mediaDevices && navigator.mediaDevices.ondevicechange !== undefined) {
    navigator.mediaDevices.ondevicechange = function() {
        console.log("devices changed");
        // Optionally enumerate devices to check the current list
        navigator.mediaDevices.enumerateDevices()
            .then((devices) => {
                devices.forEach((device) => {
                    console.log(`${device.kind}: ${device.label}, id = ${device.deviceId}`);
                });
            })
            .catch((err) => {
                console.error("Error enumerating devices: ", err);
            });
    };
} else {
    console.log("mediaDevices or ondevicechange is not supported by this browser.");
}

we should send that to the backend and then log it.

test if this is what happens when inputs_updated is called, and when the airpod goes out of range, and when it is put back in the case.

kylemcdonald commented 9 months ago

i'm logging these partially, but need more work to log it fully since according to this thread safari demands camera access in order to get full device IDs:

https://stackoverflow.com/questions/61629512/safari-13-1-navigator-mediadevices-enumeratedevices-return-only-audio-devices