Skip to main content
Version: 3.x.x

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 RoomEventListener and register the listener with room.addEventListener().
  • startLivestream() returns before the livestream has started. Wait for LIVESTREAM_STARTED in this event.
  • state is a LiveStreamState: LIVESTREAM_STARTING, LIVESTREAM_STARTED, LIVESTREAM_STOPPING or LIVESTREAM_STOPPED. Compare it with these values, not with strings. A state outside them is not delivered.
  • room.liveStreamState holds the latest one. It is LIVESTREAM_STOPPED until 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