-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨(frontend) introduce a side panel for effects
It simply render the video track if enabled. It's a basis for building the 'blur your screen' feature. More in the upcoming commits.
- Loading branch information
1 parent
6c2cace
commit 9e35562
Showing
8 changed files
with
106 additions
and
10 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
src/frontend/src/features/rooms/livekit/components/Effects.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { useEffect, useRef } from 'react' | ||
import { useLocalParticipant } from '@livekit/components-react' | ||
import { LocalVideoTrack } from 'livekit-client' | ||
import { Div, P } from '@/primitives' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
export const Effects = () => { | ||
const { t } = useTranslation('rooms', { keyPrefix: 'effects' }) | ||
const { isCameraEnabled, cameraTrack } = useLocalParticipant() | ||
const videoRef = useRef<HTMLVideoElement>(null) | ||
|
||
const localCameraTrack = cameraTrack?.track as LocalVideoTrack | ||
|
||
useEffect(() => { | ||
const videoElement = videoRef.current | ||
|
||
const attachVideoTrack = async () => { | ||
if (!videoElement) return | ||
localCameraTrack?.attach(videoElement) | ||
} | ||
|
||
attachVideoTrack() | ||
|
||
return () => { | ||
if (!videoElement) return | ||
localCameraTrack.detach(videoElement) | ||
} | ||
}, [localCameraTrack, isCameraEnabled]) | ||
|
||
return ( | ||
<Div padding="0 1.5rem"> | ||
{localCameraTrack && isCameraEnabled ? ( | ||
<video | ||
ref={videoRef} | ||
width="100%" | ||
muted | ||
style={{ | ||
transform: 'rotateY(180deg)', | ||
minHeight: '173px', | ||
borderRadius: '4px', | ||
}} | ||
/> | ||
) : ( | ||
<div | ||
style={{ | ||
width: '100%', | ||
height: '174px', | ||
display: 'flex', | ||
backgroundColor: 'black', | ||
justifyContent: 'center', | ||
flexDirection: 'column', | ||
}} | ||
> | ||
<P | ||
style={{ | ||
color: 'white', | ||
textAlign: 'center', | ||
textWrap: 'balance', | ||
marginBottom: 0, | ||
}} | ||
> | ||
{t('activateCamera')} | ||
</P> | ||
</div> | ||
)} | ||
</Div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters