You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			92 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			92 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			TypeScript
		
	
| 
											4 years ago
										 | import React, { useEffect } from 'react'; | ||
| 
											4 years ago
										 | import { useDispatch, useSelector } from 'react-redux'; | ||
| 
											4 years ago
										 | // tslint:disable-next-line: no-submodule-imports
 | ||
| 
											4 years ago
										 | import useKey from 'react-use/lib/useKey'; | ||
| 
											4 years ago
										 | import styled from 'styled-components'; | ||
| 
											4 years ago
										 | import { useVideoCallEventsListener } from '../../hooks/useVideoEventListener'; | ||
|  | import { setFullScreenCall } from '../../state/ducks/call'; | ||
| 
											4 years ago
										 | import { | ||
|  |   getCallIsInFullScreen, | ||
| 
											4 years ago
										 |   getHasOngoingCallWithFocusedConvo, | ||
| 
											4 years ago
										 | } from '../../state/selectors/call'; | ||
| 
											4 years ago
										 | import { CallWindowControls } from './CallButtons'; | ||
| 
											4 years ago
										 | import { StyledVideoElement } from './DraggableCallContainer'; | ||
| 
											4 years ago
										 | 
 | ||
|  | const CallInFullScreenVisible = styled.div`
 | ||
|  |   position: absolute; | ||
|  |   z-index: 9; | ||
|  |   top: 0; | ||
|  |   bottom: 0; | ||
|  |   right: 0; | ||
|  |   left: 0; | ||
|  |   display: flex; | ||
|  |   flex-direction: column; | ||
| 
											4 years ago
										 |   background-color: black; | ||
| 
											4 years ago
										 |   border: var(--session-border); | ||
| 
											4 years ago
										 |   opacity: 1; | ||
| 
											4 years ago
										 | `;
 | ||
|  | 
 | ||
|  | export const CallInFullScreenContainer = () => { | ||
|  |   const dispatch = useDispatch(); | ||
| 
											4 years ago
										 |   const ongoingCallWithFocused = useSelector(getHasOngoingCallWithFocusedConvo); | ||
| 
											4 years ago
										 |   const hasOngoingCallFullScreen = useSelector(getCallIsInFullScreen); | ||
|  | 
 | ||
| 
											4 years ago
										 |   const { | ||
|  |     remoteStream, | ||
|  |     remoteStreamVideoIsMuted, | ||
|  |     currentConnectedAudioInputs, | ||
| 
											4 years ago
										 |     currentConnectedAudioOutputs, | ||
| 
											4 years ago
										 |     currentConnectedCameras, | ||
|  |     isAudioMuted, | ||
| 
											4 years ago
										 |     isAudioOutputMuted, | ||
| 
											4 years ago
										 |     localStreamVideoIsMuted, | ||
|  |   } = useVideoCallEventsListener('CallInFullScreenContainer', true); | ||
| 
											4 years ago
										 | 
 | ||
|  |   const videoRefRemote = React.useRef<HTMLVideoElement>(null); | ||
| 
											4 years ago
										 | 
 | ||
|  |   function toggleFullScreenOFF() { | ||
|  |     dispatch(setFullScreenCall(false)); | ||
|  |   } | ||
|  | 
 | ||
| 
											4 years ago
										 |   useKey('Escape', () => { | ||
|  |     toggleFullScreenOFF(); | ||
|  |   }); | ||
| 
											4 years ago
										 | 
 | ||
|  |   useEffect(() => { | ||
|  |     // close fullscreen mode if the remote video gets muted
 | ||
|  |     if (remoteStreamVideoIsMuted) { | ||
|  |       dispatch(setFullScreenCall(false)); | ||
|  |     } | ||
|  |   }, [remoteStreamVideoIsMuted]); | ||
|  | 
 | ||
| 
											4 years ago
										 |   if (!ongoingCallWithFocused || !hasOngoingCallFullScreen) { | ||
| 
											4 years ago
										 |     return null; | ||
|  |   } | ||
|  | 
 | ||
| 
											4 years ago
										 |   if (videoRefRemote?.current) { | ||
| 
											4 years ago
										 |     if (videoRefRemote.current.srcObject !== remoteStream) { | ||
|  |       videoRefRemote.current.srcObject = remoteStream; | ||
|  |     } | ||
| 
											4 years ago
										 |   } | ||
|  | 
 | ||
|  |   return ( | ||
|  |     <CallInFullScreenVisible onClick={toggleFullScreenOFF}> | ||
|  |       <StyledVideoElement | ||
|  |         ref={videoRefRemote} | ||
|  |         autoPlay={true} | ||
|  |         isVideoMuted={remoteStreamVideoIsMuted} | ||
|  |       /> | ||
| 
											4 years ago
										 |       <CallWindowControls | ||
|  |         currentConnectedAudioInputs={currentConnectedAudioInputs} | ||
| 
											4 years ago
										 |         currentConnectedAudioOutputs={currentConnectedAudioOutputs} | ||
| 
											4 years ago
										 |         currentConnectedCameras={currentConnectedCameras} | ||
|  |         isAudioMuted={isAudioMuted} | ||
| 
											4 years ago
										 |         isAudioOutputMuted={isAudioOutputMuted} | ||
| 
											4 years ago
										 |         localStreamVideoIsMuted={localStreamVideoIsMuted} | ||
|  |         remoteStreamVideoIsMuted={remoteStreamVideoIsMuted} | ||
|  |         isFullScreen={true} | ||
|  |       /> | ||
| 
											4 years ago
										 |     </CallInFullScreenVisible> | ||
|  |   ); | ||
| 
											4 years ago
										 | }; |