react-native-video/android/src/main/java/com/brentvatne/exoplayer/DefaultReactExoplayerConfig.java
YangJH f2e80e9f2d
feat(android): replace deprecated ExoPlayer2 with AndroidX media3 (#3337)
* feat(android): implement AndroidX media3 dependencies
* refactor(android): remove duplicate code
* refactor(android): remove unused codes
* feat(android): replace ExoPlayer2 with AndroidX media3
* fix(android): move default properties to gradle.properties
* revert(android): prevent security exception
* chore: align indent
* chore: remove redundant comments
* chore: reorder import
* fix: apply media3's legacy player control view
2023-11-18 14:13:54 +01:00

39 lines
1.3 KiB
Java

package com.brentvatne.exoplayer;
import android.content.Context;
import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter;
import androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy;
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy;
public class DefaultReactExoplayerConfig implements ReactExoplayerConfig {
private final DefaultBandwidthMeter bandwidthMeter;
private boolean disableDisconnectError = false;
public DefaultReactExoplayerConfig(Context context) {
this.bandwidthMeter = new DefaultBandwidthMeter.Builder(context).build();
}
public LoadErrorHandlingPolicy buildLoadErrorHandlingPolicy(int minLoadRetryCount) {
if (this.disableDisconnectError) {
// Use custom error handling policy to prevent throwing an error when losing network connection
return new ReactExoplayerLoadErrorHandlingPolicy(minLoadRetryCount);
}
return new DefaultLoadErrorHandlingPolicy(minLoadRetryCount);
}
public void setDisableDisconnectError(boolean disableDisconnectError) {
this.disableDisconnectError = disableDisconnectError;
}
public boolean getDisableDisconnectError() {
return this.disableDisconnectError;
}
@Override
public DefaultBandwidthMeter getBandwidthMeter() {
return bandwidthMeter;
}
}