Skip items in playlist with error on Android.
This commit is contained in:
parent
0524d4302b
commit
f266ce0b7a
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in New Issue