From 5153ccde987b97a907776ce313c7314a073426fc Mon Sep 17 00:00:00 2001 From: krocard Date: Tue, 27 Apr 2021 12:09:37 +0100 Subject: [PATCH] Remove release command for symmetry with Player construction Release is a life cycle operation that should only be called when the player is no longer needed. It's linked to the player lifecycle and thus very different from prepare/stop. As a result, it should not be in the same command. Additionally it's not clear if remote players will ever need to call release, as the player creator is best candidate to release it. As a result the release operation doesn't have a use case for a command. A release command can be added later if a need is identified. PiperOrigin-RevId: 370649214 --- .../com/google/android/exoplayer2/ext/cast/CastPlayer.java | 2 +- .../google/android/exoplayer2/ext/cast/CastPlayerTest.java | 4 ++-- .../src/main/java/com/google/android/exoplayer2/Player.java | 6 +++--- .../java/com/google/android/exoplayer2/ExoPlayerImpl.java | 2 +- .../java/com/google/android/exoplayer2/ExoPlayerTest.java | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java index 28daec5144..a1cf436a4a 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java @@ -89,7 +89,7 @@ public final class CastPlayer extends BasePlayer { new Commands.Builder() .addAll( COMMAND_PLAY_PAUSE, - COMMAND_PREPARE_STOP_RELEASE, + COMMAND_PREPARE_STOP, COMMAND_SEEK_TO_DEFAULT_POSITION, COMMAND_SEEK_TO_MEDIA_ITEM, COMMAND_SET_REPEAT_MODE, diff --git a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java index ab49831c60..7c9862a353 100644 --- a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java +++ b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java @@ -25,7 +25,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_GET_MEDIA_ITEMS_METAD import static com.google.android.exoplayer2.Player.COMMAND_GET_TEXT; import static com.google.android.exoplayer2.Player.COMMAND_GET_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE; -import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP_RELEASE; +import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_DEFAULT_POSITION; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_MEDIA_ITEM; @@ -1108,7 +1108,7 @@ public class CastPlayerTest { updateTimeLine(mediaItems, mediaQueueItemIds, /* currentItemId= */ 1); assertThat(castPlayer.isCommandAvailable(COMMAND_PLAY_PAUSE)).isTrue(); - assertThat(castPlayer.isCommandAvailable(COMMAND_PREPARE_STOP_RELEASE)).isTrue(); + assertThat(castPlayer.isCommandAvailable(COMMAND_PREPARE_STOP)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_DEFAULT_POSITION)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isTrue(); assertThat(castPlayer.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isTrue(); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Player.java b/library/common/src/main/java/com/google/android/exoplayer2/Player.java index 8d08a52808..fc7ca7a316 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Player.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Player.java @@ -938,7 +938,7 @@ public interface Player { /** * Commands that can be executed on a {@code Player}. One of {@link #COMMAND_PLAY_PAUSE}, {@link - * #COMMAND_PREPARE_STOP_RELEASE}, {@link #COMMAND_SEEK_TO_DEFAULT_POSITION}, {@link + * #COMMAND_PREPARE_STOP}, {@link #COMMAND_SEEK_TO_DEFAULT_POSITION}, {@link * #COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM}, {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM}, {@link * #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}, {@link #COMMAND_SEEK_TO_MEDIA_ITEM}, {@link * #COMMAND_SET_SPEED_AND_PITCH}, {@link #COMMAND_SET_SHUFFLE_MODE}, {@link @@ -953,7 +953,7 @@ public interface Player { @Retention(RetentionPolicy.SOURCE) @IntDef({ COMMAND_PLAY_PAUSE, - COMMAND_PREPARE_STOP_RELEASE, + COMMAND_PREPARE_STOP, COMMAND_SEEK_TO_DEFAULT_POSITION, COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, @@ -979,7 +979,7 @@ public interface Player { /** Command to start, pause or resume playback. */ int COMMAND_PLAY_PAUSE = 1; /** Command to prepare the player, stop playback or release the player. */ - int COMMAND_PREPARE_STOP_RELEASE = 2; + int COMMAND_PREPARE_STOP = 2; /** Command to seek to the default position of the current window. */ int COMMAND_SEEK_TO_DEFAULT_POSITION = 3; /** Command to seek anywhere into the current window. */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java index cda5f48a19..c5f126a59f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java @@ -192,7 +192,7 @@ import java.util.concurrent.CopyOnWriteArraySet; new Commands.Builder() .addAll( COMMAND_PLAY_PAUSE, - COMMAND_PREPARE_STOP_RELEASE, + COMMAND_PREPARE_STOP, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_REPEAT_MODE, diff --git a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java index 666d0d4e65..96aa707880 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -25,7 +25,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_GET_MEDIA_ITEMS_METAD import static com.google.android.exoplayer2.Player.COMMAND_GET_TEXT; import static com.google.android.exoplayer2.Player.COMMAND_GET_VOLUME; import static com.google.android.exoplayer2.Player.COMMAND_PLAY_PAUSE; -import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP_RELEASE; +import static com.google.android.exoplayer2.Player.COMMAND_PREPARE_STOP; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_DEFAULT_POSITION; import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_MEDIA_ITEM; @@ -8074,7 +8074,7 @@ public final class ExoPlayerTest { player.addMediaSources(ImmutableList.of(new FakeMediaSource(), new FakeMediaSource())); assertThat(player.isCommandAvailable(COMMAND_PLAY_PAUSE)).isTrue(); - assertThat(player.isCommandAvailable(COMMAND_PREPARE_STOP_RELEASE)).isTrue(); + assertThat(player.isCommandAvailable(COMMAND_PREPARE_STOP)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_DEFAULT_POSITION)).isTrue(); assertThat(player.isCommandAvailable(COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM)).isFalse(); assertThat(player.isCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)).isTrue(); @@ -10269,7 +10269,7 @@ public final class ExoPlayerTest { Player.Commands.Builder builder = new Player.Commands.Builder(); builder.addAll( COMMAND_PLAY_PAUSE, - COMMAND_PREPARE_STOP_RELEASE, + COMMAND_PREPARE_STOP, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_REPEAT_MODE,