2019-09-16 16:29:31 -04:00
|
|
|
package com.brentvatne.exoplayer;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
|
|
|
|
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
|
|
|
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
|
|
|
|
|
|
|
|
public class DefaultReactExoplayerConfig implements ReactExoplayerConfig {
|
|
|
|
|
|
|
|
private final DefaultBandwidthMeter bandwidthMeter;
|
2021-05-17 13:09:09 +03:00
|
|
|
private boolean disableDisconnectError = false;
|
2019-09-16 16:29:31 -04:00
|
|
|
|
|
|
|
public DefaultReactExoplayerConfig(Context context) {
|
|
|
|
this.bandwidthMeter = new DefaultBandwidthMeter.Builder(context).build();
|
|
|
|
}
|
|
|
|
|
|
|
|
public LoadErrorHandlingPolicy buildLoadErrorHandlingPolicy(int minLoadRetryCount) {
|
2021-05-17 13:09:09 +03:00
|
|
|
if (this.disableDisconnectError) {
|
|
|
|
// Use custom error handling policy to prevent throwing an error when losing network connection
|
|
|
|
return new ReactExoplayerLoadErrorHandlingPolicy(minLoadRetryCount);
|
|
|
|
}
|
2019-09-16 16:29:31 -04:00
|
|
|
return new DefaultLoadErrorHandlingPolicy(minLoadRetryCount);
|
|
|
|
}
|
|
|
|
|
2021-05-17 13:09:09 +03:00
|
|
|
public void setDisableDisconnectError(boolean disableDisconnectError) {
|
|
|
|
this.disableDisconnectError = disableDisconnectError;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean getDisableDisconnectError() {
|
|
|
|
return this.disableDisconnectError;
|
|
|
|
}
|
|
|
|
|
2019-09-16 16:29:31 -04:00
|
|
|
@Override
|
|
|
|
public DefaultBandwidthMeter getBandwidthMeter() {
|
|
|
|
return bandwidthMeter;
|
|
|
|
}
|
|
|
|
}
|