Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
how to get exception when no camera in js

There's a web page for mobile and from js I can get access to the camera. One case I need to support is when there's no camera. So last week for such case I was getting exception sth like 'Could not start a video source' and added error handler. Today an upload dialog box is opened Now I'm testing it on pc on chrome but soon want to test it on android as well

  • How to catch edge cases like no camera/no permission/other kind of errors so it'll be working on ios/android devices and desktop
  • I don't want any upload dialog box to be displayed. Is there any solution?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can check if any video devices type available or not using enumerateDevices() function available in navigator.

const cameraAvailable = (devices) => {
    const videoDevice = devices.filter((d) => d.kind === "videoinput");

    if (videoDevice.length > 0) {
      console.log("camera available");
      return true;
    } else {
      console.log("No camera available");
      return false;
    }
  };
  const getMediaDevices = async () => {
    try {
      const devices = await navigator.mediaDevices.enumerateDevices();
      if(cameraAvailable(devices)){
        // handle stuff with camera
      }
    } catch (error) {
      console.log(error);
    }
  };
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!