Skip to content

Instantly share code, notes, and snippets.

@mariorcardoso
Created April 28, 2022 13:11
Show Gist options
  • Save mariorcardoso/e651630eb29598f55cd22c94cecb45a4 to your computer and use it in GitHub Desktop.
Save mariorcardoso/e651630eb29598f55cd22c94cecb45a4 to your computer and use it in GitHub Desktop.
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