Reputation: 5968
I have a meeting app using Twilio Video.
The app has a requirement such that when a user wants to join a room, it's not immediate. That means a user sends a request to the app server to join, immediately he will see his local webcam, then he will wait for sometime until the server responds with a token to join the room. It may be 10 or 20 minutes.
The communication between the client and the server is done through WebSockets.
Here is the process :
Step 1: Client sends a request to the app server to join a room
Step 2: Request access and show the client local camera as follows :
// Get the track from twilio
const Track = await Twilio.Video.createLocalVideoTrack();
// Add track to HTML
LocalMediaContainer.appendChild(Track.attach());
Step 3: Client waits for the server to respond (let's say 10 minutes)
Step 4: The server responds with the token to join Twilio video room
Step 5: Client joins room using the token sent by the server as follows
Twilio.Video.connect(Token, { name:RoomName }).then(room => {
console.log('Successfully joined a Room');
room.on('participantConnected', participant => {
console.log('A remote Participant connected ');
});
}, error => {
console.error('Unable to connect to Room');
});
The process works fine. The problem I'm getting however, is that in Step 5, when the client is trying to join a room, Twilio asks him again to grant access to camera.
Basically, even though the access has already been granted, the method Twilio.Video.connect asks again for access.
I was wondering if there is a way to use the authorization previously granted to use the camera and avoid asking for it again if it has already been granted.
Upvotes: 1
Views: 316
Reputation: 73027
Twilio developer evangelist here.
When you call Twilio.Video.connect
you can pass an array of tracks with the user's media that you already have.
Twilio.Video.connect(Token, { name: RoomName, tracks: [VideoTrack, AudioTrack] }).then(...);
This uses your existing tracks instead of making a new permissions request to getUserMedia
.
Upvotes: 2