From dfc3e83e79cd246557704bcdd377d2da3f7cfa82 Mon Sep 17 00:00:00 2001 From: Arthur Geron Date: Mon, 28 Aug 2023 11:45:11 -0300 Subject: [PATCH] feat: replaced deprecated event emitter --- .../ivs/reactnative/player/AmazonIvsView.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsView.kt b/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsView.kt index de59148..9845cb7 100644 --- a/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsView.kt +++ b/android/src/main/java/com/amazonaws/ivs/reactnative/player/AmazonIvsView.kt @@ -11,7 +11,7 @@ import com.facebook.react.bridge.LifecycleEventListener import com.facebook.react.bridge.ReactContext import com.facebook.react.bridge.ReadableMap import com.facebook.react.uimanager.ThemedReactContext -import com.facebook.react.uimanager.events.RCTEventEmitter +import com.facebook.react.uimanager.events.RCTModernEventEmitter import java.util.* import java.util.concurrent.TimeUnit import kotlin.concurrent.timerTask @@ -123,7 +123,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte finishedLoading = false player.load(uri) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.LOAD_START.toString(), Arguments.createMap()) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.LOAD_START.toString(), Arguments.createMap()) } } @@ -215,7 +215,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte val data = Arguments.createMap() data.putMap("textCue", textCue) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.CUE.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.CUE.toString(), data) } fun setMaxBitrate(bitrate: Double) { @@ -239,7 +239,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte val data = Arguments.createMap() data.putMap("textMetadataCue", textMetadataCue) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.METADATA_CUE.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.METADATA_CUE.toString(), data) } fun onDurationChange(duration: Long) { @@ -248,7 +248,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte val parsedDuration = getDuration(duration); data.putDouble("duration", parsedDuration) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.DURATION_CHANGED.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.DURATION_CHANGED.toString(), data) } fun onError(error: String) { @@ -256,21 +256,21 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte val data = Arguments.createMap() data.putString("error", error) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.ERROR.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.ERROR.toString(), data) } fun onSeek(position: Long) { val reactContext = context as ReactContext val data = Arguments.createMap() data.putDouble("position", convertMilliSecondsToSeconds(position)) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.SEEK.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.SEEK.toString(), data) } fun onProgress(position: Long) { val reactContext = context as ReactContext val data = Arguments.createMap() data.putDouble("position", convertMilliSecondsToSeconds(position)) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.PROGRESS.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.PROGRESS.toString(), data) } private fun convertMilliSecondsToSeconds (milliSeconds: Long): Double { @@ -314,7 +314,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte finishedLoading = true - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.LOAD.toString(), onLoadData) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.LOAD.toString(), onLoadData) } } READY -> { @@ -337,7 +337,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte playerData.putArray("qualities", qualities) data.putMap("playerData", playerData) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.DATA.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.DATA.toString(), data) }; BUFFERING -> {} // The following empty statements are intentional and avoid Kotlin’s "expression must be exhaustive" error. IDLE -> {} @@ -346,7 +346,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte val onStateChangeData = Arguments.createMap() onStateChangeData.putString("state", mapPlayerState(state)) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.STATE_CHANGED.toString(), onStateChangeData) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.STATE_CHANGED.toString(), onStateChangeData) } fun onQualityChange(quality: Quality) { @@ -363,12 +363,12 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte val data = Arguments.createMap() data.putMap("quality", newQuality) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.QUALITY_CHANGED.toString(), data) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.QUALITY_CHANGED.toString(), data) } fun onPlayerRebuffering() { val reactContext = context as ReactContext - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.REBUFFERING.toString(), Arguments.createMap()) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.REBUFFERING.toString(), Arguments.createMap()) } private fun intervalHandler() { @@ -382,7 +382,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte } ?: run { liveLatencyData.putNull("liveLatency") } - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.LIVE_LATENCY_CHANGED.toString(), liveLatencyData) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.LIVE_LATENCY_CHANGED.toString(), liveLatencyData) lastLiveLatency = player?.liveLatency } @@ -406,7 +406,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte } onVideoData.putMap("videoData", videoData) - reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.VIDEO_STATISTICS.toString(), onVideoData) + reactContext.getJSModule(RCTModernEventEmitter::class.java).receiveEvent(id, Events.VIDEO_STATISTICS.toString(), onVideoData) lastBitrate = player?.averageBitrate lastDuration = player?.duration