Remove deprecated stop(boolean)

This method has been deprecated for over 2 years.

PiperOrigin-RevId: 520586238
This commit is contained in:
tonihei 2023-03-30 09:59:35 +00:00 committed by Tianyi Feng
parent f4a3478d84
commit b3788ce568
13 changed files with 33 additions and 336 deletions

View File

@ -58,6 +58,8 @@
* Remove `DefaultAudioSink` constructors, use `DefaultAudioSink.Builder` * Remove `DefaultAudioSink` constructors, use `DefaultAudioSink.Builder`
instead. instead.
* Remove `HlsMasterPlaylist`, use `HlsMultivariantPlaylist` instead. * Remove `HlsMasterPlaylist`, use `HlsMultivariantPlaylist` instead.
* Remove `Player.stop(boolean)`. Use `Player.stop()` and
`Player.clearMediaItems()` (if `reset` is `true`) instead.
### 1.0.0 (2023-03-22) ### 1.0.0 (2023-03-22)

View File

@ -477,17 +477,6 @@ public final class CastPlayer extends BasePlayer {
@Override @Override
public void stop() { public void stop() {
stop(/* reset= */ false);
}
/**
* @deprecated Use {@link #stop()} and {@link #clearMediaItems()} (if {@code reset} is true) or
* just {@link #stop()} (if {@code reset} is false). Any player error will be cleared when
* {@link #prepare() re-preparing} the player.
*/
@Deprecated
@Override
public void stop(boolean reset) {
playbackState = STATE_IDLE; playbackState = STATE_IDLE;
if (remoteMediaClient != null) { if (remoteMediaClient != null) {
// TODO(b/69792021): Support or emulate stop without position reset. // TODO(b/69792021): Support or emulate stop without position reset.

View File

@ -478,20 +478,6 @@ public class ForwardingPlayer implements Player {
player.stop(); player.stop();
} }
/**
* Calls {@link Player#stop(boolean)} on the delegate.
*
* @deprecated Use {@link #stop()} and {@link #clearMediaItems()} (if {@code reset} is true) or
* just {@link #stop()} (if {@code reset} is false). Any player error will be cleared when
* {@link #prepare() re-preparing} the player.
*/
@SuppressWarnings("deprecation") // Forwarding to deprecated method
@Deprecated
@Override
public void stop(boolean reset) {
player.stop(reset);
}
/** Calls {@link Player#release()} on the delegate. */ /** Calls {@link Player#release()} on the delegate. */
@Override @Override
public void release() { public void release() {

View File

@ -2524,15 +2524,6 @@ public interface Player {
*/ */
void stop(); void stop();
/**
* @deprecated Use {@link #stop()} and {@link #clearMediaItems()} (if {@code reset} is true) or
* just {@link #stop()} (if {@code reset} is false). Any player error will be cleared when
* {@link #prepare() re-preparing} the player.
*/
@UnstableApi
@Deprecated
void stop(boolean reset);
/** /**
* Releases the player. This method must be called when the player is no longer required. The * Releases the player. This method must be called when the player is no longer required. The
* player must not be used after calling this method. * player must not be used after calling this method.

View File

@ -2325,14 +2325,6 @@ public abstract class SimpleBasePlayer extends BasePlayer {
.build()); .build());
} }
@Override
public final void stop(boolean reset) {
stop();
if (reset) {
clearMediaItems();
}
}
@Override @Override
public final void release() { public final void release() {
verifyApplicationThreadAndInitState(); verifyApplicationThreadAndInitState();

View File

@ -956,7 +956,6 @@ import java.util.concurrent.TimeoutException;
if (!internalPlayer.setForegroundMode(foregroundMode)) { if (!internalPlayer.setForegroundMode(foregroundMode)) {
// One of the renderers timed out releasing its resources. // One of the renderers timed out releasing its resources.
stopInternal( stopInternal(
/* reset= */ false,
ExoPlaybackException.createForUnexpected( ExoPlaybackException.createForUnexpected(
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_SET_FOREGROUND_MODE), new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_SET_FOREGROUND_MODE),
PlaybackException.ERROR_CODE_TIMEOUT)); PlaybackException.ERROR_CODE_TIMEOUT));
@ -966,15 +965,9 @@ import java.util.concurrent.TimeoutException;
@Override @Override
public void stop() { public void stop() {
verifyApplicationThread();
stop(/* reset= */ false);
}
@Override
public void stop(boolean reset) {
verifyApplicationThread(); verifyApplicationThread();
audioFocusManager.updateAudioFocus(getPlayWhenReady(), Player.STATE_IDLE); audioFocusManager.updateAudioFocus(getPlayWhenReady(), Player.STATE_IDLE);
stopInternal(reset, /* error= */ null); stopInternal(/* error= */ null);
currentCueGroup = new CueGroup(ImmutableList.of(), playbackInfo.positionUs); currentCueGroup = new CueGroup(ImmutableList.of(), playbackInfo.positionUs);
} }
@ -1759,38 +1752,27 @@ import java.util.concurrent.TimeoutException;
/** /**
* Stops the player. * Stops the player.
* *
* @param reset Whether the playlist should be cleared and whether the playback position and
* playback error should be reset.
* @param error An optional {@link ExoPlaybackException} to set. * @param error An optional {@link ExoPlaybackException} to set.
*/ */
private void stopInternal(boolean reset, @Nullable ExoPlaybackException error) { private void stopInternal(@Nullable ExoPlaybackException error) {
PlaybackInfo playbackInfo; PlaybackInfo playbackInfo =
if (reset) { this.playbackInfo.copyWithLoadingMediaPeriodId(this.playbackInfo.periodId);
playbackInfo = playbackInfo.bufferedPositionUs = playbackInfo.positionUs;
removeMediaItemsInternal( playbackInfo.totalBufferedDurationUs = 0;
/* fromIndex= */ 0, /* toIndex= */ mediaSourceHolderSnapshots.size());
playbackInfo = playbackInfo.copyWithPlaybackError(null);
} else {
playbackInfo = this.playbackInfo.copyWithLoadingMediaPeriodId(this.playbackInfo.periodId);
playbackInfo.bufferedPositionUs = playbackInfo.positionUs;
playbackInfo.totalBufferedDurationUs = 0;
}
playbackInfo = playbackInfo.copyWithPlaybackState(Player.STATE_IDLE); playbackInfo = playbackInfo.copyWithPlaybackState(Player.STATE_IDLE);
if (error != null) { if (error != null) {
playbackInfo = playbackInfo.copyWithPlaybackError(error); playbackInfo = playbackInfo.copyWithPlaybackError(error);
} }
pendingOperationAcks++; pendingOperationAcks++;
internalPlayer.stop(); internalPlayer.stop();
boolean positionDiscontinuity =
playbackInfo.timeline.isEmpty() && !this.playbackInfo.timeline.isEmpty();
updatePlaybackInfo( updatePlaybackInfo(
playbackInfo, playbackInfo,
TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, /* ignored */ TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
/* ignored */ PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST, /* ignored */ PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST,
/* seekProcessed= */ false, /* seekProcessed= */ false,
positionDiscontinuity, /* positionDiscontinuity= */ false,
DISCONTINUITY_REASON_REMOVE, /* ignored */ DISCONTINUITY_REASON_INTERNAL,
/* discontinuityWindowStartPositionUs= */ getCurrentPositionUsInternal(playbackInfo), /* ignored */ C.TIME_UNSET,
/* ignored */ C.INDEX_UNSET, /* ignored */ C.INDEX_UNSET,
/* repeatCurrentMediaItem= */ false); /* repeatCurrentMediaItem= */ false);
} }
@ -2589,7 +2571,6 @@ import java.util.concurrent.TimeoutException;
this.videoOutput = videoOutput; this.videoOutput = videoOutput;
if (messageDeliveryTimedOut) { if (messageDeliveryTimedOut) {
stopInternal( stopInternal(
/* reset= */ false,
ExoPlaybackException.createForUnexpected( ExoPlaybackException.createForUnexpected(
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_DETACH_SURFACE), new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_DETACH_SURFACE),
PlaybackException.ERROR_CODE_TIMEOUT)); PlaybackException.ERROR_CODE_TIMEOUT));

View File

@ -1079,18 +1079,6 @@ public class SimpleExoPlayer extends BasePlayer
player.stop(); player.stop();
} }
/**
* @deprecated Use {@link #stop()} and {@link #clearMediaItems()} (if {@code reset} is true) or
* just {@link #stop()} (if {@code reset} is false). Any player error will be cleared when
* {@link #prepare() re-preparing} the player.
*/
@Deprecated
@Override
public void stop(boolean reset) {
blockUntilConstructorFinished();
player.stop(reset);
}
@Override @Override
public void release() { public void release() {
blockUntilConstructorFinished(); blockUntilConstructorFinished();

View File

@ -1504,7 +1504,7 @@ public final class ExoPlayerTest {
} }
@Test @Test
public void stop_withoutReset_doesNotResetPosition_correctMasking() throws Exception { public void stop_correctMasking() throws Exception {
int[] currentMediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; int[] currentMediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET}; long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
@ -1524,7 +1524,7 @@ public final class ExoPlayerTest {
currentPosition[0] = player.getCurrentPosition(); currentPosition[0] = player.getCurrentPosition();
bufferedPosition[0] = player.getBufferedPosition(); bufferedPosition[0] = player.getBufferedPosition();
totalBufferedDuration[0] = player.getTotalBufferedDuration(); totalBufferedDuration[0] = player.getTotalBufferedDuration();
player.stop(/* reset= */ false); player.stop();
currentMediaItemIndex[1] = player.getCurrentMediaItemIndex(); currentMediaItemIndex[1] = player.getCurrentMediaItemIndex();
currentPosition[1] = player.getCurrentPosition(); currentPosition[1] = player.getCurrentPosition();
bufferedPosition[1] = player.getBufferedPosition(); bufferedPosition[1] = player.getBufferedPosition();
@ -1574,109 +1574,12 @@ public final class ExoPlayerTest {
} }
@Test @Test
public void stop_withoutReset_releasesMediaSource() throws Exception { public void stop_releasesMediaSource() throws Exception {
Timeline timeline = new FakeTimeline(); Timeline timeline = new FakeTimeline();
final FakeMediaSource mediaSource = final FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT); new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG).waitForPlaybackState(Player.STATE_READY).stop().build();
.waitForPlaybackState(Player.STATE_READY)
.stop(/* reset= */ false)
.build();
new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline)
.setActionSchedule(actionSchedule)
.build()
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
mediaSource.assertReleased();
}
@Test
public void stop_withReset_doesResetPosition_correctMasking() throws Exception {
int[] currentMediaItemIndex = {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
long[] currentPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] bufferedPosition = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
long[] totalBufferedDuration = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
final FakeMediaSource mediaSource =
new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG)
.pause()
.seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000)
.waitForPlaybackState(Player.STATE_READY)
.executeRunnable(
new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
currentMediaItemIndex[0] = player.getCurrentMediaItemIndex();
currentPosition[0] = player.getCurrentPosition();
bufferedPosition[0] = player.getBufferedPosition();
totalBufferedDuration[0] = player.getTotalBufferedDuration();
player.stop(/* reset= */ true);
currentMediaItemIndex[1] = player.getCurrentMediaItemIndex();
currentPosition[1] = player.getCurrentPosition();
bufferedPosition[1] = player.getBufferedPosition();
totalBufferedDuration[1] = player.getTotalBufferedDuration();
}
})
.waitForPlaybackState(Player.STATE_IDLE)
.executeRunnable(
new PlayerRunnable() {
@Override
public void run(ExoPlayer player) {
currentMediaItemIndex[2] = player.getCurrentMediaItemIndex();
currentPosition[2] = player.getCurrentPosition();
bufferedPosition[2] = player.getBufferedPosition();
totalBufferedDuration[2] = player.getTotalBufferedDuration();
}
})
.build();
ExoPlayerTestRunner testRunner =
new ExoPlayerTestRunner.Builder(context)
.setMediaSources(mediaSource, mediaSource)
.setActionSchedule(actionSchedule)
.build()
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
testRunner.assertPositionDiscontinuityReasonsEqual(
Player.DISCONTINUITY_REASON_SEEK, Player.DISCONTINUITY_REASON_REMOVE);
assertThat(currentMediaItemIndex[0]).isEqualTo(1);
assertThat(currentPosition[0]).isGreaterThan(0);
assertThat(bufferedPosition[0]).isEqualTo(10000);
assertThat(totalBufferedDuration[0]).isEqualTo(10000 - currentPosition[0]);
assertThat(currentMediaItemIndex[1]).isEqualTo(0);
assertThat(currentPosition[1]).isEqualTo(0);
assertThat(bufferedPosition[1]).isEqualTo(0);
assertThat(totalBufferedDuration[1]).isEqualTo(0);
assertThat(currentMediaItemIndex[2]).isEqualTo(0);
assertThat(currentPosition[2]).isEqualTo(0);
assertThat(bufferedPosition[2]).isEqualTo(0);
assertThat(totalBufferedDuration[2]).isEqualTo(0);
}
@Test
public void stop_withReset_releasesMediaSource() throws Exception {
Timeline timeline = new FakeTimeline();
final FakeMediaSource mediaSource =
new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT);
ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_READY)
.stop(/* reset= */ true)
.build();
new ExoPlayerTestRunner.Builder(context) new ExoPlayerTestRunner.Builder(context)
.setTimeline(timeline) .setTimeline(timeline)
@ -1754,7 +1657,7 @@ public final class ExoPlayerTest {
} }
@Test @Test
public void settingNewStartPositionPossibleAfterStopWithReset() throws Exception { public void settingNewStartPositionPossibleAfterStopAndClearMediaItems() throws Exception {
Timeline timeline = new FakeTimeline(); Timeline timeline = new FakeTimeline();
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2); Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2);
MediaSource secondSource = MediaSource secondSource =
@ -1764,7 +1667,8 @@ public final class ExoPlayerTest {
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
.stop(/* reset= */ true) .stop()
.clearMediaItems()
.waitForPlaybackState(Player.STATE_IDLE) .waitForPlaybackState(Player.STATE_IDLE)
.seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000) .seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000)
.setMediaSources(secondSource) .setMediaSources(secondSource)
@ -1980,11 +1884,12 @@ public final class ExoPlayerTest {
} }
@Test @Test
public void stopDuringPreparationOverwritesPreparation() throws Exception { public void stopAndClearMediaItemsDuringPreparationOverwritesPreparation() throws Exception {
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_BUFFERING) .waitForPlaybackState(Player.STATE_BUFFERING)
.stop(true) .stop()
.clearMediaItems()
.waitForPendingPlayerCommands() .waitForPendingPlayerCommands()
.build(); .build();
ExoPlayerTestRunner testRunner = ExoPlayerTestRunner testRunner =
@ -2007,8 +1912,8 @@ public final class ExoPlayerTest {
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
.stop(false) .stop()
.stop(false) .stop()
// Wait until the player fully processed the second stop to see that no further // Wait until the player fully processed the second stop to see that no further
// callbacks are triggered. // callbacks are triggered.
.waitForPendingPlayerCommands() .waitForPendingPlayerCommands()
@ -3273,7 +3178,7 @@ public final class ExoPlayerTest {
public void onPlaybackStateChanged(@Player.State int playbackState) { public void onPlaybackStateChanged(@Player.State int playbackState) {
playerListener1States.add(playbackState); playerListener1States.add(playbackState);
if (playbackState == Player.STATE_READY) { if (playbackState == Player.STATE_READY) {
playerReference.get().stop(/* reset= */ true); playerReference.get().stop();
} }
} }
}; };
@ -3325,7 +3230,8 @@ public final class ExoPlayerTest {
public void onPlaybackStateChanged(@Player.State int playbackState) { public void onPlaybackStateChanged(@Player.State int playbackState) {
playerListenerStates.add(playbackState); playerListenerStates.add(playbackState);
if (playbackState == Player.STATE_READY) { if (playbackState == Player.STATE_READY) {
playerReference.get().stop(/* reset= */ true); playerReference.get().stop();
playerReference.get().clearMediaItems();
sequence.add(0); sequence.add(0);
} }
} }
@ -3396,7 +3302,7 @@ public final class ExoPlayerTest {
}) })
// Ensure there are no further pending callbacks. // Ensure there are no further pending callbacks.
.delay(1) .delay(1)
.stop(/* reset= */ true) .stop()
.waitForPlaybackState(Player.STATE_IDLE) .waitForPlaybackState(Player.STATE_IDLE)
.prepare() .prepare()
.waitForPlaybackState(Player.STATE_ENDED) .waitForPlaybackState(Player.STATE_ENDED)
@ -3412,14 +3318,12 @@ public final class ExoPlayerTest {
exoPlayerTestRunner.assertTimelinesSame( exoPlayerTestRunner.assertTimelinesSame(
new FakeMediaSource.InitialTimeline(firstTimeline), new FakeMediaSource.InitialTimeline(firstTimeline),
firstTimeline, firstTimeline,
Timeline.EMPTY,
new FakeMediaSource.InitialTimeline(secondTimeline), new FakeMediaSource.InitialTimeline(secondTimeline),
secondTimeline); secondTimeline);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual( exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE); Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
} }
@ -6256,8 +6160,7 @@ public final class ExoPlayerTest {
} }
@Test @Test
public void stopWithNoReset_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering() public void stop_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering() throws Exception {
throws Exception {
Timeline timeline = new FakeTimeline(); Timeline timeline = new FakeTimeline();
FakeMediaSource secondMediaSource = new FakeMediaSource(timeline); FakeMediaSource secondMediaSource = new FakeMediaSource(timeline);
int[] playbackStateHolder = new int[3]; int[] playbackStateHolder = new int[3];
@ -6265,7 +6168,7 @@ public final class ExoPlayerTest {
ActionSchedule actionSchedule = ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG) new ActionSchedule.Builder(TAG)
.waitForPlaybackState(Player.STATE_READY) .waitForPlaybackState(Player.STATE_READY)
.stop(/* reset= */ false) .stop()
.executeRunnable( .executeRunnable(
new PlaybackStateCollector(/* index= */ 0, playbackStateHolder, windowCountHolder)) new PlaybackStateCollector(/* index= */ 0, playbackStateHolder, windowCountHolder))
.clearMediaItems() .clearMediaItems()
@ -9079,40 +8982,8 @@ public final class ExoPlayerTest {
player.release(); player.release();
} }
// Tests deprecated stop(boolean reset)
@SuppressWarnings("deprecation")
@Test @Test
public void stop_withReset_notifiesMediaItemTransition() throws Exception { public void stop_doesNotNotifyMediaItemTransition() throws Exception {
List<MediaItem> reportedMediaItems = new ArrayList<>();
List<Integer> reportedTransitionReasons = new ArrayList<>();
MediaSource mediaSource1 = FakeMediaSource.createWithWindowId(/* windowId= */ new Object());
MediaSource mediaSource2 = FakeMediaSource.createWithWindowId(/* windowId= */ new Object());
ExoPlayer player = new TestExoPlayerBuilder(context).build();
player.addListener(
new Listener() {
@Override
public void onMediaItemTransition(@Nullable MediaItem mediaItem, int reason) {
reportedMediaItems.add(mediaItem);
reportedTransitionReasons.add(reason);
}
});
player.setMediaSources(ImmutableList.of(mediaSource1, mediaSource2));
player.prepare();
runUntilPlaybackState(player, Player.STATE_READY);
player.stop(/* reset= */ true);
assertThat(reportedMediaItems).containsExactly(mediaSource1.getMediaItem(), null).inOrder();
assertThat(reportedTransitionReasons)
.containsExactly(
Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED,
Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED)
.inOrder();
player.release();
}
@Test
public void stop_withoutReset_doesNotNotifyMediaItemTransition() throws Exception {
List<MediaItem> reportedMediaItems = new ArrayList<>(); List<MediaItem> reportedMediaItems = new ArrayList<>();
List<Integer> reportedTransitionReasons = new ArrayList<>(); List<Integer> reportedTransitionReasons = new ArrayList<>();
MediaSource mediaSource1 = FakeMediaSource.createWithWindowId(/* windowId= */ new Object()); MediaSource mediaSource1 = FakeMediaSource.createWithWindowId(/* windowId= */ new Object());
@ -12082,43 +11953,6 @@ public final class ExoPlayerTest {
player.release(); player.release();
} }
// Tests deprecated stop(boolean reset)
@SuppressWarnings("deprecation")
@Test
public void stop_withResetRemovesPlayingPeriod_callsOnPositionDiscontinuity() throws Exception {
ExoPlayer player = new TestExoPlayerBuilder(context).build();
Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener);
player.setMediaSource(createFakeMediaSource(/* id= */ 123));
player.prepare();
TestPlayerRunHelper.playUntilPosition(
player, /* mediaItemIndex= */ 0, /* positionMs= */ 5 * C.MILLIS_PER_SECOND);
player.stop(/* reset= */ true);
ArgumentCaptor<Player.PositionInfo> oldPosition =
ArgumentCaptor.forClass(Player.PositionInfo.class);
ArgumentCaptor<Player.PositionInfo> newPosition =
ArgumentCaptor.forClass(Player.PositionInfo.class);
verify(listener, never())
.onPositionDiscontinuity(any(), any(), not(eq(Player.DISCONTINUITY_REASON_REMOVE)));
verify(listener)
.onPositionDiscontinuity(
oldPosition.capture(), newPosition.capture(), eq(Player.DISCONTINUITY_REASON_REMOVE));
List<Player.PositionInfo> oldPositions = oldPosition.getAllValues();
List<Player.PositionInfo> newPositions = newPosition.getAllValues();
assertThat(oldPositions.get(0).mediaItemIndex).isEqualTo(0);
assertThat(oldPositions.get(0).mediaItem.localConfiguration.tag).isEqualTo(123);
assertThat(oldPositions.get(0).positionMs).isIn(Range.closed(4980L, 5000L));
assertThat(oldPositions.get(0).contentPositionMs).isIn(Range.closed(4980L, 5000L));
assertThat(newPositions.get(0).windowUid).isNull();
assertThat(newPositions.get(0).mediaItemIndex).isEqualTo(0);
assertThat(newPositions.get(0).mediaItem).isNull();
assertThat(newPositions.get(0).positionMs).isEqualTo(0);
assertThat(newPositions.get(0).contentPositionMs).isEqualTo(0);
player.release();
}
@Test @Test
public void seekTo_cancelsSourceDiscontinuity_callsOnPositionDiscontinuity() throws Exception { public void seekTo_cancelsSourceDiscontinuity_callsOnPositionDiscontinuity() throws Exception {
Timeline timeline1 = Timeline timeline1 =

View File

@ -470,21 +470,6 @@ public class MediaController implements Player {
impl.stop(); impl.stop();
} }
/**
* @deprecated Use {@link #stop()} and {@link #clearMediaItems()} (if {@code reset} is true) or
* just {@link #stop()} (if {@code reset} is false). Any player error will be cleared when
* {@link #prepare() re-preparing} the player.
*/
@UnstableApi
@Deprecated
@Override
public void stop(boolean reset) {
stop();
if (reset) {
clearMediaItems();
}
}
/** /**
* Releases the connection between {@link MediaController} and {@link MediaSession}. This method * Releases the connection between {@link MediaController} and {@link MediaSession}. This method
* must be called when the controller is no longer required. The controller must not be used after * must be called when the controller is no longer required. The controller must not be used after

View File

@ -314,17 +314,6 @@ public class MockPlayer implements Player {
checkNotNull(conditionVariables.get(METHOD_STOP)).open(); checkNotNull(conditionVariables.get(METHOD_STOP)).open();
} }
/**
* @deprecated Use {@link #stop()} and {@link #clearMediaItems()} (if {@code reset} is true) or
* just {@link #stop()} (if {@code reset} is false). Any player error will be cleared when
* {@link #prepare() re-preparing} the player.
*/
@Deprecated
@Override
public void stop(boolean reset) {
throw new UnsupportedOperationException();
}
@Override @Override
public void addListener(Listener listener) { public void addListener(Listener listener) {
listeners.add(listener); listeners.add(listener);

View File

@ -339,13 +339,11 @@ public abstract class Action {
} }
} }
/** Calls {@link Player#stop()} or {@link Player#stop(boolean)}. */ /** Calls {@link Player#stop()}. */
public static final class Stop extends Action { public static final class Stop extends Action {
private static final String STOP_ACTION_TAG = "Stop"; private static final String STOP_ACTION_TAG = "Stop";
@Nullable private final Boolean reset;
/** /**
* Action will call {@link Player#stop()}. * Action will call {@link Player#stop()}.
* *
@ -353,28 +351,12 @@ public abstract class Action {
*/ */
public Stop(String tag) { public Stop(String tag) {
super(tag, STOP_ACTION_TAG); super(tag, STOP_ACTION_TAG);
this.reset = null;
}
/**
* Action will call {@link Player#stop(boolean)}.
*
* @param tag A tag to use for logging.
* @param reset The value to pass to {@link Player#stop(boolean)}.
*/
public Stop(@Size(max = 23) String tag, boolean reset) {
super(tag, STOP_ACTION_TAG);
this.reset = reset;
} }
@Override @Override
protected void doActionImpl( protected void doActionImpl(
ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
if (reset == null) { player.stop();
player.stop();
} else {
player.stop(reset);
}
} }
} }

View File

@ -242,17 +242,6 @@ public final class ActionSchedule {
return apply(new Stop(tag)); return apply(new Stop(tag));
} }
/**
* Schedules a stop action.
*
* @param reset Whether the player should be reset.
* @return The builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder stop(boolean reset) {
return apply(new Stop(tag, reset));
}
/** /**
* Schedules a play action. * Schedules a play action.
* *

View File

@ -185,17 +185,6 @@ public class StubPlayer extends BasePlayer {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/**
* @deprecated Use {@link #stop()} and {@link #clearMediaItems()} (if {@code reset} is true) or
* just {@link #stop()} (if {@code reset} is false). Any player error will be cleared when
* {@link #prepare() re-preparing} the player.
*/
@Deprecated
@Override
public void stop(boolean reset) {
throw new UnsupportedOperationException();
}
@Override @Override
public void release() { public void release() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();