Created
April 28, 2022 13:11
-
-
Save mariorcardoso/e651630eb29598f55cd22c94cecb45a4 to your computer and use it in GitHub Desktop.
This file contains 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
export const imagePreview = async ({ | |
videoRef, | |
}: ImagePreviewInput): Promise<MediaStream | undefined> => { | |
try { | |
const videoElem = videoRef.current; | |
if (!videoElem) throw Error("Video HTML element not defined"); | |
videoElem.srcObject = await navigator.mediaDevices.getDisplayMedia(); | |
return videoElem.srcObject; | |
} catch (error) { | |
console.error("imagePreview error: " + error); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment