Add COMMAND_SET_MEDIA_ITEM to Player.Commands
Some Player implementations have no playlist capability but can still set a MediaItem for playback. Examples are a MediaController connected to a legacy MediaSession, ExoPlayer up to 2.12 or MediaPlayer. To indicate this capability, we need an allowed command in addition to COMMAND_CHANGE_MEDIA_ITEMS that just allows to set a single item that replaces everything that is currently played. #minor-release PiperOrigin-RevId: 453879626 (cherry picked from commit 2056152824512bcd8f2f09b2f7c1a752e913feac)
This commit is contained in:
parent
4e3617c2f1
commit
c1aff0dc8f
@ -100,7 +100,8 @@ public final class CastPlayer extends BasePlayer {
|
||||
COMMAND_GET_MEDIA_ITEMS_METADATA,
|
||||
COMMAND_SET_MEDIA_ITEMS_METADATA,
|
||||
COMMAND_CHANGE_MEDIA_ITEMS,
|
||||
COMMAND_GET_TRACKS)
|
||||
COMMAND_GET_TRACKS,
|
||||
COMMAND_SET_MEDIA_ITEM)
|
||||
.build();
|
||||
|
||||
public static final float MIN_SPEED_SUPPORTED = 0.5f;
|
||||
|
@ -36,6 +36,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT_MEDIA_IT
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_DEVICE_VOLUME;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEM;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEMS_METADATA;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_REPEAT_MODE;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE;
|
||||
@ -1359,6 +1360,7 @@ public class CastPlayerTest {
|
||||
assertThat(castPlayer.isCommandAvailable(COMMAND_GET_MEDIA_ITEMS_METADATA)).isTrue();
|
||||
assertThat(castPlayer.isCommandAvailable(COMMAND_SET_MEDIA_ITEMS_METADATA)).isTrue();
|
||||
assertThat(castPlayer.isCommandAvailable(COMMAND_CHANGE_MEDIA_ITEMS)).isTrue();
|
||||
assertThat(castPlayer.isCommandAvailable(COMMAND_SET_MEDIA_ITEM)).isTrue();
|
||||
assertThat(castPlayer.isCommandAvailable(COMMAND_GET_AUDIO_ATTRIBUTES)).isFalse();
|
||||
assertThat(castPlayer.isCommandAvailable(COMMAND_GET_VOLUME)).isFalse();
|
||||
assertThat(castPlayer.isCommandAvailable(COMMAND_GET_DEVICE_VOLUME)).isFalse();
|
||||
|
@ -383,6 +383,7 @@ public interface Player {
|
||||
COMMAND_GET_TEXT,
|
||||
COMMAND_SET_TRACK_SELECTION_PARAMETERS,
|
||||
COMMAND_GET_TRACKS,
|
||||
COMMAND_SET_MEDIA_ITEM,
|
||||
};
|
||||
|
||||
private final FlagSet.Builder flagsBuilder;
|
||||
@ -1392,7 +1393,8 @@ public interface Player {
|
||||
* #COMMAND_GET_VOLUME}, {@link #COMMAND_GET_DEVICE_VOLUME}, {@link #COMMAND_SET_VOLUME}, {@link
|
||||
* #COMMAND_SET_DEVICE_VOLUME}, {@link #COMMAND_ADJUST_DEVICE_VOLUME}, {@link
|
||||
* #COMMAND_SET_VIDEO_SURFACE}, {@link #COMMAND_GET_TEXT}, {@link
|
||||
* #COMMAND_SET_TRACK_SELECTION_PARAMETERS} or {@link #COMMAND_GET_TRACKS}.
|
||||
* #COMMAND_SET_TRACK_SELECTION_PARAMETERS}, {@link #COMMAND_GET_TRACKS} or {@link
|
||||
* #COMMAND_SET_MEDIA_ITEM}.
|
||||
*/
|
||||
// @Target list includes both 'default' targets and TYPE_USE, to ensure backwards compatibility
|
||||
// with Kotlin usages from before TYPE_USE was added.
|
||||
@ -1431,6 +1433,7 @@ public interface Player {
|
||||
COMMAND_GET_TEXT,
|
||||
COMMAND_SET_TRACK_SELECTION_PARAMETERS,
|
||||
COMMAND_GET_TRACKS,
|
||||
COMMAND_SET_MEDIA_ITEM,
|
||||
})
|
||||
@interface Command {}
|
||||
/** Command to start, pause or resume playback. */
|
||||
@ -1509,6 +1512,8 @@ public interface Player {
|
||||
int COMMAND_SET_TRACK_SELECTION_PARAMETERS = 29;
|
||||
/** Command to get details of the current track selection. */
|
||||
int COMMAND_GET_TRACKS = 30;
|
||||
/** Command to set a {@link MediaItem MediaItem}. */
|
||||
int COMMAND_SET_MEDIA_ITEM = 31;
|
||||
|
||||
/** Represents an invalid {@link Command}. */
|
||||
int COMMAND_INVALID = -1;
|
||||
|
@ -292,7 +292,8 @@ import java.util.concurrent.TimeoutException;
|
||||
COMMAND_SET_DEVICE_VOLUME,
|
||||
COMMAND_ADJUST_DEVICE_VOLUME,
|
||||
COMMAND_SET_VIDEO_SURFACE,
|
||||
COMMAND_GET_TEXT)
|
||||
COMMAND_GET_TEXT,
|
||||
COMMAND_SET_MEDIA_ITEM)
|
||||
.addIf(
|
||||
COMMAND_SET_TRACK_SELECTION_PARAMETERS, trackSelector.isSetParametersSupported())
|
||||
.build();
|
||||
|
@ -37,6 +37,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_NEXT_MEDIA_IT
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_DEVICE_VOLUME;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEM;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_MEDIA_ITEMS_METADATA;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_REPEAT_MODE;
|
||||
import static com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE;
|
||||
@ -8969,6 +8970,7 @@ public final class ExoPlayerTest {
|
||||
assertThat(player.isCommandAvailable(COMMAND_GET_MEDIA_ITEMS_METADATA)).isTrue();
|
||||
assertThat(player.isCommandAvailable(COMMAND_SET_MEDIA_ITEMS_METADATA)).isTrue();
|
||||
assertThat(player.isCommandAvailable(COMMAND_CHANGE_MEDIA_ITEMS)).isTrue();
|
||||
assertThat(player.isCommandAvailable(COMMAND_SET_MEDIA_ITEM)).isTrue();
|
||||
assertThat(player.isCommandAvailable(COMMAND_GET_AUDIO_ATTRIBUTES)).isTrue();
|
||||
assertThat(player.isCommandAvailable(COMMAND_GET_VOLUME)).isTrue();
|
||||
assertThat(player.isCommandAvailable(COMMAND_GET_DEVICE_VOLUME)).isTrue();
|
||||
@ -12118,6 +12120,7 @@ public final class ExoPlayerTest {
|
||||
COMMAND_GET_MEDIA_ITEMS_METADATA,
|
||||
COMMAND_SET_MEDIA_ITEMS_METADATA,
|
||||
COMMAND_CHANGE_MEDIA_ITEMS,
|
||||
COMMAND_SET_MEDIA_ITEM,
|
||||
COMMAND_GET_AUDIO_ATTRIBUTES,
|
||||
COMMAND_GET_VOLUME,
|
||||
COMMAND_GET_DEVICE_VOLUME,
|
||||
|
Loading…
x
Reference in New Issue
Block a user