Created
August 18, 2021 14:46
-
-
Save butchi/573c17d8a8b3b05cebb78853b028e747 to your computer and use it in GitHub Desktop.
ディスプレイのキャプチャを取得するスニペット
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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