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

90
Views
Check primary monitor in JavaScript with navigator.mediaDevices.getUserMedia

I want to capture the main monitor by the browser. I'm trying to do it like this:

navigator.mediaDevices.getDisplayMedia({
      video: {
        displaySurface: 'monitor',
        logicalSurface: true,
        cursor: 'always',
        frameRate: {
            ideal: 20
        }
    }
})

Next, the user chooses which screen he will broadcast. I want to check that the user has selected the main monitor (in case there are several). How i can do this? Thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

By checking displaySurface.


navigator.mediaDevices.getDisplayMedia({
        video: {
            displaySurface: 'monitor',
            logicalSurface: true,
            cursor: 'always',
            frameRate: {
                ideal: 20
            }
        }
    })
    .then((strm) => {
        let displaySurface = strm.getVideoTracks()[0].getSettings().displaySurface;
        console.log(displaySurface);
        if (displaySurface !== 'monitor') {
          // do your stuff...
        }
    })
    .catch((err) => console.error(err));
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!