Skip to content

Instantly share code, notes, and snippets.

@pawansingh00
Created May 3, 2022 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawansingh00/723c9b67940a607d82056dbaa42859b9 to your computer and use it in GitHub Desktop.
Save pawansingh00/723c9b67940a607d82056dbaa42859b9 to your computer and use it in GitHub Desktop.
async startScreenCapture() {
let captureMediaStream = null;
let screen_constraints = {
video: {
cursor: "always",
displaySurface: "monitor"
}
};
try {
captureMediaStream = await navigator.mediaDevices.getDisplayMedia(screen_constraints);
let displaySurface = captureMediaStream.getVideoTracks()[0].getSettings().displaySurface;
if (displaySurface === "monitor") {
// This means User has not shared his Entire Screen
// Take the appropriate action needed, like
alert(`Please share your entire screen.`);
return;
}
} catch (err) {
console.log(err.message, err.code);
}
return captureMediaStream;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment