Skip to content

Twilio Programmable Video – Disabled videos for certain participants, camera permission is still requested

I am implementing a seminar application with twilio programmable video. The scenario can be described as following:

1 host lectures n participants. The participants can participate only via audio but can see the hosts video. I accomplished that by simply unpublishing and disabling the videostreams of the participants:

import Video, {
  LocalAudioTrackPublication,
  LocalVideoTrackPublication,
  Participant,
} from 'twilio-video';
...

if (room && room.localParticipant && !props.isHost) {
   room.localParticipant.videoTracks.forEach(
    (publication: LocalVideoTrackPublication) => {
       publication.track.disable();
       publication.unpublish();
    }
  );
}

The problem is, that the participants, although not publishing any video, are still asked to grant the permission for their cameras and if they deny it, the video of the host is not shown anymore either.

Is there any way to get rid of the video permission request?

Answer

Twilio developer evangelist here.

Rather than asking for access to the video and then disabling it afterwards, you should not ask for camera access in the first place.

You can achieve this by changing the media constraints you send in to the connect method like this:

Video.connect(token, {
  audio: true,
  video: false
})

This will only ask for microphone permissions and will only publish an audio track for the participant.