Created
May 22, 2020 14:22
-
-
Save ErikGMatos/5175d75c1d03fbf1c7e3971d49a464cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // function to connect | |
| const initLoad = useCallback(async () => { | |
| if (!info) return history.push(commom.CONFIG_ERROR); | |
| const room1 = await connect(info.joinInfo.attendee.jwtToken, { | |
| video: { deviceId: videoInputDevice }, | |
| audio: { deviceId: audioInputDevice }, | |
| name: info.meetingId, | |
| networkQuality: { | |
| local: 2, | |
| remote: 1, | |
| }, | |
| }); | |
| setClientIdentity(info?.user?.name); | |
| setRoom(room1); | |
| if (currentStream.active) currentStream.active.stop(); | |
| const track = await createLocalVideoTrack({ | |
| deviceId: { | |
| exact: videoInputDevice, | |
| }, | |
| }); | |
| setTrackLocal(track); | |
| refVideoClient.current.appendChild(track.attach()); | |
| }, [audioInputDevice, info, videoInputDevice]); | |
| //function to events of room | |
| useEffect(() => { | |
| if (!room) return; | |
| room.participants.forEach(addParticipant); | |
| room.on('participantConnected', addParticipant); | |
| room.on('participantDisconnected', participantDisconnected); | |
| room.once('disconnected', () => { | |
| // endMeeting(info); | |
| setShowModal(SET_ACTIVE_MODAL.endCall); | |
| setRemoteIdentity(false); | |
| console.log('Você saiu da sala:', room.name); | |
| }); | |
| room.on('trackUnsubscribed', track => { | |
| track.detach().forEach(mediaElement => { | |
| mediaElement.remove(); | |
| }); | |
| }); | |
| room.localParticipant.on( | |
| 'networkQualityLevelChanged', | |
| printNetworkQualityStatsLocal | |
| ); | |
| }, [addParticipant, info, room]); | |
| //as I would do for no click. of a button can I stop my current camera and switch to the other one? | |
| I've tried several times without success = / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment