RTMP Events - Android
The onLivestreamStateChanged event tells you the current state of the livestream for the room.
onLivestreamStateChanged
- This event will be triggered when the room's livestream status changes.
- Override it in a
RoomEventListenerand register the listener withroom.addEventListener(). startLivestream()returns before the livestream has started. Wait forLIVESTREAM_STARTEDin this event.stateis aLiveStreamState:LIVESTREAM_STARTING,LIVESTREAM_STARTED,LIVESTREAM_STOPPINGorLIVESTREAM_STOPPED. Compare it with these values, not with strings. A state outside them is not delivered.room.liveStreamStateholds the latest one. It isLIVESTREAM_STOPPEDuntil the first event, and is reset when the room is left.
Example
Here is the usage of the event mentioned in this page.
private val roomEventListener: RoomEventListener = object : RoomEventListener() {
override fun onLivestreamStateChanged(state: LiveStreamState) {
when (state) {
LiveStreamState.LIVESTREAM_STARTING -> Log.d( "LivestreamStateChanged",
"Room livestream is starting"
)
LiveStreamState.LIVESTREAM_STARTED -> Log.d( "LivestreamStateChanged",
"Room livestream is started"
)
LiveStreamState.LIVESTREAM_STOPPING -> Log.d("LivestreamStateChanged",
"Room livestream is stopping"
)
LiveStreamState.LIVESTREAM_STOPPED -> Log.d("LivestreamStateChanged",
"Room livestream is stopped"
)
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
//...
// add listener to room
room!!.addEventListener(roomEventListener)
}
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord

