Join Live Stream - Android
Once, the live stream is configured, the next step is to join it. If you have not initialized the live stream yet, you can follow the guide here.
join()
- To join the live stream you can call the
join()
method which is the part of theMeeting
class of Android SDK. - This method can be called after the live stream is initialized from the
VideoSdk class
.
Events associated with Join
Following callbacks are received when a participant is successfully joined.
- Local Participant will receive a
onMeetingJoined
event, when successfully joined. - Remote Participant will receive a
onParticipantJoined
event with the newly joinedParticipant
object from the event callback.
- Kotlin
- Java
class LiveStreamActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_live_stream);
// initialize the meeting
liveStream = VideoSDK.initMeeting(... )
...
// join meeting
meeting!!.join()
// Add event listener for listening upcoming events of live stream
meeting!!.addEventListener(meetingEventListener)
}
private val meetingEventListener: MeetingEventListener = object : MeetingEventListener(){
//Event to determine if the live stream has been joined
fun onMeetingJoined() {
Log.d("VideoSDK", "onMeetingJoined")
}
/ //Event to determine some other participant has joined
fun onParticipantJoined(participant: Participant) {
Log.d("#VideoSDK", participant.displayName + " joined");
}
}
}
public class LiveStreamActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_live_stream);
// initialize the meeting
Meeting liveStream = VideoSDK.initMeeting( ...);
...
// join meeting
meeting.join();
// Add event listener for listening upcoming events of live stream
meeting.addEventListener(meetingEventListener);
}
private final MeetingEventListener meetingEventListener=new MeetingEventListener() {
//Event to determine if the live stream has been joined
@Override
public void onMeetingJoined() {
Log.d("VideoSDK", "onMeetingJoined");
}
/ //Event to determine some other participant has joined
@Override
public void onParticipantJoined(Participant participant) {
Log.d("#VideoSDK", participant.getDisplayName() + " joined");
}
};
}
leave()
- To leave the live stream you can call the
leave()
method which is the part of theMeeting
class of Flutter SDK.
note
This method can be called only after the live stream is joined successfully.
Events associated with the leave() method
Following callbacks are received when a participant leaves the live stream.
- The Local Participant will receive the
onMeetingLeft
event, once they have successfully left the livestream. - All the Remote Participants—including all the hosts and audience members—will receive the
onParticipantLeft
event with theParticipant
object of the user who left the livestream.
- Kotlin
- Java
private final MeetingEventListener meetingEventListener = new MeetingEventListener() {
//Event to determine if the live stream has been left
override fun onMeetingLeft() {
Log.d("#VideoSDK", "onMeetingleft()")
}
//Event to determine some other participant has left
override fun onParticipantLeft(participant: Participant) {
Log.d("#VideoSDK", participant.displayName + " left");
}
}
private final MeetingEventListener meetingEventListener = new MeetingEventListener() {
//Event to determine if the live stream has been left
@Override
public void onMeetingLeft() {
Log.d("#VideoSDK", "onMeetingleft()")
}
//Event to determine some other participant has left
@Override
public void onParticipantLeft(Participant participant) {
Log.d("#VideoSDK", participant.getDisplayName() + " left");
}
}
tip
You should call the leave()
method on the unmount of your main live stream component so that live stream is left once the view is unmounted.
API Reference
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord