Skip to content

Instantly share code, notes, and snippets.

@butchi
Created August 18, 2021 14:46
Show Gist options
  • Save butchi/573c17d8a8b3b05cebb78853b028e747 to your computer and use it in GitHub Desktop.
Save butchi/573c17d8a8b3b05cebb78853b028e747 to your computer and use it in GitHub Desktop.
ディスプレイのキャプチャを取得するスニペット
videoElm = document.createElement("video");
videoElm.setAttribute('autoplay', true)
document.body.append(videoElm);
navigator.mediaDevices
.getDisplayMedia({ video: true })
.then((mediaStream) => {
const localStream = mediaStream;
videoElm.srcObject = mediaStream;
})
.catch((error) => {
console.log("navigator.getUserMedia error: ", error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment