Skip items in playlist with error on Android.

This commit is contained in:
Ryan Heise 2020-08-07 22:50:36 +10:00
parent 0524d4302b
commit f266ce0b7a
1 changed files with 10 additions and 0 deletions

View File

@ -74,6 +74,7 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
private Map<String, MediaSource> mediaSources = new HashMap<String, MediaSource>(); private Map<String, MediaSource> mediaSources = new HashMap<String, MediaSource>();
private IcyInfo icyInfo; private IcyInfo icyInfo;
private IcyHeaders icyHeaders; private IcyHeaders icyHeaders;
private int errorCount;
private SimpleExoPlayer player; private SimpleExoPlayer player;
private MediaSource mediaSource; private MediaSource mediaSource;
@ -246,6 +247,14 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
Log.e(TAG, "default: " + error.getUnexpectedException().getMessage()); Log.e(TAG, "default: " + error.getUnexpectedException().getMessage());
} }
sendError(String.valueOf(error.type), error.getMessage()); sendError(String.valueOf(error.type), error.getMessage());
errorCount++;
if (player.hasNext()) {
if (errorCount <= 5) {
int nextIndex = currentIndex + 1;
player.prepare(mediaSource);
player.seekTo(nextIndex, 0);
}
}
} }
@Override @Override
@ -505,6 +514,7 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
player.stop(); player.stop();
break; break;
} }
errorCount = 0;
prepareResult = result; prepareResult = result;
transition(ProcessingState.loading); transition(ProcessingState.loading);
if (player.getShuffleModeEnabled()) { if (player.getShuffleModeEnabled()) {