Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't work on 13.4.1 #9

Closed
kasperkamperman opened this issue May 6, 2020 · 3 comments
Closed

doesn't work on 13.4.1 #9

kasperkamperman opened this issue May 6, 2020 · 3 comments

Comments

@kasperkamperman
Copy link
Owner

Because of dependency on DetectRTC.
See this open issue:
muaz-khan/DetectRTC#88

@kasperkamperman
Copy link
Owner Author

I tried to remove the DetectRTC dependency. That worked for iOS and I got a working camera in 13.4.1, however it broke the camera on my Android device...

// this function counts the amount of video inputs
// it replaces DetectRTC that was previously implemented
function deviceCount() {
  return new Promise(function (resolve) {
    if (
      navigator.mediaDevices &&
      navigator.mediaDevices.getUserMedia &&
      navigator.mediaDevices.enumerateDevices
    ) {
      var videoInCount = 0;

      navigator.mediaDevices
        .enumerateDevices()
        .then(function (devices) {
          devices.forEach(function (device) {
            if (device.kind === "video") {
              device.kind = "videoinput";
            }

            if (device.kind === "videoinput") {
              videoInCount++;
            }
          });

          resolve(videoInCount);
        })
        .catch(function (err) {
          console.log(err.name + ": " + err.message);
          resolve(0);
        });
    } else resolve(0);
  });
}

document.addEventListener("DOMContentLoaded", function (event) {
  deviceCount().then(function (deviceCount) {
    if (deviceCount > 0) {
      amountOfCameras = deviceCount;
      initCameraUI();
      initCameraStream();
    } else {
      alert(
        "Mobile camera is not supported by browser, or there is no camera detected/connected"
      );
    }
  });
});

If you want to play around with it and find out why this doesn't work on Android, be my guest.

@kasperkamperman
Copy link
Owner Author

I think I solved the 13.4.1 issue with a new update.

@David-dp-
Copy link

Which browser/UA uses "video" for a device kind? All the ones I've tested use "videoinput".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants