Skip to content

Instantly share code, notes, and snippets.

@abbas-oveissi
Created March 25, 2020 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abbas-oveissi/ffb79318083a7b57dbaedc32e27d97d3 to your computer and use it in GitHub Desktop.
Save abbas-oveissi/ffb79318083a7b57dbaedc32e27d97d3 to your computer and use it in GitHub Desktop.
private void connectToRoom(String roomName) {
configureAudio(true);
ConnectOptions.Builder connectOptionsBuilder = new ConnectOptions.Builder(accessToken)
.roomName(roomName);
/*
* Add local audio track to connect options to share with participants.
*/
if (localAudioTrack != null) {
connectOptionsBuilder
.audioTracks(Collections.singletonList(localAudioTrack));
}
/*
* Add local video track to connect options to share with participants.
*/
if (localVideoTrack != null) {
connectOptionsBuilder.videoTracks(Collections.singletonList(localVideoTrack));
}
/*
* Set the preferred audio and video codec for media.
*/
connectOptionsBuilder.preferAudioCodecs(Collections.singletonList(audioCodec));
connectOptionsBuilder.preferVideoCodecs(Collections.singletonList(videoCodec));
/*
* Set the sender side encoding parameters.
*/
encodingParameters = getEncodingParameters();
connectOptionsBuilder.encodingParameters(encodingParameters);
/*
* Toggles automatic track subscription. If set to false, the LocalParticipant will receive
* notifications of track publish events, but will not automatically subscribe to them. If
* set to true, the LocalParticipant will automatically subscribe to tracks as they are
* published. If unset, the default is true. Note: This feature is only available for Group
* Rooms. Toggling the flag in a P2P room does not modify subscription behavior.
*/
connectOptionsBuilder.enableAutomaticSubscription(true);
room = Video.connect(getContext(), connectOptionsBuilder.build(), roomListener());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment