refactor(android): migrate ReactExoplayerConfig to Kotlin (#3994)

* Rename .java to .kt

* refactor(android): migrate ReactExoplayerConfig to Kotlin
This commit is contained in:
Seyed Mostafa Hasani 2024-07-15 13:28:07 +03:30 committed by GitHub
parent 4e7c64e707
commit df9ffde5fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 25 deletions

View File

@ -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
}

View File

@ -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();
}

View File

@ -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
}