1

I'm building a video conferencing solution where participants first join a hall area where they check out the participants in the hall and then when desired are able to start a video conference.

The hall/room area displays a listing of the members connected to the room. I'm initializing the room by connecting with audio and video parameters set to false.

It's only when the participants choose to enter the conference that I need to set these parameters to true and then be able to retrieve the relevant tracks.

Is there a way to change the connect options after a connection is made?

1 Answers1

1

Twilio developer evangelist here.

While you can't exactly change the initial connect options after a connection is made you can publish new tracks to a room for a participant.

You'll have to request the audio and video yourself using navigator.mediaDevices.getUserMedia then once you have the media stream, publish each of the tracks to the room. That would look a bit like this:

navigator.mediaDevices.getUserMedia({ audio: true, video: true })
  .then(stream => {
    stream.getTracks().forEach(track => {
      room.localParticipant.publishTrack(track);
    })
  });

The above code should be run in a closure that has access to the currently active room object.

There is an example of this in my blog post about screen sharing with Twilio Video. It isn't adding video and audio after, but adding a second video stream of the user's desktop. The code there should show a bit more context.

Does that help at all?

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thank you for the detailed answer. One question though, will that mean that the usage meter will activate despite there being no video or audio feed at the moment a connection is made in the hallway area? – Frisbetarian-Support Palestine Jul 16 '19 at 13:54
  • 1
    When a user is connected to a room they will trigger usage regardless of the media they are sending. They are still receiving a stream from the room too. – philnash Jul 17 '19 at 00:25
  • Oh alright. I'll have to roll my own presence system in the hallway area then as participants could stay in the hallway for an undetermined amount of time which will mean useless usage of a paid stream. – Frisbetarian-Support Palestine Jul 17 '19 at 11:38
  • Sounds right if it could be a bunch of users, the maximum size of a room is 50 anyway. – philnash Jul 17 '19 at 11:42