Reputation: 2631
I'm using the Twilio Android Library and I'm having trouble getting the Video Streams of the partipants already in that room when you join it. Someone please help I've been trying for a couple of hours.
return new Room.Listener() {
@Override
public void onConnected(Room room) {
Log.d(TAG, "Room Listener Connected to " + room.getName());
}
After connection into a room, this method is called, I don't know how to get the VideoTracks of the other participants.
Upvotes: 0
Views: 149
Reputation: 1561
Once your room is connected successfully then you have to find the remote participants from the room and attach the RemoteParticipant.Listener
for each participant in the room.
To get the participants from the room :
override fun onConnected(room: Room) {
for (remoteParticipant in room.remoteParticipants) {
addRemoteParticipant(remoteParticipant)
}
}
To set the listener with the remote participants.
private fun addRemoteParticipant(remoteParticipant: RemoteParticipant) {
remoteParticipantIdentity = remoteParticipant.identity
remoteParticipant.setListener(remoteParticipantListener())
}
After that you have to implement the methods to get the audio and video track of the participant.
private fun remoteParticipantListener(): RemoteParticipant.Listener {
return object : RemoteParticipant.Listener {
override fun onAudioTrackPublished(remoteParticipant:RemoteParticipant,remoteAudioTrackPublication: RemoteAudioTrackPublication) {
}
override fun onAudioTrackUnpublished(remoteParticipant: RemoteParticipant,remoteAudioTrackPublication: RemoteAudioTrackPublication) {
}
override fun onDataTrackPublished(remoteParticipant: RemoteParticipant,remoteDataTrackPublication: RemoteDataTrackPublication) {
}
override fun onDataTrackUnpublished(remoteParticipant: RemoteParticipant,
remoteDataTrackPublication: RemoteDataTrackPublication) {
}
override fun onVideoTrackPublished(remoteParticipant: RemoteParticipant,remoteVideoTrackPublication: RemoteVideoTrackPublication) {}
override fun onVideoTrackUnpublished(remoteParticipant: RemoteParticipant, remoteVideoTrackPublication: RemoteVideoTrackPublication) {}
override fun onAudioTrackSubscribed(remoteParticipant: RemoteParticipant,remoteAudioTrackPublication: RemoteAudioTrackPublication,remoteAudioTrack: RemoteAudioTrack) {}
override fun onAudioTrackUnsubscribed(remoteParticipant: RemoteParticipant,
remoteAudioTrackPublication: RemoteAudioTrackPublication, remoteAudioTrack: RemoteAudioTrack) {}
override fun onAudioTrackSubscriptionFailed(remoteParticipant: RemoteParticipant,
remoteAudioTrackPublication: RemoteAudioTrackPublication, twilioException: TwilioException) { }
override fun onDataTrackSubscribed(remoteParticipant: RemoteParticipant,remoteDataTrackPublication: RemoteDataTrackPublication,remoteDataTrack: RemoteDataTrack) {}
override fun onDataTrackUnsubscribed(remoteParticipant: RemoteParticipant,remoteDataTrackPublication: RemoteDataTrackPublication, remoteDataTrack: RemoteDataTrack) {}
override fun onDataTrackSubscriptionFailed(remoteParticipant: RemoteParticipant,remoteDataTrackPublication: RemoteDataTrackPublication,twilioException: TwilioException) {}
override fun onVideoTrackSubscribed(remoteParticipant: RemoteParticipant, remoteVideoTrackPublication: RemoteVideoTrackPublication, remoteVideoTrack: RemoteVideoTrack) {}
override fun onVideoTrackUnsubscribed(remoteParticipant: RemoteParticipant, remoteVideoTrackPublication: RemoteVideoTrackPublication,remoteVideoTrack: RemoteVideoTrack) {}
override fun onVideoTrackSubscriptionFailed(remoteParticipant: RemoteParticipant,
remoteVideoTrackPublication: RemoteVideoTrackPublication, twilioException: TwilioException){}
override fun onAudioTrackEnabled(remoteParticipant: RemoteParticipant,
remoteAudioTrackPublication: RemoteAudioTrackPublication) {}
override fun onAudioTrackDisabled(remoteParticipant: RemoteParticipant,
remoteAudioTrackPublication: RemoteAudioTrackPublication) {}
override fun onVideoTrackEnabled(remoteParticipant: RemoteParticipant,
remoteVideoTrackPublication: RemoteVideoTrackPublication) {}
override fun onVideoTrackDisabled(remoteParticipant: RemoteParticipant,remoteVideoTrackPublication: RemoteVideoTrackPublication) {}
}
}
Upvotes: 2