From e62da368d28f6fe2286fafa611397966fad6b83d Mon Sep 17 00:00:00 2001 From: tonihei Date: Tue, 16 Apr 2019 17:16:00 +0100 Subject: [PATCH] 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 --- .../android/exoplayer2/demo/PlayerActivity.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 11df14e3dd..acb24adebe 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -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(); }