I’m building a video conference web app using ReactJS. Now, I have an issue, where if I initially has the state of isUseVideo === false
means that the user’s camera is disabled, and I open the PiP mode, the PiP will not show the camera toggle, so I’m unable to toggle it on through the PiP mode.
useEffect(() => {
navigator.mediaSession.setMicrophoneActive(isUseMicrophone);
navigator.mediaSession.setCameraActive(isUseVideo);
try {
navigator.mediaSession.setActionHandler("togglemicrophone", () => {
console.log('User clicked "Toggle Mic" icon.');
if (isAllowUnmute) {
navigator.mediaSession.setMicrophoneActive(!isUseMicrophone);
dispatch(setUseMicrophone(!isUseMicrophone));
}
});
} catch (error) {
console.log(
'Warning! The "togglemicrophone" media session action is not supported.'
);
}
try {
navigator.mediaSession.setActionHandler("togglecamera", () => {
console.log('User clicked "Toggle Camera" icon.');
navigator.mediaSession.setCameraActive(!isUseVideo);
dispatch(setUseVideo(!isUseVideo));
});
} catch (error) {
console.log(
'Warning! The "togglecamera" media session action is not supported.'
);
}
}, [isUseMicrophone, isUseVideo]);
This works fine for the microphone though. Am I missing something here?