Fix mute flickering. (#2350)
Use `useMeme` to not change the parameters that are used to call usePreviewDevice. Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -68,8 +68,8 @@ export const VideoPreview: FC<Props> = ({
|
|||||||
deviceId: devices.audioInput.selectedId,
|
deviceId: devices.audioInput.selectedId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const tracks = usePreviewTracks(
|
const deviceConfig = useMemo(() => {
|
||||||
{
|
return {
|
||||||
// The only reason we request audio here is to get the audio permission
|
// The only reason we request audio here is to get the audio permission
|
||||||
// request over with at the same time. But changing the audio settings
|
// request over with at the same time. But changing the audio settings
|
||||||
// shouldn't cause this hook to recreate the track, which is why we
|
// shouldn't cause this hook to recreate the track, which is why we
|
||||||
@@ -80,13 +80,15 @@ export const VideoPreview: FC<Props> = ({
|
|||||||
video: muteStates.video.enabled && {
|
video: muteStates.video.enabled && {
|
||||||
deviceId: devices.videoInput.selectedId,
|
deviceId: devices.videoInput.selectedId,
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
(error) => {
|
}, [devices.videoInput.selectedId, muteStates.video.enabled]);
|
||||||
logger.error("Error while creating preview Tracks:", error);
|
|
||||||
muteStates.audio.setEnabled?.(false);
|
const tracks = usePreviewTracks(deviceConfig, (error) => {
|
||||||
muteStates.video.setEnabled?.(false);
|
logger.error("Error while creating preview Tracks:", error);
|
||||||
},
|
muteStates.audio.setEnabled?.(false);
|
||||||
);
|
muteStates.video.setEnabled?.(false);
|
||||||
|
});
|
||||||
|
|
||||||
const videoTrack = useMemo(
|
const videoTrack = useMemo(
|
||||||
() =>
|
() =>
|
||||||
tracks?.find((t) => t.kind === Track.Kind.Video) as
|
tracks?.find((t) => t.kind === Track.Kind.Video) as
|
||||||
|
|||||||
Reference in New Issue
Block a user