From 7ee8567f4a80b2ec9018cb0761fca41ac9ff9c9e Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Mon, 30 Jan 2017 07:00:28 -0800 Subject: [PATCH] Fix demo app to avoid seeking if resume position is clear This fixed the resume live window issue by modifying the demo app. Issue:#2344 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=145987470 --- .../google/android/exoplayer2/demo/PlayerActivity.java | 9 ++++++--- .../com/google/android/exoplayer2/SimpleExoPlayer.java | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 9add658d301..66ad2aebf10 100644 --- a/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -317,8 +317,11 @@ private void initializePlayer() { } MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0] : new ConcatenatingMediaSource(mediaSources); - player.seekTo(resumeWindow, resumePosition); - player.prepare(mediaSource, false, false); + boolean haveResumePosition = resumeWindow != C.INDEX_UNSET; + if (haveResumePosition) { + player.seekTo(resumeWindow, resumePosition); + } + player.prepare(mediaSource, !haveResumePosition, !haveResumePosition); playerNeedsSource = false; updateButtonVisibilities(); } @@ -377,7 +380,7 @@ private void updateResumePosition() { } private void clearResumePosition() { - resumeWindow = 0; + resumeWindow = C.INDEX_UNSET; resumePosition = C.TIME_UNSET; } diff --git a/library/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java index da9417374e4..298e5282466 100644 --- a/library/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java +++ b/library/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java @@ -479,8 +479,8 @@ public void prepare(MediaSource mediaSource) { } @Override - public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetTimeline) { - player.prepare(mediaSource, resetPosition, resetTimeline); + public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) { + player.prepare(mediaSource, resetPosition, resetState); } @Override