/* * Called when participant joins the room */ private void addParticipant(Participant participant) { /* * This app only displays video for one additional participant per Room */ if (thumbnailVideoView.getVisibility() == View.VISIBLE) { Snackbar.make( connectActionFab, "Multiple participants are not currently support in this UI", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); return; } participantIdentity = participant.getIdentity(); videoStatusTextView.setText("Participant " + participantIdentity + " joined"); /* * Stop rendering local video track in primary view and move it to thumbnail view */ localVideoTrack.removeRenderer(primaryVideoView); thumbnailVideoView.setVisibility(View.VISIBLE); localVideoTrack.addRenderer(thumbnailVideoView); localVideoView = thumbnailVideoView; /* * Start listening for participant media events */ participant.getMedia().setListener(mediaListener()); }
/* * Called when participant leaves the room */ private void removeParticipant(Participant participant) { videoStatusTextView.setText("Participant " + participant.getIdentity() + " left."); if (!participant.getIdentity().equals(participantIdentity)) { return; } /* * Show local video in primary view */ thumbnailVideoView.setVisibility(View.GONE); localVideoTrack.removeRenderer(thumbnailVideoView); primaryVideoView.setMirror(true); localVideoTrack.addRenderer(primaryVideoView); localVideoView = primaryVideoView; }
private void createLocalMedia() { localMedia = LocalMedia.create(this); // Share your microphone localAudioTrack = localMedia.addAudioTrack(true); // Share your camera cameraCapturer = new CameraCapturer(this, CameraSource.FRONT_CAMERA); localVideoTrack = localMedia.addVideoTrack(true, cameraCapturer); primaryVideoView.setMirror(true); localVideoTrack.addRenderer(primaryVideoView); localVideoView = primaryVideoView; }