Fix bug in code to skip error items on Android.
This commit is contained in:
parent
d6e14ae9d6
commit
e977949d46
|
@ -248,14 +248,12 @@ public class AudioPlayer implements MethodCallHandler, Player.EventListener, Met
|
||||||
}
|
}
|
||||||
sendError(String.valueOf(error.type), error.getMessage());
|
sendError(String.valueOf(error.type), error.getMessage());
|
||||||
errorCount++;
|
errorCount++;
|
||||||
if (player.hasNext()) {
|
if (player.hasNext() && currentIndex != null && errorCount <= 5) {
|
||||||
if (errorCount <= 5) {
|
|
||||||
int nextIndex = currentIndex + 1;
|
int nextIndex = currentIndex + 1;
|
||||||
player.prepare(mediaSource);
|
player.prepare(mediaSource);
|
||||||
player.seekTo(nextIndex, 0);
|
player.seekTo(nextIndex, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSeekProcessed() {
|
public void onSeekProcessed() {
|
||||||
|
|
|
@ -71,7 +71,7 @@ class _MyAppState extends State<MyApp> {
|
||||||
await _player.load(_playlist);
|
await _player.load(_playlist);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// catch load errors: 404, invalid url ...
|
// catch load errors: 404, invalid url ...
|
||||||
print("An error occured (${e.code}): ${e.message}");
|
print("An error occured $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -598,6 +598,9 @@ class PlayerException {
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
PlayerException(this.code, this.message);
|
PlayerException(this.code, this.message);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => "($code) $message";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that occurs when one operation on the player has been interrupted
|
/// An error that occurs when one operation on the player has been interrupted
|
||||||
|
@ -606,6 +609,9 @@ class PlayerInterruptedException {
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
PlayerInterruptedException(this.message);
|
PlayerInterruptedException(this.message);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => "$message";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encapsulates the playback state and current position of the player.
|
/// Encapsulates the playback state and current position of the player.
|
||||||
|
|
Loading…
Reference in New Issue