2022-11-13 17:11:09 -06:00
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
import ScreenShare from '@mui/icons-material/ScreenShare'
|
|
|
|
import StopScreenShare from '@mui/icons-material/StopScreenShare'
|
|
|
|
import Fab from '@mui/material/Fab'
|
|
|
|
import Tooltip from '@mui/material/Tooltip'
|
|
|
|
|
|
|
|
import { PeerRoom } from 'services/PeerRoom/PeerRoom'
|
|
|
|
|
|
|
|
import { useRoomScreenShare } from './useRoomScreenShare'
|
|
|
|
|
2022-11-24 00:16:34 -06:00
|
|
|
export interface RoomFileUploadControlsProps {
|
2022-11-13 17:11:09 -06:00
|
|
|
peerRoom: PeerRoom
|
|
|
|
}
|
|
|
|
|
2022-11-24 00:16:34 -06:00
|
|
|
export function RoomScreenShareControls({
|
|
|
|
peerRoom,
|
|
|
|
}: RoomFileUploadControlsProps) {
|
2022-11-13 17:11:09 -06:00
|
|
|
const { isSharingScreen, handleScreenShareStart, handleScreenShareStop } =
|
|
|
|
useRoomScreenShare({
|
|
|
|
peerRoom,
|
|
|
|
})
|
|
|
|
|
|
|
|
const handleToggleScreenShareButtonClick = () => {
|
|
|
|
if (isSharingScreen) {
|
|
|
|
handleScreenShareStop()
|
|
|
|
} else {
|
|
|
|
handleScreenShareStart()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!window.navigator?.mediaDevices?.getDisplayMedia) {
|
|
|
|
return <></>
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
alignItems: 'center',
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
justifyContent: 'center',
|
|
|
|
px: 1,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tooltip
|
|
|
|
title={
|
|
|
|
isSharingScreen ? 'Stop sharing screen' : 'Share screen with room'
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<Fab
|
|
|
|
color={isSharingScreen ? 'error' : 'success'}
|
|
|
|
aria-label="share screen"
|
|
|
|
onClick={handleToggleScreenShareButtonClick}
|
|
|
|
>
|
|
|
|
{isSharingScreen ? <StopScreenShare /> : <ScreenShare />}
|
|
|
|
</Fab>
|
|
|
|
</Tooltip>
|
|
|
|
</Box>
|
|
|
|
)
|
|
|
|
}
|