fixing state when cant connect to media

This commit is contained in:
Roland Osborne 2023-03-28 16:19:47 -07:00
parent 00f4769505
commit d6b642d6a2

View File

@ -323,20 +323,25 @@ export function useRingContext() {
videoTrack.current = false; videoTrack.current = false;
audioTrack.current = false; audioTrack.current = false;
accessVideo.current = false; accessVideo.current = false;
const stream = await navigator.mediaDevices.getUserMedia({ try {
video: false, const stream = await navigator.mediaDevices.getUserMedia({
audio: true, video: false,
}); audio: true,
accessAudio.current = true; });
updateState({ localVideo: false, localAudio: true, localStream: stream }); accessAudio.current = true;
for (const track of stream.getTracks()) { updateState({ localVideo: false, localAudio: true, localStream: stream });
if (track.kind === 'audio') { for (const track of stream.getTracks()) {
audioTrack.current = track; if (track.kind === 'audio') {
audioTrack.current = track;
}
if (track.kind === 'video') {
videoTrack.current = track;
}
pc.current.addTrack(track);
} }
if (track.kind === 'video') { }
videoTrack.current = track; catch (err) {
} console.log(err);
pc.current.addTrack(track);
} }
const protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; const protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';