How to skip DeviceSelectionScreen (deviceSelectionStep)?
pavel-khudiakov-effectiff opened this issue · 5 comments
Question
Hello everyone! My version is 0.7.1.
I need to skip deviceSelectionStep
, but if I replace (for example) <DeviceSelectionScreen …>
to <Button onClick={handleJoin}>
in PreJoinScreens.tsx
, after join the room my video is black (it's switching on after double click on/off) and microphone is muted forever.
Can't understand why. Red dot on Chrome tab showing that video and audio tracks is working.
I think the problem is somewhere inside getAudioAndVideoTracks()
in PreJoinScreens.tsx
:
- If we use NextJS with
reactStrictMode: true
, it permanently uses mic and camera, because ofuseEffect
withoutreturn
. Probably I should add:
return () => { localTracks.forEach((track) => track.stop()); };
- Then if I skip
<DeviceSelectionScreen />
and replace it with<Button onClick={handleJoin}>
instead, I facing some async problem:
- Local camera is black (it's switching on after double click on/off) and microphone is muted forever.
- But if I stay little longer on PreJoinScreens page, camera and mic initiated well.
How should I init camera and mic in a correct way, when I skip DeviceSelectionScreen part? I need it to accept incoming call without device checks.
The problem is reproduced if isAcquiringLocalTracks
is true
at the same time while we are trying to get publications from usePublications
. I modify my example for join on submit:
master...pavel-khudiakov-effectiff:twilio-video-app-react:skip-device-selection-screen
Now it's easier to reproduce.
Probably the problem is somewhere inside async operations.
I tried any variation if (isAcquiringLocalTracks) return <Spinner>
or waiting isAcquiringLocalTracks
before call handleJoin()
, but it's not helping.
Add commit 'debug 2':
- When I try to call
handleJoin()
fromuseEffect
withif (!isAcquiringLocalTracks) ...
it is still black screen:
useEffect(() => {
if (isJoining && !isAcquiringLocalTracks) {
handleJoin();
}
}, [isJoining, isAcquiringLocalTracks]);
- But if I click at the button (after it is no more disabled), everything is fine:
<Button
variant="contained"
color="primary"
data-cy-join-now
onClick={handleJoin}
disabled={isAcquiringLocalTracks}
>