From a98d5bbd0a44930d7e179d228d0e662070f0c50e Mon Sep 17 00:00:00 2001 From: tonihei Date: Thu, 29 Jun 2017 05:58:39 -0700 Subject: [PATCH] Do not start rebuffering after playback ended. This is currently happening after toggling the repeat mode. This is line with the rest of the implementation which requires a seek operation to resume playback. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160516449 --- .../android/exoplayer2/ExoPlayerTest.java | 26 +++++-------------- .../exoplayer2/ExoPlayerImplInternal.java | 5 ---- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/library/core/src/androidTest/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/androidTest/java/com/google/android/exoplayer2/ExoPlayerTest.java index 7bbb6f9306..8d76e8793f 100644 --- a/library/core/src/androidTest/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/androidTest/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -226,22 +226,22 @@ public final class ExoPlayerTest extends TestCase { final int[] actionSchedule = { // 0 -> 1 ExoPlayer.REPEAT_MODE_ONE, // 1 -> 1 ExoPlayer.REPEAT_MODE_OFF, // 1 -> 2 - -1, // 2 -> ended - ExoPlayer.REPEAT_MODE_ONE, // ended -> 2 + ExoPlayer.REPEAT_MODE_ONE, // 2 -> 2 ExoPlayer.REPEAT_MODE_ALL, // 2 -> 0 ExoPlayer.REPEAT_MODE_ONE, // 0 -> 0 -1, // 0 -> 0 ExoPlayer.REPEAT_MODE_OFF, // 0 -> 1 -1, // 1 -> 2 - -1, // 2 -> ended - -1 + -1 // 2 -> ended }; - int[] expectedWindowIndices = {1, 1, 2, 2, 2, 0, 0, 0, 1, 2, 2}; + int[] expectedWindowIndices = {1, 1, 2, 2, 0, 0, 0, 1, 2}; final LinkedList windowIndices = new LinkedList<>(); final CountDownLatch actionCounter = new CountDownLatch(actionSchedule.length); PlayerWrapper playerWrapper = new PlayerWrapper() { + @Override @SuppressWarnings("ResourceType") - private void executeAction() { + public void onPositionDiscontinuity() { + super.onPositionDiscontinuity(); int actionIndex = actionSchedule.length - (int) actionCounter.getCount(); if (actionSchedule[actionIndex] != -1) { player.setRepeatMode(actionSchedule[actionIndex]); @@ -249,20 +249,6 @@ public final class ExoPlayerTest extends TestCase { windowIndices.add(player.getCurrentWindowIndex()); actionCounter.countDown(); } - - @Override - public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { - super.onPlayerStateChanged(playWhenReady, playbackState); - if (playbackState == ExoPlayer.STATE_ENDED) { - executeAction(); - } - } - - @Override - public void onPositionDiscontinuity() { - super.onPositionDiscontinuity(); - executeAction(); - } }; MediaSource mediaSource = new FakeMediaSource(timeline, null, TEST_VIDEO_FORMAT); FakeRenderer renderer = new FakeRenderer(TEST_VIDEO_FORMAT); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java index b6c9ef6f5d..6f54d5f9e1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java @@ -488,11 +488,6 @@ import java.io.IOException; long newPositionUs = seekToPeriodPosition(periodId, playbackInfo.positionUs); playbackInfo = new PlaybackInfo(periodId, newPositionUs); } - - // Restart buffering if playback has ended and repetition is enabled. - if (state == ExoPlayer.STATE_ENDED && repeatMode != ExoPlayer.REPEAT_MODE_OFF) { - setState(ExoPlayer.STATE_BUFFERING); - } } private void startRenderers() throws ExoPlaybackException {