From 8aa9567fa1f1e81a4ead1f6f2d896b8b14db0a7c Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 22 Apr 2024 17:25:23 +0200 Subject: [PATCH] Fix participant tile audio muted data prop (#838) --- .changeset/moody-suits-share.md | 5 +++++ packages/react/src/hooks/useParticipantTile.ts | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changeset/moody-suits-share.md diff --git a/.changeset/moody-suits-share.md b/.changeset/moody-suits-share.md new file mode 100644 index 000000000..3e66b9415 --- /dev/null +++ b/.changeset/moody-suits-share.md @@ -0,0 +1,5 @@ +--- +"@livekit/components-react": patch +--- + +Fix participant tile audio muted data prop diff --git a/packages/react/src/hooks/useParticipantTile.ts b/packages/react/src/hooks/useParticipantTile.ts index d353ce76d..59b76c5d1 100644 --- a/packages/react/src/hooks/useParticipantTile.ts +++ b/packages/react/src/hooks/useParticipantTile.ts @@ -6,6 +6,7 @@ import { mergeProps } from '../mergeProps'; import { useFacingMode } from './useFacingMode'; import { useIsMuted } from './useIsMuted'; import { useIsSpeaking } from './useIsSpeaking'; +import { Track } from 'livekit-client'; /** @public */ export interface UseParticipantTileProps extends React.HTMLAttributes { @@ -53,8 +54,17 @@ export function useParticipantTile({ trackReference.source, trackReference.participant, ]); + + const micTrack = trackReference.participant.getTrackPublication(Track.Source.Microphone); + const micRef = React.useMemo(() => { + return { + participant: trackReference.participant, + source: Track.Source.Microphone, + publication: micTrack, + }; + }, [micTrack, trackReference.participant]); const isVideoMuted = useIsMuted(trackReference); - const isAudioMuted = useIsMuted(trackReference); + const isAudioMuted = useIsMuted(micRef); const isSpeaking = useIsSpeaking(trackReference.participant); const facingMode = useFacingMode(trackReference); return {