pull/586/head
FongMi 2 years ago
parent bcead90768
commit e68bb3e8f9
  1. 9
      app/src/main/java/com/fongmi/android/tv/player/Players.java
  2. 8
      app/src/main/java/com/fongmi/android/tv/player/exo/ExoUtil.java

@ -78,7 +78,6 @@ public class Players implements Player.Listener, ParseCallback {
private long position;
private int decode;
private int error;
private int retry;
public static Players create(Activity activity) {
@ -157,7 +156,6 @@ public class Players implements Player.Listener, ParseCallback {
position = C.TIME_UNSET;
removeTimeoutCheck();
stopParse();
error = 0;
retry = 0;
}
@ -198,7 +196,7 @@ public class Players implements Player.Listener, ParseCallback {
}
public boolean retried() {
return ++retry > ExoUtil.getRetry(error);
return ++retry > 2;
}
public boolean canAdjustSpeed() {
@ -406,10 +404,10 @@ public class Players implements Player.Listener, ParseCallback {
private void setMediaItem(Map<String, String> headers, String url, String format, Drm drm, List<Sub> subs, int timeout) {
if (exoPlayer != null) exoPlayer.setMediaItem(ExoUtil.getMediaItem(this.headers = checkUa(headers), UrlUtil.uri(this.url = url), this.format = format, this.drm = drm, checkSub(this.subs = subs), decode), position);
if (exoPlayer != null) exoPlayer.prepare();
Logger.t(TAG).d(error + "," + url);
App.post(runnable, timeout);
session.setActive(true);
PlayerEvent.prepare();
Logger.t(TAG).d(url);
}
private void removeTimeoutCheck() {
@ -532,7 +530,8 @@ public class Players implements Player.Listener, ParseCallback {
@Override
public void onPlayerError(@NonNull PlaybackException error) {
setPlaybackState(PlaybackStateCompat.STATE_ERROR);
ErrorEvent.url(this.error = error.errorCode);
Logger.t(TAG).e(error.errorCode + "," + url);
ErrorEvent.url(error.errorCode);
}
@Override

@ -95,14 +95,6 @@ public class ExoUtil {
return null;
}
public static int getRetry(int errorCode) {
if (errorCode == PlaybackException.ERROR_CODE_IO_UNSPECIFIED) return 2;
if (errorCode == PlaybackException.ERROR_CODE_DECODER_INIT_FAILED) return 2;
if (errorCode >= PlaybackException.ERROR_CODE_DECODER_QUERY_FAILED && errorCode <= PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED) return 2;
if (errorCode >= PlaybackException.ERROR_CODE_PARSING_CONTAINER_MALFORMED && errorCode <= PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED) return 2;
return 1;
}
public static MediaItem getMediaItem(Map<String, String> headers, Uri uri, String mimeType, Drm drm, List<Sub> subs, int decode) {
MediaItem.Builder builder = new MediaItem.Builder().setUri(uri);
builder.setAllowChunklessPreparation(Players.isHard(decode));

Loading…
Cancel
Save