From df9ffde5fae2b65cbc906d922cace0bd8cf0d6ac Mon Sep 17 00:00:00 2001 From: Seyed Mostafa Hasani Date: Mon, 15 Jul 2024 13:28:07 +0330 Subject: [PATCH] refactor(android): migrate ReactExoplayerConfig to Kotlin (#3994) * Rename .java to .kt * refactor(android): migrate ReactExoplayerConfig to Kotlin --- .../exoplayer/DefaultReactExoplayerConfig.kt | 13 ++++--------- .../exoplayer/ReactExoplayerConfig.java | 16 ---------------- .../brentvatne/exoplayer/ReactExoplayerConfig.kt | 10 ++++++++++ 3 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.java create mode 100644 android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.kt diff --git a/android/src/main/java/com/brentvatne/exoplayer/DefaultReactExoplayerConfig.kt b/android/src/main/java/com/brentvatne/exoplayer/DefaultReactExoplayerConfig.kt index ce5d3bfd..12c0ddf8 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/DefaultReactExoplayerConfig.kt +++ b/android/src/main/java/com/brentvatne/exoplayer/DefaultReactExoplayerConfig.kt @@ -8,19 +8,14 @@ import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy class DefaultReactExoplayerConfig(context: Context) : ReactExoplayerConfig { private var bandWidthMeter: DefaultBandwidthMeter = DefaultBandwidthMeter.Builder(context).build() - private var disableDisconnectError: Boolean = false + override var disableDisconnectError: Boolean = false + override val bandwidthMeter: DefaultBandwidthMeter + get() = bandWidthMeter + override fun buildLoadErrorHandlingPolicy(minLoadRetryCount: Int): LoadErrorHandlingPolicy = if (disableDisconnectError) { ReactExoplayerLoadErrorHandlingPolicy(minLoadRetryCount) } else { DefaultLoadErrorHandlingPolicy(minLoadRetryCount) } - - override fun setDisableDisconnectError(disableDisconnectError: Boolean) { - this.disableDisconnectError = disableDisconnectError - } - - override fun getDisableDisconnectError(): Boolean = disableDisconnectError - - override fun getBandwidthMeter(): DefaultBandwidthMeter = bandWidthMeter } diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.java deleted file mode 100644 index 1abb0408..00000000 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.brentvatne.exoplayer; - -import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter; -import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy; - -/** - * Extension points to configure the Exoplayer instance - */ -public interface ReactExoplayerConfig { - LoadErrorHandlingPolicy buildLoadErrorHandlingPolicy(int minLoadRetryCount); - - void setDisableDisconnectError(boolean disableDisconnectError); - boolean getDisableDisconnectError(); - - DefaultBandwidthMeter getBandwidthMeter(); -} diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.kt b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.kt new file mode 100644 index 00000000..6f5e65ba --- /dev/null +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerConfig.kt @@ -0,0 +1,10 @@ +package com.brentvatne.exoplayer + +import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter +import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy + +interface ReactExoplayerConfig { + fun buildLoadErrorHandlingPolicy(minLoadRetryCount: Int): LoadErrorHandlingPolicy + var disableDisconnectError: Boolean + val bandwidthMeter: DefaultBandwidthMeter +}