Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Fixed webcam light not turning off when camera paused. (#10224)
Browse files Browse the repository at this point in the history
Video tracks, and clones thereof, were not being stopped when one's camera
was paused. This would lead the webcam 'active' light to stay on.
  • Loading branch information
barankyle authored May 23, 2024
1 parent bc81dde commit 513898f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/client-core/src/components/UserMediaWindow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ export const useUserMediaWindowHook = ({ peerID, type }: Props) => {
useEffect(() => {
if (peerMediaChannelState.videoStream.value?.track)
videoTrackId.set(peerMediaChannelState.videoStream.value.track.id)
}, [peerMediaChannelState.videoStream])
}, [peerMediaChannelState.videoStream.value?.track?.id])

useEffect(() => {
if (peerMediaChannelState.audioStream.value?.track)
audioTrackId.set(peerMediaChannelState.audioStream.value.track.id)
}, [peerMediaChannelState.audioStream])
}, [peerMediaChannelState.audioStream.value?.track?.id])

useEffect(() => {
function onUserInteraction() {
Expand Down Expand Up @@ -284,6 +284,8 @@ export const useUserMediaWindowHook = ({ peerID, type }: Props) => {
}
}, 100)
}
if (isSelf && videoProducerPaused && videoStream != null && videoElement != null)
videoTrackClones.get(NO_PROXY).forEach((track) => track.stop())
}, [videoProducerPaused])

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ export const toggleWebcamPaused = async () => {
if (videoPaused) resumeProducer(mediaNetwork, mediaStreamState.camVideoProducer.value! as ProducerExtension)
else pauseProducer(mediaNetwork, mediaStreamState.camVideoProducer.value! as ProducerExtension)
mediaStreamState.videoPaused.set(!videoPaused)
if (!videoPaused) mediaStreamState.camVideoProducer.value!.track?.stop()
}
}
}
Expand Down

0 comments on commit 513898f

Please sign in to comment.