More gracefully recover from streaming playback errors in

ExoPlayerWrapper.
This commit is contained in:
casey langen 2017-05-21 23:10:53 -07:00
parent ba62116a16
commit 24bf49408d
2 changed files with 17 additions and 4 deletions

View File

@ -163,9 +163,18 @@ public class ExoPlayerWrapper extends PlayerWrapper {
public void resume() {
Preconditions.throwIfNotOnMainThread();
if (this.getState() == State.Paused || this.getState() == State.Prepared) {
this.player.setPlayWhenReady(true);
setState(State.Playing);
switch (this.getState()) {
case Paused:
case Prepared:
this.player.setPlayWhenReady(true);
setState(State.Playing);
break;
case Error:
this.player.setPlayWhenReady(true);
this.player.prepare(this.source);
setState(State.Preparing);
break;
}
this.prefetch = false;
@ -294,6 +303,10 @@ public class ExoPlayerWrapper extends PlayerWrapper {
dispose();
return;
}
else {
player.setPlayWhenReady(false);
setPosition(0);
}
}
}
@ -303,7 +316,6 @@ public class ExoPlayerWrapper extends PlayerWrapper {
case Playing:
case Paused:
setState(State.Error);
dispose();
break;
}
}

View File

@ -20,6 +20,7 @@
android:id="@+id/fast_scroller"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:rfs_touchTargetWidth="32dp"
android:paddingLeft="8dp"
android:layout_alignParentRight="true" />