Commit 851c915e by kimvde Committed by Ian Baker

Add COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM to available commands

PiperOrigin-RevId: 362036291
parent 383b6d42
......@@ -98,7 +98,10 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu
if (!timeline.isEmpty() && !player.isPlayingAd()) {
timeline.getWindow(player.getCurrentWindowIndex(), window);
enableSkipTo = timeline.getWindowCount() > 1;
enablePrevious = window.isSeekable || !window.isLive() || player.hasPrevious();
enablePrevious =
window.isSeekable
|| !window.isLive()
|| player.isCommandAvailable(Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
enableNext =
(window.isLive() && window.isDynamic)
|| player.isCommandAvailable(Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM);
......
......@@ -266,6 +266,9 @@ public abstract class BasePlayer implements Player {
}
protected Commands getAvailableCommands() {
return new Commands.Builder().addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNext()).build();
return new Commands.Builder()
.addIf(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, hasNext())
.addIf(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, hasPrevious())
.build();
}
}
......@@ -1031,14 +1031,16 @@ public interface Player {
/**
* Commands that can be executed on a {@code Player}. One of {@link
* #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM}.
* #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} or {@link #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({COMMAND_SEEK_TO_NEXT_MEDIA_ITEM})
@IntDef({COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM})
@interface Command {}
/** Command to seek to the next {@link MediaItem} in the playlist. */
int COMMAND_SEEK_TO_NEXT_MEDIA_ITEM = 0;
/** Command to seek to the previous {@link MediaItem} in the playlist. */
int COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM = 1;
/** Returns the component of this player for audio output, or null if audio is not supported. */
@Nullable
......
......@@ -913,7 +913,10 @@ public class PlayerControlView extends FrameLayout {
timeline.getWindow(player.getCurrentWindowIndex(), window);
boolean isSeekable = window.isSeekable;
enableSeeking = isSeekable;
enablePrevious = isSeekable || !window.isLive() || player.hasPrevious();
enablePrevious =
isSeekable
|| !window.isLive()
|| player.isCommandAvailable(Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
enableRewind = isSeekable && controlDispatcher.isRewindEnabled();
enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled();
enableNext =
......
......@@ -1460,7 +1460,10 @@ public class PlayerNotificationManager {
if (!timeline.isEmpty() && !player.isPlayingAd()) {
timeline.getWindow(player.getCurrentWindowIndex(), window);
boolean isSeekable = window.isSeekable;
enablePrevious = isSeekable || !window.isLive() || player.hasPrevious();
enablePrevious =
isSeekable
|| !window.isLive()
|| player.isCommandAvailable(Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
enableRewind = isSeekable && controlDispatcher.isRewindEnabled();
enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled();
enableNext =
......
......@@ -1148,7 +1148,10 @@ public class StyledPlayerControlView extends FrameLayout {
timeline.getWindow(player.getCurrentWindowIndex(), window);
boolean isSeekable = window.isSeekable;
enableSeeking = isSeekable;
enablePrevious = isSeekable || !window.isLive() || player.hasPrevious();
enablePrevious =
isSeekable
|| !window.isLive()
|| player.isCommandAvailable(Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM);
enableRewind = isSeekable && controlDispatcher.isRewindEnabled();
enableFastForward = isSeekable && controlDispatcher.isFastForwardEnabled();
enableNext =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment