Created
December 20, 2023 12:42
-
-
Save Tushkiz/d5621db6be82c27db894d30f28ce822b to your computer and use it in GitHub Desktop.
VirtualBackground Addon
This file contains hidden or 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
import { useEffect, useState } from 'react'; | |
import DyteClient from '@dytesdk/web-core'; | |
import { DyteMeeting, registerAddons } from '@dytesdk/react-ui-kit'; | |
import VideoBackgroundAddon from '@dytesdk/ui-kit-addons/video-background'; | |
const videoBackground = new VideoBackgroundAddon({ | |
modes: ['blur', 'virtual'], | |
images: [ | |
'https://images.unsplash.com/photo-1487088678257-3a541e6e3922?q=80&w=2874&auto=format&fit=crop&ixlib=rb-4.0.3', | |
'https://images.unsplash.com/photo-1496715976403-7e36dc43f17b?q=80&w=2848&auto=format&fit=crop&ixlib=rb-4.0.3', | |
'https://images.unsplash.com/photo-1600431521340-491eca880813?q=80&w=2938&auto=format&fit=crop&ixlib=rb-4.0.3', | |
], | |
}); | |
function VideoBgAddon() { | |
const [meeting, setMeeting] = useState<DyteClient | null>(null); | |
const url = new URL(window.location.href); | |
const queryToken = url.searchParams.get('authToken')!; | |
if (!queryToken) { | |
alert('Please add authToken to url query params'); | |
} | |
useEffect(() => { | |
if (meeting) return; | |
const init = async () => { | |
DyteClient.init({ | |
defaults: { audio: false, video: false }, | |
authToken: queryToken, | |
}).then((m) => { | |
setMeeting(m); | |
}); | |
}; | |
init(); | |
}, [meeting, queryToken]); | |
if (!meeting) { | |
return 'Loading...'; | |
} | |
return <DyteMeeting meeting={meeting} config={registerAddons([videoBackground], meeting)} />; | |
} | |
export default VideoBgAddon; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment