13

I'm using getUserMedia() to capture a camera stream on iOS 11's Safari. When I get the list of cameras using the MediaDevices API, the labels are blank. Is there a way to reliably determine which camera is pointed in which direction?

navigator.mediaDevices.enumerateDevices().then(function(devices) {
    devices.forEach(function(device) {
        if(device.kind === 'videoinput') {
            console.log(device);
            // Labels for both cameras are blank:
            // MediaDeviceInfo { deviceId: "123ABC", groupId: "", kind: "videoinput", label: "" }
        }
    });
});
Luke Dennis
  • 14,212
  • 17
  • 56
  • 69

1 Answers1

0

The docs make it sound like a user may have to grant permissions to give labeled camera data.

It says:

This might produce

videoinput: id = csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8=
audioinput: id = RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM=
audioinput: id = r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=

or if one or more MediaStreams are active or persistent permissions are granted:

videoinput: FaceTime HD Camera (Built-in) 
id=csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8=
audioinput: default (Built-in Microphone)
id=RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM=
audioinput: Built-in Microphone id=r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=

To me this implies that the issue might lie in user permissions.

Nathan
  • 96
  • 7