Remove deprecated stop(boolean)
This method has been deprecated for over 2 years. PiperOrigin-RevId: 520586238
This commit is contained in:
parent
f4a3478d84
commit
b3788ce568
@ -58,6 +58,8 @@
|
||||
* Remove `DefaultAudioSink` constructors, use `DefaultAudioSink.Builder`
|
||||
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)
|
||||
|
||||
|
@ -477,17 +477,6 @@ public final class CastPlayer extends BasePlayer {
|
||||
|
||||
@Override
|
||||
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;
|
||||
if (remoteMediaClient != null) {
|
||||
// TODO(b/69792021): Support or emulate stop without position reset.
|
||||
|
@ -478,20 +478,6 @@ public class ForwardingPlayer implements Player {
|
||||
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. */
|
||||
@Override
|
||||
public void release() {
|
||||
|
@ -2524,15 +2524,6 @@ public interface Player {
|
||||
*/
|
||||
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
|
||||
* player must not be used after calling this method.
|
||||
|
@ -2325,14 +2325,6 @@ public abstract class SimpleBasePlayer extends BasePlayer {
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void stop(boolean reset) {
|
||||
stop();
|
||||
if (reset) {
|
||||
clearMediaItems();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void release() {
|
||||
verifyApplicationThreadAndInitState();
|
||||
|
@ -956,7 +956,6 @@ import java.util.concurrent.TimeoutException;
|
||||
if (!internalPlayer.setForegroundMode(foregroundMode)) {
|
||||
// One of the renderers timed out releasing its resources.
|
||||
stopInternal(
|
||||
/* reset= */ false,
|
||||
ExoPlaybackException.createForUnexpected(
|
||||
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_SET_FOREGROUND_MODE),
|
||||
PlaybackException.ERROR_CODE_TIMEOUT));
|
||||
@ -966,15 +965,9 @@ import java.util.concurrent.TimeoutException;
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
verifyApplicationThread();
|
||||
stop(/* reset= */ false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(boolean reset) {
|
||||
verifyApplicationThread();
|
||||
audioFocusManager.updateAudioFocus(getPlayWhenReady(), Player.STATE_IDLE);
|
||||
stopInternal(reset, /* error= */ null);
|
||||
stopInternal(/* error= */ null);
|
||||
currentCueGroup = new CueGroup(ImmutableList.of(), playbackInfo.positionUs);
|
||||
}
|
||||
|
||||
@ -1759,38 +1752,27 @@ import java.util.concurrent.TimeoutException;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
private void stopInternal(boolean reset, @Nullable ExoPlaybackException error) {
|
||||
PlaybackInfo playbackInfo;
|
||||
if (reset) {
|
||||
playbackInfo =
|
||||
removeMediaItemsInternal(
|
||||
/* fromIndex= */ 0, /* toIndex= */ mediaSourceHolderSnapshots.size());
|
||||
playbackInfo = playbackInfo.copyWithPlaybackError(null);
|
||||
} else {
|
||||
playbackInfo = this.playbackInfo.copyWithLoadingMediaPeriodId(this.playbackInfo.periodId);
|
||||
playbackInfo.bufferedPositionUs = playbackInfo.positionUs;
|
||||
playbackInfo.totalBufferedDurationUs = 0;
|
||||
}
|
||||
private void stopInternal(@Nullable ExoPlaybackException error) {
|
||||
PlaybackInfo playbackInfo =
|
||||
this.playbackInfo.copyWithLoadingMediaPeriodId(this.playbackInfo.periodId);
|
||||
playbackInfo.bufferedPositionUs = playbackInfo.positionUs;
|
||||
playbackInfo.totalBufferedDurationUs = 0;
|
||||
playbackInfo = playbackInfo.copyWithPlaybackState(Player.STATE_IDLE);
|
||||
if (error != null) {
|
||||
playbackInfo = playbackInfo.copyWithPlaybackError(error);
|
||||
}
|
||||
pendingOperationAcks++;
|
||||
internalPlayer.stop();
|
||||
boolean positionDiscontinuity =
|
||||
playbackInfo.timeline.isEmpty() && !this.playbackInfo.timeline.isEmpty();
|
||||
updatePlaybackInfo(
|
||||
playbackInfo,
|
||||
TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
|
||||
/* ignored */ TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
|
||||
/* ignored */ PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST,
|
||||
/* seekProcessed= */ false,
|
||||
positionDiscontinuity,
|
||||
DISCONTINUITY_REASON_REMOVE,
|
||||
/* discontinuityWindowStartPositionUs= */ getCurrentPositionUsInternal(playbackInfo),
|
||||
/* positionDiscontinuity= */ false,
|
||||
/* ignored */ DISCONTINUITY_REASON_INTERNAL,
|
||||
/* ignored */ C.TIME_UNSET,
|
||||
/* ignored */ C.INDEX_UNSET,
|
||||
/* repeatCurrentMediaItem= */ false);
|
||||
}
|
||||
@ -2589,7 +2571,6 @@ import java.util.concurrent.TimeoutException;
|
||||
this.videoOutput = videoOutput;
|
||||
if (messageDeliveryTimedOut) {
|
||||
stopInternal(
|
||||
/* reset= */ false,
|
||||
ExoPlaybackException.createForUnexpected(
|
||||
new ExoTimeoutException(ExoTimeoutException.TIMEOUT_OPERATION_DETACH_SURFACE),
|
||||
PlaybackException.ERROR_CODE_TIMEOUT));
|
||||
|
@ -1079,18 +1079,6 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
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
|
||||
public void release() {
|
||||
blockUntilConstructorFinished();
|
||||
|
@ -1504,7 +1504,7 @@ public final class ExoPlayerTest {
|
||||
}
|
||||
|
||||
@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};
|
||||
long[] currentPosition = {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();
|
||||
bufferedPosition[0] = player.getBufferedPosition();
|
||||
totalBufferedDuration[0] = player.getTotalBufferedDuration();
|
||||
player.stop(/* reset= */ false);
|
||||
player.stop();
|
||||
currentMediaItemIndex[1] = player.getCurrentMediaItemIndex();
|
||||
currentPosition[1] = player.getCurrentPosition();
|
||||
bufferedPosition[1] = player.getBufferedPosition();
|
||||
@ -1574,109 +1574,12 @@ public final class ExoPlayerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stop_withoutReset_releasesMediaSource() throws Exception {
|
||||
public void stop_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= */ 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 ActionSchedule.Builder(TAG).waitForPlaybackState(Player.STATE_READY).stop().build();
|
||||
|
||||
new ExoPlayerTestRunner.Builder(context)
|
||||
.setTimeline(timeline)
|
||||
@ -1754,7 +1657,7 @@ public final class ExoPlayerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void settingNewStartPositionPossibleAfterStopWithReset() throws Exception {
|
||||
public void settingNewStartPositionPossibleAfterStopAndClearMediaItems() throws Exception {
|
||||
Timeline timeline = new FakeTimeline();
|
||||
Timeline secondTimeline = new FakeTimeline(/* windowCount= */ 2);
|
||||
MediaSource secondSource =
|
||||
@ -1764,7 +1667,8 @@ public final class ExoPlayerTest {
|
||||
ActionSchedule actionSchedule =
|
||||
new ActionSchedule.Builder(TAG)
|
||||
.waitForPlaybackState(Player.STATE_READY)
|
||||
.stop(/* reset= */ true)
|
||||
.stop()
|
||||
.clearMediaItems()
|
||||
.waitForPlaybackState(Player.STATE_IDLE)
|
||||
.seek(/* mediaItemIndex= */ 1, /* positionMs= */ 1000)
|
||||
.setMediaSources(secondSource)
|
||||
@ -1980,11 +1884,12 @@ public final class ExoPlayerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stopDuringPreparationOverwritesPreparation() throws Exception {
|
||||
public void stopAndClearMediaItemsDuringPreparationOverwritesPreparation() throws Exception {
|
||||
ActionSchedule actionSchedule =
|
||||
new ActionSchedule.Builder(TAG)
|
||||
.waitForPlaybackState(Player.STATE_BUFFERING)
|
||||
.stop(true)
|
||||
.stop()
|
||||
.clearMediaItems()
|
||||
.waitForPendingPlayerCommands()
|
||||
.build();
|
||||
ExoPlayerTestRunner testRunner =
|
||||
@ -2007,8 +1912,8 @@ public final class ExoPlayerTest {
|
||||
ActionSchedule actionSchedule =
|
||||
new ActionSchedule.Builder(TAG)
|
||||
.waitForPlaybackState(Player.STATE_READY)
|
||||
.stop(false)
|
||||
.stop(false)
|
||||
.stop()
|
||||
.stop()
|
||||
// Wait until the player fully processed the second stop to see that no further
|
||||
// callbacks are triggered.
|
||||
.waitForPendingPlayerCommands()
|
||||
@ -3273,7 +3178,7 @@ public final class ExoPlayerTest {
|
||||
public void onPlaybackStateChanged(@Player.State int playbackState) {
|
||||
playerListener1States.add(playbackState);
|
||||
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) {
|
||||
playerListenerStates.add(playbackState);
|
||||
if (playbackState == Player.STATE_READY) {
|
||||
playerReference.get().stop(/* reset= */ true);
|
||||
playerReference.get().stop();
|
||||
playerReference.get().clearMediaItems();
|
||||
sequence.add(0);
|
||||
}
|
||||
}
|
||||
@ -3396,7 +3302,7 @@ public final class ExoPlayerTest {
|
||||
})
|
||||
// Ensure there are no further pending callbacks.
|
||||
.delay(1)
|
||||
.stop(/* reset= */ true)
|
||||
.stop()
|
||||
.waitForPlaybackState(Player.STATE_IDLE)
|
||||
.prepare()
|
||||
.waitForPlaybackState(Player.STATE_ENDED)
|
||||
@ -3412,14 +3318,12 @@ public final class ExoPlayerTest {
|
||||
exoPlayerTestRunner.assertTimelinesSame(
|
||||
new FakeMediaSource.InitialTimeline(firstTimeline),
|
||||
firstTimeline,
|
||||
Timeline.EMPTY,
|
||||
new FakeMediaSource.InitialTimeline(secondTimeline),
|
||||
secondTimeline);
|
||||
exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
|
||||
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
|
||||
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
|
||||
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
|
||||
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
|
||||
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
|
||||
}
|
||||
|
||||
@ -6256,8 +6160,7 @@ public final class ExoPlayerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stopWithNoReset_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering()
|
||||
throws Exception {
|
||||
public void stop_modifyingPlaylistRemainsInIdleState_needsPrepareForBuffering() throws Exception {
|
||||
Timeline timeline = new FakeTimeline();
|
||||
FakeMediaSource secondMediaSource = new FakeMediaSource(timeline);
|
||||
int[] playbackStateHolder = new int[3];
|
||||
@ -6265,7 +6168,7 @@ public final class ExoPlayerTest {
|
||||
ActionSchedule actionSchedule =
|
||||
new ActionSchedule.Builder(TAG)
|
||||
.waitForPlaybackState(Player.STATE_READY)
|
||||
.stop(/* reset= */ false)
|
||||
.stop()
|
||||
.executeRunnable(
|
||||
new PlaybackStateCollector(/* index= */ 0, playbackStateHolder, windowCountHolder))
|
||||
.clearMediaItems()
|
||||
@ -9079,40 +8982,8 @@ public final class ExoPlayerTest {
|
||||
player.release();
|
||||
}
|
||||
|
||||
// Tests deprecated stop(boolean reset)
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void stop_withReset_notifiesMediaItemTransition() 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 {
|
||||
public void stop_doesNotNotifyMediaItemTransition() throws Exception {
|
||||
List<MediaItem> reportedMediaItems = new ArrayList<>();
|
||||
List<Integer> reportedTransitionReasons = new ArrayList<>();
|
||||
MediaSource mediaSource1 = FakeMediaSource.createWithWindowId(/* windowId= */ new Object());
|
||||
@ -12082,43 +11953,6 @@ public final class ExoPlayerTest {
|
||||
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
|
||||
public void seekTo_cancelsSourceDiscontinuity_callsOnPositionDiscontinuity() throws Exception {
|
||||
Timeline timeline1 =
|
||||
|
@ -470,21 +470,6 @@ public class MediaController implements Player {
|
||||
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
|
||||
* must be called when the controller is no longer required. The controller must not be used after
|
||||
|
@ -314,17 +314,6 @@ public class MockPlayer implements Player {
|
||||
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
|
||||
public void addListener(Listener listener) {
|
||||
listeners.add(listener);
|
||||
|
@ -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 {
|
||||
|
||||
private static final String STOP_ACTION_TAG = "Stop";
|
||||
|
||||
@Nullable private final Boolean reset;
|
||||
|
||||
/**
|
||||
* Action will call {@link Player#stop()}.
|
||||
*
|
||||
@ -353,28 +351,12 @@ public abstract class Action {
|
||||
*/
|
||||
public Stop(String 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
|
||||
protected void doActionImpl(
|
||||
ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
|
||||
if (reset == null) {
|
||||
player.stop();
|
||||
} else {
|
||||
player.stop(reset);
|
||||
}
|
||||
player.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,17 +242,6 @@ public final class ActionSchedule {
|
||||
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.
|
||||
*
|
||||
|
@ -185,17 +185,6 @@ public class StubPlayer extends BasePlayer {
|
||||
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
|
||||
public void release() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
Loading…
x
Reference in New Issue
Block a user