Use player.retry in demo app instead of manual position tracking.

We currently do manual position tracking while the player is in error mode.
This is to allow an initial seek to the new position when trying to re-prepare.

Instead, we can just use our player.retry method and remove the tracking code.

PiperOrigin-RevId: 243819580
This commit is contained in:
tonihei 2019-04-16 17:16:00 +01:00 committed by Andrew Lewis
parent 8e7a2ba958
commit e62da368d2

View File

@ -311,7 +311,7 @@ public class PlayerActivity extends AppCompatActivity
@Override
public void preparePlayback() {
initializePlayer();
player.retry();
}
// PlaybackControlView.VisibilityListener implementation
@ -641,22 +641,12 @@ public class PlayerActivity extends AppCompatActivity
updateButtonVisibility();
}
@Override
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
if (player.getPlaybackError() != null) {
// The user has performed a seek whilst in the error state. Update the resume position so
// that if the user then retries, playback resumes from the position to which they seeked.
updateStartPosition();
}
}
@Override
public void onPlayerError(ExoPlaybackException e) {
if (isBehindLiveWindow(e)) {
clearStartPosition();
initializePlayer();
} else {
updateStartPosition();
updateButtonVisibility();
showControls();
}