import React from 'react' import { Button } from 'UI' function ScreenSharing() { const videoRef = React.createRef() function handleSuccess(stream) { // startButton.disabled = true; //videoRef.current?.srcObject = stream; // @ts-ignore window.stream = stream; // make variable available to browser console stream.getVideoTracks()[0].addEventListener('ended', () => { console.log('The user has ended sharing the screen'); }); } function handleError(error) { console.log(`getDisplayMedia error: ${error.name}`, error); } const startScreenSharing = () => { // @ts-ignore navigator.mediaDevices.getDisplayMedia({video: true}) .then(handleSuccess, handleError); } const stopScreenSharing = () => { // @ts-ignore window.stream.stop() console.log('Stop screen sharing') } return (
) } export default ScreenSharing