@@ -75,6 +75,7 @@ const CatalystChatView = ({
7575 cstmSupportUrl,
7676 arbData,
7777 bgRemoval,
78+ bgRemovalKey,
7879 handleReceiveArbData,
7980 onJoinCall,
8081 onMemberJoin,
@@ -92,6 +93,7 @@ const CatalystChatView = ({
9293 cstmSupportUrl ?: string ;
9394 arbData ?: Uint8Array ;
9495 bgRemoval ?: 'blur' | string ;
96+ bgRemovalKey : string ;
9597 handleReceiveArbData ?: ( arbData : Uint8Array ) => void ;
9698 onJoinCall ?: ( ) => void ;
9799 onMemberJoin ?: ( ) => void ;
@@ -107,7 +109,7 @@ const CatalystChatView = ({
107109 const [ chatOpen , setChatOpen ] = useState ( false ) ;
108110 const [ outputDevice , setOutputDevice ] = useState < MediaDeviceInfo > ( ) ;
109111 // const [bgRemovalEffect, setBgRemovalEffect] = useState(bgRemoval ?? 'none');
110- const [ bgFilter , setBgFilter ] = useState < BackgroundFilter > ( ) ;
112+ const [ bgFilter , setBgFilter ] = useState < BackgroundFilter > ( ) ;
111113 const roomState = useRoom ( ) ;
112114 const isMounted = useIsMounted ( ) ;
113115 const audDId = useReadLocalStorage ( 'PREFERRED_AUDIO_DEVICE_ID' ) ;
@@ -172,17 +174,17 @@ const CatalystChatView = ({
172174 : false ,
173175 } ) ;
174176 // apply bg removal filters
175- if ( bgRemoval && bgRemoval !== 'none' ) {
177+ if ( bgRemoval && bgRemoval !== 'none' && bgRemovalKey . length > 0 ) {
176178 const vidTrack = localTracks . find ( track => track . kind === 'video' ) ;
177179 if ( vidTrack ) {
178- const filter = await initBgFilter ( vidTrack , bgRemoval ) ;
180+ const filter = await initBgFilter ( bgRemovalKey , vidTrack , bgRemoval ) ;
179181 if ( filter ) {
180182 setBgFilter ( filter ) ;
181183 localTracks = await applyBgFilterToTracks ( localTracks , filter ) ;
182184 }
183185 }
184186 }
185-
187+
186188 localTracks . forEach ( track => {
187189 if ( ! isMounted ( ) ) return ;
188190 room . localParticipant . publishTrack (
@@ -221,25 +223,25 @@ const CatalystChatView = ({
221223 } , [ token ] ) ;
222224
223225 useEffect ( ( ) => {
224- if ( ! outputDevice ) {
225- navigator . mediaDevices . enumerateDevices ( ) . then ( devices => {
226- if ( ! isMounted ( ) ) return ;
227- const outputDevices = devices . filter (
228- id => id . kind === 'audiooutput' && id ?. deviceId
229- ) ;
230- let outDevice : MediaDeviceInfo | undefined ;
231- if ( outDId ) {
232- outDevice = outputDevices . find ( d => d ?. deviceId === outDId ) ;
233- }
234- if ( ! outDevice ) {
235- outDevice = outputDevices [ 0 ] ;
236- }
237- setOutputDevice ( outDevice ) ;
238- if ( outDId !== outDevice ?. deviceId && outDevice ?. deviceId ) {
239- setOutDId ( outDevice ?. deviceId ) ;
240- }
241- } ) ;
242- }
226+ if ( ! outputDevice ) {
227+ navigator . mediaDevices . enumerateDevices ( ) . then ( devices => {
228+ if ( ! isMounted ( ) ) return ;
229+ const outputDevices = devices . filter (
230+ id => id . kind === 'audiooutput' && id ?. deviceId
231+ ) ;
232+ let outDevice : MediaDeviceInfo | undefined ;
233+ if ( outDId ) {
234+ outDevice = outputDevices . find ( d => d ?. deviceId === outDId ) ;
235+ }
236+ if ( ! outDevice ) {
237+ outDevice = outputDevices [ 0 ] ;
238+ }
239+ setOutputDevice ( outDevice ) ;
240+ if ( outDId !== outDevice ?. deviceId && outDevice ?. deviceId ) {
241+ setOutDId ( outDevice ?. deviceId ) ;
242+ }
243+ } ) ;
244+ }
243245 // disconnect on unmount
244246 return ( ) => {
245247 roomState . disconnectAll ( ) ;
@@ -261,10 +263,9 @@ const CatalystChatView = ({
261263 } ;
262264
263265 // roomState.audioTracks.map(track => console.log(track));
264- if ( fade > 0 ) {
265-
266- // animate toolbar & header fade in/out
267- useEffect ( ( ) => {
266+ if ( fade > 0 ) {
267+ // animate toolbar & header fade in/out
268+ useEffect ( ( ) => {
268269 const delayCheck = ( ) => {
269270 if ( ! isMounted ( ) ) return ;
270271 const hClasses = headerRef . current ?. classList ;
@@ -315,16 +316,15 @@ const CatalystChatView = ({
315316 videoChatRef . current ?. addEventListener ( 'mousemove' , debounceHandleMouse ) ;
316317 var _delay = setInterval ( delayCheck , fade ) ;
317318
318- return ( ) => {
319- clearInterval ( _delay ) ;
320- videoChatRef . current ?. removeEventListener (
321- 'mousemove' ,
322- debounceHandleMouse
323- ) ;
324- } ;
325- } , [ ] ) ;
326- }
327-
319+ return ( ) => {
320+ clearInterval ( _delay ) ;
321+ videoChatRef . current ?. removeEventListener (
322+ 'mousemove' ,
323+ debounceHandleMouse
324+ ) ;
325+ } ;
326+ } , [ ] ) ;
327+ }
328328
329329 return (
330330 < div id = "video-chat" className = "relative w-full h-full" ref = { videoChatRef } >
@@ -485,10 +485,9 @@ const CatalystChatView = ({
485485 updateOutputDevice = { updateOutputDevice }
486486 outputDevice = { outputDevice }
487487 bgFilter = { bgFilter }
488- setBgFilter = { setBgFilter }
489- bgRemoval = { bgRemoval }
490- // bgRemovalEffect={bgRemovalEffect}
491- // setBgRemovalEffect={setBgRemovalEffect}
488+ setBgFilter = { setBgFilter }
489+ bgRemoval = { bgRemoval }
490+ bgRemovalKey = { bgRemovalKey }
492491 chatOpen = { chatOpen }
493492 setChatOpen = { setChatOpen }
494493 disableChat = { disableChat }
0 commit comments