|
@@ -15,7 +15,7 @@ import MicIcon from '@mui/icons-material/Mic';
|
|
import MicOffIcon from '@mui/icons-material/MicOff';
|
|
import MicOffIcon from '@mui/icons-material/MicOff';
|
|
import CallEndIcon from '@mui/icons-material/CallEnd';
|
|
import CallEndIcon from '@mui/icons-material/CallEnd';
|
|
import Moveable from "react-moveable";
|
|
import Moveable from "react-moveable";
|
|
-import {OnDrag,OnResize,OnScale} from "react-moveable";
|
|
|
|
|
|
+import { OnDrag } from "react-moveable";
|
|
|
|
|
|
import { getChat } from '../../../../../../redux/chat/selector';
|
|
import { getChat } from '../../../../../../redux/chat/selector';
|
|
import { prodAwsS3,firstLetter,slicedWord } from '../../../../../../helpers'
|
|
import { prodAwsS3,firstLetter,slicedWord } from '../../../../../../helpers'
|
|
@@ -28,7 +28,12 @@ const useStyles = makeStyles({
|
|
width: '100vw',
|
|
width: '100vw',
|
|
height: '100vh',
|
|
height: '100vh',
|
|
zIndex: 100,
|
|
zIndex: 100,
|
|
- overflowY: 'hidden',
|
|
|
|
|
|
+ overflow: 'hidden',
|
|
|
|
+ display: 'flex',
|
|
|
|
+ justifyContent: 'center',
|
|
|
|
+ alignItems: 'center',
|
|
|
|
+ alignContent: "center",
|
|
|
|
+ backgroundColor: 'rgba(104, 105, 104, 0.6)',
|
|
},
|
|
},
|
|
shareScreenActive: {
|
|
shareScreenActive: {
|
|
width: '90%',
|
|
width: '90%',
|
|
@@ -42,7 +47,6 @@ const useStyles = makeStyles({
|
|
},
|
|
},
|
|
modalCall: {
|
|
modalCall: {
|
|
background: 'rgb(36, 36, 36)',
|
|
background: 'rgb(36, 36, 36)',
|
|
- position: 'absolute',
|
|
|
|
display: 'flex',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
flexDirection: 'column',
|
|
justifyContent: 'start',
|
|
justifyContent: 'start',
|
|
@@ -50,8 +54,6 @@ const useStyles = makeStyles({
|
|
justifyItems:"center",
|
|
justifyItems:"center",
|
|
width: '34vw',
|
|
width: '34vw',
|
|
height:'50vh',
|
|
height:'50vh',
|
|
- left: '33vw',
|
|
|
|
- bottom: '25vh',
|
|
|
|
borderRadius: 7,
|
|
borderRadius: 7,
|
|
},
|
|
},
|
|
rightIcons: {
|
|
rightIcons: {
|
|
@@ -127,12 +129,12 @@ interface ICallModal {
|
|
const CallModal = ({setModalCall,shareRef,videoRef}:ICallModal) => {
|
|
const CallModal = ({setModalCall,shareRef,videoRef}:ICallModal) => {
|
|
const classes = useStyles()
|
|
const classes = useStyles()
|
|
const { name, lastName, avatarUrl, color } = useSelector(getChat)
|
|
const { name, lastName, avatarUrl, color } = useSelector(getChat)
|
|
- const [mute, setMute] = useState<boolean>(false)
|
|
|
|
|
|
+ const [audio, setAudio] = useState<boolean>(true)
|
|
|
|
+ const [video, setVideo] = useState<any>(false)
|
|
const [share, setShare] = useState<any>(null)
|
|
const [share, setShare] = useState<any>(null)
|
|
- const target = videoRef.current
|
|
|
|
const handleShareScreen = async () => {
|
|
const handleShareScreen = async () => {
|
|
const displayMediaStreamConstraints = {
|
|
const displayMediaStreamConstraints = {
|
|
- video: true
|
|
|
|
|
|
+ video: true,
|
|
};
|
|
};
|
|
const navigator:any = window.navigator
|
|
const navigator:any = window.navigator
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints);
|
|
const stream = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints);
|
|
@@ -140,36 +142,53 @@ const CallModal = ({setModalCall,shareRef,videoRef}:ICallModal) => {
|
|
setShare(true)
|
|
setShare(true)
|
|
stream.getVideoTracks()[0].onended = () => setShare(false)
|
|
stream.getVideoTracks()[0].onended = () => setShare(false)
|
|
};
|
|
};
|
|
- const handleMute = () => setMute(prevState => !prevState)
|
|
|
|
|
|
+ const handleAudio = () => setAudio(prevState => !prevState)
|
|
|
|
+ const handleVideo = async () => {
|
|
|
|
+ const displayMediaStreamConstraints = {
|
|
|
|
+ audio: false,
|
|
|
|
+ video: {
|
|
|
|
+ width: {
|
|
|
|
+ min: 1280,
|
|
|
|
+ ideal: 1920,
|
|
|
|
+ max: 2560,
|
|
|
|
+ },
|
|
|
|
+ height: {
|
|
|
|
+ min: 720,
|
|
|
|
+ ideal: 1080,
|
|
|
|
+ max: 1440
|
|
|
|
+ },
|
|
|
|
+ facingMode: 'user'
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ const navigator:any = window.navigator
|
|
|
|
+ const stream = await navigator.mediaDevices.getUserMedia(displayMediaStreamConstraints)
|
|
|
|
+
|
|
|
|
+ if (!video) {
|
|
|
|
+ setVideo(true)
|
|
|
|
+ videoRef.current.srcObject = stream;
|
|
|
|
+ } else {
|
|
|
|
+ videoRef.current.srcObject = null;
|
|
|
|
+ stream.getVideoTracks()[0].stop()
|
|
|
|
+ setVideo(false)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
const handleCloseCallModal = () => setModalCall(false)
|
|
const handleCloseCallModal = () => setModalCall(false)
|
|
// requesting, waiting ,ringing, hanging up,line busy
|
|
// requesting, waiting ,ringing, hanging up,line busy
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={classes.overlay} >
|
|
<div className={classes.overlay} >
|
|
- <video ref={videoRef} style={{minWidth:100,minHeight:70}} playsInline muted autoPlay/>
|
|
|
|
|
|
+ <video ref={videoRef} style={{width: video ? 250 : 0, height: video ? 'auto' : 0, cursor: 'pointer',
|
|
|
|
+ position: 'absolute', top: 0, left: 0, zIndex: 100}} playsInline autoPlay muted/>
|
|
<Moveable
|
|
<Moveable
|
|
- target={target}
|
|
|
|
- container={null}
|
|
|
|
- origin={true}
|
|
|
|
- edge={false}
|
|
|
|
|
|
+ target={videoRef.current}
|
|
draggable={true}
|
|
draggable={true}
|
|
throttleDrag={0}
|
|
throttleDrag={0}
|
|
|
|
+ hideDefaultLines={true}
|
|
|
|
+ renderDirections={[]}
|
|
|
|
+ rotationPosition="none"
|
|
|
|
+ origin={false}
|
|
onDrag={({ target, transform }: OnDrag) =>
|
|
onDrag={({ target, transform }: OnDrag) =>
|
|
target!.style.transform = transform }
|
|
target!.style.transform = transform }
|
|
- keepRatio={true}
|
|
|
|
- resizable={true}
|
|
|
|
- throttleResize={0}
|
|
|
|
- onResize={({target, width, height,delta}: OnResize) => {
|
|
|
|
- delta[0] && (target!.style.width = `${width}px`);
|
|
|
|
- delta[1] && (target!.style.height = `${height}px`);
|
|
|
|
- }}
|
|
|
|
- scalable={true}
|
|
|
|
- throttleScale={0}
|
|
|
|
- onScale={({target, scale, transform}: OnScale) => {
|
|
|
|
- target!.style.transform = transform;
|
|
|
|
- }}
|
|
|
|
- rotatable={false}
|
|
|
|
- pinchable={true}
|
|
|
|
/>
|
|
/>
|
|
<div className={classes.modalCall}>
|
|
<div className={classes.modalCall}>
|
|
<div className={classes.rightIcons} style={{marginBottom: share?0:40,}}>
|
|
<div className={classes.rightIcons} style={{marginBottom: share?0:40,}}>
|
|
@@ -185,7 +204,7 @@ const CallModal = ({setModalCall,shareRef,videoRef}:ICallModal) => {
|
|
</div>
|
|
</div>
|
|
{!share&&<ListItemAvatar style={{marginBottom:15}}>
|
|
{!share&&<ListItemAvatar style={{marginBottom:15}}>
|
|
<Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
|
|
<Avatar alt={name} src={avatarUrl?`${prodAwsS3}/${avatarUrl}`:undefined}
|
|
- sx={{ background: color, width: 120, height: 120, marginRight: 2, fontSize:30}}>
|
|
|
|
|
|
+ sx={{ background: color, width: 120, height: 120, marginRight: 2, fontSize:30,zIndex:0}}>
|
|
{`${firstLetter(name)}${firstLetter(lastName)}`}
|
|
{`${firstLetter(name)}${firstLetter(lastName)}`}
|
|
</Avatar>
|
|
</Avatar>
|
|
</ListItemAvatar>}
|
|
</ListItemAvatar>}
|
|
@@ -202,31 +221,31 @@ const CallModal = ({setModalCall,shareRef,videoRef}:ICallModal) => {
|
|
<div className={classes.bottomWrapper}>
|
|
<div className={classes.bottomWrapper}>
|
|
{!share&&<div className={classes.bottomItem}>
|
|
{!share&&<div className={classes.bottomItem}>
|
|
<Avatar className={classes.bottomIcon} onClick={handleShareScreen}
|
|
<Avatar className={classes.bottomIcon} onClick={handleShareScreen}
|
|
- sx={{backgroundColor: '#ffffff',color: 'rgb(36, 36, 36)', width: 44, height: 44}}>
|
|
|
|
|
|
+ sx={{backgroundColor: '#ffffff',color: 'rgb(36, 36, 36)', width: 44, height: 44,zIndex:0}}>
|
|
<ScreenShareIcon fontSize="medium" />
|
|
<ScreenShareIcon fontSize="medium" />
|
|
</Avatar>
|
|
</Avatar>
|
|
<Typography variant="h6" className={classes.titleIconBottom}>Screencast</Typography>
|
|
<Typography variant="h6" className={classes.titleIconBottom}>Screencast</Typography>
|
|
</div>}
|
|
</div>}
|
|
<div className={classes.bottomItem}>
|
|
<div className={classes.bottomItem}>
|
|
- <Avatar className={classes.bottomIcon}
|
|
|
|
- sx={{backgroundColor: share?'rgb(88, 88, 88)':'#ffffff',color: share?'#ffffff':'rgb(36, 36, 36)', width: 44, height: 44}}>
|
|
|
|
- <VideocamOffIcon fontSize="medium" />
|
|
|
|
|
|
+ <Avatar className={classes.bottomIcon} onClick={handleVideo}
|
|
|
|
+ sx={{backgroundColor: video?'rgb(88, 88, 88)':'#ffffff',color: video?'#ffffff':'rgb(36, 36, 36)', width: 44, height: 44,zIndex:0}}>
|
|
|
|
+ {video?<VideocamOffIcon fontSize="medium" />:<VideocamIcon fontSize="medium" />}
|
|
</Avatar>
|
|
</Avatar>
|
|
- <Typography variant="h6" className={classes.titleIconBottom}>Start Video</Typography>
|
|
|
|
|
|
+ <Typography variant="h6" className={classes.titleIconBottom}>{video?'Stop Video':'Start Video'}</Typography>
|
|
</div>
|
|
</div>
|
|
<div className={classes.bottomItem}>
|
|
<div className={classes.bottomItem}>
|
|
<Avatar className={classes.bottomIcon}
|
|
<Avatar className={classes.bottomIcon}
|
|
- sx={{backgroundColor: '#f02a2a',color: '#ffffff', width: 44, height: 44}}>
|
|
|
|
|
|
+ sx={{backgroundColor: '#f02a2a',color: '#ffffff', width: 44, height: 44,zIndex:0}}>
|
|
<CallEndIcon fontSize="medium" />
|
|
<CallEndIcon fontSize="medium" />
|
|
</Avatar>
|
|
</Avatar>
|
|
<Typography variant="h6" className={classes.titleIconBottom}>End Call</Typography>
|
|
<Typography variant="h6" className={classes.titleIconBottom}>End Call</Typography>
|
|
</div>
|
|
</div>
|
|
<div className={classes.bottomItem}>
|
|
<div className={classes.bottomItem}>
|
|
- <Avatar className={classes.bottomIcon} onClick={handleMute}
|
|
|
|
- sx={{backgroundColor: mute?'#ffffff':'rgb(88, 88, 88)',color: mute?'rgb(36, 36, 36)':'#ffffff', width: 44, height: 44}}>
|
|
|
|
- {mute?<MicOffIcon fontSize="medium" />:<MicIcon fontSize="medium" />}
|
|
|
|
|
|
+ <Avatar className={classes.bottomIcon} onClick={handleAudio}
|
|
|
|
+ sx={{backgroundColor: audio?'rgb(88, 88, 88)':'#ffffff',color: audio?'#ffffff':'rgb(36, 36, 36)', width: 44, height: 44,zIndex:0}}>
|
|
|
|
+ {audio?<MicIcon fontSize="medium" />:<MicOffIcon fontSize="medium" />}
|
|
</Avatar>
|
|
</Avatar>
|
|
- <Typography variant="h6" className={classes.titleIconBottom}>{mute?'Unmute':'Mute'}</Typography>
|
|
|
|
|
|
+ <Typography variant="h6" className={classes.titleIconBottom}>{audio?'Mute':'Unmute'}</Typography>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|