Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

LiveEventListener(Kotlin)

Ray edited this page Aug 1, 2021 · 3 revisions

Overview

LiveEventListener can observing the change of properties related with a live event.

If you haven't read MediaCore(Kotlin), please read it first.

Create LiveEventListener

  • Use straasCore.createLiveEventListener to create a LiveEventListener:
val liveEventListener = StraasCore.getInstance(context).createLiveEventListener(StraasMember.GUEST)

Start

Start and pass specified live event id to start observing this properties

lifecycleScope.launch {
    liveEventListener.start(liveId)
}

Observing properties

After start, you can start to get or observe properties in LiveEventListener

val broadcastStateV2 = liveEventListener.broadcastStateV2.value
// handle broadcastStateV2
lifecycleScope.launch {
    liveEventListener.broadcastStateV2.collect { broadcastStateV2 -> 
        // handle new broadcastStateV2
    }
}

Stop

If you don't need to observe these properties anymore, remember to call stop to disconnect from server and save the resources.

liveEventListener.stop()

Clone this wiki locally