@@ -4,6 +4,7 @@ import com.facebook.react.bridge.Arguments
44import com.facebook.react.bridge.WritableMap
55import com.theoplayer.android.api.event.EventListener
66import com.theoplayer.android.api.event.player.theolive.DistributionLoadStartEvent
7+ import com.theoplayer.android.api.event.player.theolive.DistributionLoadedEvent
78import com.theoplayer.android.api.event.player.theolive.DistributionOfflineEvent
89import com.theoplayer.android.api.event.player.theolive.EndpointLoadedEvent
910import com.theoplayer.android.api.event.player.theolive.IntentToFallbackEvent
@@ -13,8 +14,11 @@ import com.theoplayer.util.PayloadBuilder
1314
1415private const val EVENT_PROP_TYPE = " type"
1516private const val EVENT_PROP_DISTRIBUTION_ID = " distributionId"
17+ private const val EVENT_PROP_DISTRIBUTION = " distribution"
1618private const val EVENT_PROP_ENDPOINT = " endpoint"
1719private const val EVENT_PROP_REASON = " reason"
20+ private const val EVENT_PROP_NAME = " name"
21+ private const val EVENT_PROP_ID = " id"
1822
1923class THEOliveEventAdapter (private val theoLiveApi : TheoLive , private val emitter : Emitter ) {
2024
@@ -24,6 +28,8 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte
2428
2529 private val onDistributionLoadStart =
2630 EventListener <DistributionLoadStartEvent > { onDistributionLoadStart(it) }
31+ private val onDistributionLoaded =
32+ EventListener <DistributionLoadedEvent > { onDistributionLoaded(it) }
2733 private val onDistributionOffline =
2834 EventListener <DistributionOfflineEvent > { onDistributionOffline(it) }
2935 private val onEndPointLoaded =
@@ -33,6 +39,7 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte
3339
3440 init {
3541 theoLiveApi.addEventListener(TheoLiveEventTypes .DISTRIBUTIONLOADSTART , onDistributionLoadStart)
42+ theoLiveApi.addEventListener(TheoLiveEventTypes .DISTRIBUTIONLOADED , onDistributionLoaded)
3643 theoLiveApi.addEventListener(TheoLiveEventTypes .DISTRIBUTIONOFFLINE , onDistributionOffline)
3744 theoLiveApi.addEventListener(TheoLiveEventTypes .ENDPOINTLOADED , onEndPointLoaded)
3845 theoLiveApi.addEventListener(TheoLiveEventTypes .INTENTTOFALLBACK , onIntentOfFallback)
@@ -43,6 +50,7 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte
4350 TheoLiveEventTypes .DISTRIBUTIONLOADSTART ,
4451 onDistributionLoadStart
4552 )
53+ theoLiveApi.removeEventListener(TheoLiveEventTypes .DISTRIBUTIONLOADED , onDistributionLoaded)
4654 theoLiveApi.removeEventListener(TheoLiveEventTypes .DISTRIBUTIONOFFLINE , onDistributionOffline)
4755 theoLiveApi.removeEventListener(TheoLiveEventTypes .ENDPOINTLOADED , onEndPointLoaded)
4856 theoLiveApi.removeEventListener(TheoLiveEventTypes .INTENTTOFALLBACK , onIntentOfFallback)
@@ -55,6 +63,16 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte
5563 })
5664 }
5765
66+ private fun onDistributionLoaded (event : DistributionLoadedEvent ) {
67+ emitter.emit(Arguments .createMap().apply {
68+ putString(EVENT_PROP_TYPE , " distributionloaded" )
69+ putMap(EVENT_PROP_DISTRIBUTION , Arguments .createMap().apply {
70+ putString(EVENT_PROP_ID , event.getDistribution().id)
71+ putString(EVENT_PROP_NAME , event.getDistribution().name)
72+ })
73+ })
74+ }
75+
5876 private fun onDistributionOffline (event : DistributionOfflineEvent ) {
5977 emitter.emit(Arguments .createMap().apply {
6078 putString(EVENT_PROP_TYPE , " distributionoffline" )
0 commit comments