Migrate media3.session references from Window to MediaItem
#minor-release PiperOrigin-RevId: 405927299
This commit is contained in:
parent
d83fe03d88
commit
f37e980018
@ -1270,7 +1270,7 @@ public class MediaController implements Player {
|
|||||||
@Override
|
@Override
|
||||||
public int getCurrentMediaItemIndex() {
|
public int getCurrentMediaItemIndex() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return isConnected() ? impl.getCurrentWindowIndex() : C.INDEX_UNSET;
|
return isConnected() ? impl.getCurrentMediaItemIndex() : C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -1291,7 +1291,7 @@ public class MediaController implements Player {
|
|||||||
@Override
|
@Override
|
||||||
public int getPreviousMediaItemIndex() {
|
public int getPreviousMediaItemIndex() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return isConnected() ? impl.getPreviousWindowIndex() : C.INDEX_UNSET;
|
return isConnected() ? impl.getPreviousMediaItemIndex() : C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -1312,7 +1312,7 @@ public class MediaController implements Player {
|
|||||||
@Override
|
@Override
|
||||||
public int getNextMediaItemIndex() {
|
public int getNextMediaItemIndex() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return isConnected() ? impl.getNextWindowIndex() : C.INDEX_UNSET;
|
return isConnected() ? impl.getNextMediaItemIndex() : C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -1348,13 +1348,13 @@ public class MediaController implements Player {
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasPreviousMediaItem() {
|
public boolean hasPreviousMediaItem() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return isConnected() && impl.hasPreviousWindow();
|
return isConnected() && impl.hasPreviousMediaItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNextMediaItem() {
|
public boolean hasNextMediaItem() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return isConnected() && impl.hasNextWindow();
|
return isConnected() && impl.hasNextMediaItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -1392,7 +1392,7 @@ public class MediaController implements Player {
|
|||||||
Log.w(TAG, "The controller is not connected. Ignoring seekToPreviousMediaItem().");
|
Log.w(TAG, "The controller is not connected. Ignoring seekToPreviousMediaItem().");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
impl.seekToPreviousWindow();
|
impl.seekToPreviousMediaItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -1416,7 +1416,7 @@ public class MediaController implements Player {
|
|||||||
Log.w(TAG, "The controller is not connected. Ignoring seekToNextMediaItem().");
|
Log.w(TAG, "The controller is not connected. Ignoring seekToNextMediaItem().");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
impl.seekToNextWindow();
|
impl.seekToNextMediaItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1824,7 +1824,6 @@ public class MediaController implements Player {
|
|||||||
checkState(Looper.myLooper() == getApplicationLooper(), WRONG_THREAD_ERROR_MESSAGE);
|
checkState(Looper.myLooper() == getApplicationLooper(), WRONG_THREAD_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/202157117): Rename Window references to MediaItem.
|
|
||||||
interface MediaControllerImpl {
|
interface MediaControllerImpl {
|
||||||
|
|
||||||
void addListener(Player.Listener listener);
|
void addListener(Player.Listener listener);
|
||||||
@ -1850,11 +1849,11 @@ public class MediaController implements Player {
|
|||||||
|
|
||||||
void seekToDefaultPosition();
|
void seekToDefaultPosition();
|
||||||
|
|
||||||
void seekToDefaultPosition(int windowIndex);
|
void seekToDefaultPosition(int mediaItemIndex);
|
||||||
|
|
||||||
void seekTo(long positionMs);
|
void seekTo(long positionMs);
|
||||||
|
|
||||||
void seekTo(int windowIndex, long positionMs);
|
void seekTo(int mediaItemIndex, long positionMs);
|
||||||
|
|
||||||
long getSeekBackIncrement();
|
long getSeekBackIncrement();
|
||||||
|
|
||||||
@ -1920,7 +1919,7 @@ public class MediaController implements Player {
|
|||||||
|
|
||||||
void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition);
|
void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition);
|
||||||
|
|
||||||
void setMediaItems(List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs);
|
void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs);
|
||||||
|
|
||||||
ListenableFuture<SessionResult> setMediaUri(Uri uri, Bundle extras);
|
ListenableFuture<SessionResult> setMediaUri(Uri uri, Bundle extras);
|
||||||
|
|
||||||
@ -1948,19 +1947,19 @@ public class MediaController implements Player {
|
|||||||
|
|
||||||
int getCurrentPeriodIndex();
|
int getCurrentPeriodIndex();
|
||||||
|
|
||||||
int getCurrentWindowIndex();
|
int getCurrentMediaItemIndex();
|
||||||
|
|
||||||
int getPreviousWindowIndex();
|
int getPreviousMediaItemIndex();
|
||||||
|
|
||||||
int getNextWindowIndex();
|
int getNextMediaItemIndex();
|
||||||
|
|
||||||
boolean hasPreviousWindow();
|
boolean hasPreviousMediaItem();
|
||||||
|
|
||||||
boolean hasNextWindow();
|
boolean hasNextMediaItem();
|
||||||
|
|
||||||
void seekToPreviousWindow();
|
void seekToPreviousMediaItem();
|
||||||
|
|
||||||
void seekToNextWindow();
|
void seekToNextMediaItem();
|
||||||
|
|
||||||
void seekToPrevious();
|
void seekToPrevious();
|
||||||
|
|
||||||
|
@ -488,11 +488,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
seekToInternal(getCurrentWindowIndex(), /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(getCurrentMediaItemIndex(), /* positionMs= */ C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToDefaultPosition(int windowIndex) {
|
public void seekToDefaultPosition(int mediaItemIndex) {
|
||||||
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)) {
|
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -502,11 +502,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
new RemoteSessionTask() {
|
new RemoteSessionTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run(IMediaSession iSession, int seq) throws RemoteException {
|
public void run(IMediaSession iSession, int seq) throws RemoteException {
|
||||||
iSession.seekToDefaultPositionWithMediaItemIndex(controllerStub, seq, windowIndex);
|
iSession.seekToDefaultPositionWithMediaItemIndex(controllerStub, seq, mediaItemIndex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
seekToInternal(windowIndex, /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(mediaItemIndex, /* positionMs= */ C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -524,11 +524,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
seekToInternal(getCurrentWindowIndex(), positionMs);
|
seekToInternal(getCurrentMediaItemIndex(), positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekTo(int windowIndex, long positionMs) {
|
public void seekTo(int mediaItemIndex, long positionMs) {
|
||||||
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)) {
|
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_MEDIA_ITEM)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -538,11 +538,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
new RemoteSessionTask() {
|
new RemoteSessionTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run(IMediaSession iSession, int seq) throws RemoteException {
|
public void run(IMediaSession iSession, int seq) throws RemoteException {
|
||||||
iSession.seekToWithMediaItemIndex(controllerStub, seq, windowIndex, positionMs);
|
iSession.seekToWithMediaItemIndex(controllerStub, seq, mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
seekToInternal(windowIndex, positionMs);
|
seekToInternal(mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -817,7 +817,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
setMediaItemsInternal(
|
setMediaItemsInternal(
|
||||||
Collections.singletonList(mediaItem),
|
Collections.singletonList(mediaItem),
|
||||||
/* startWindowIndex= */ C.INDEX_UNSET,
|
/* startIndex= */ C.INDEX_UNSET,
|
||||||
/* startPositionMs= */ C.TIME_UNSET,
|
/* startPositionMs= */ C.TIME_UNSET,
|
||||||
/* resetToDefaultPosition= */ false);
|
/* resetToDefaultPosition= */ false);
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
setMediaItemsInternal(
|
setMediaItemsInternal(
|
||||||
Collections.singletonList(mediaItem),
|
Collections.singletonList(mediaItem),
|
||||||
/* startWindowIndex= */ C.INDEX_UNSET,
|
/* startIndex= */ C.INDEX_UNSET,
|
||||||
/* startPositionMs= */ startPositionMs,
|
/* startPositionMs= */ startPositionMs,
|
||||||
/* resetToDefaultPosition= */ false);
|
/* resetToDefaultPosition= */ false);
|
||||||
}
|
}
|
||||||
@ -855,7 +855,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
setMediaItemsInternal(
|
setMediaItemsInternal(
|
||||||
Collections.singletonList(mediaItem),
|
Collections.singletonList(mediaItem),
|
||||||
/* startWindowIndex= */ C.INDEX_UNSET,
|
/* startIndex= */ C.INDEX_UNSET,
|
||||||
/* startPositionMs= */ C.TIME_UNSET,
|
/* startPositionMs= */ C.TIME_UNSET,
|
||||||
/* resetToDefaultPosition= */ resetPosition);
|
/* resetToDefaultPosition= */ resetPosition);
|
||||||
}
|
}
|
||||||
@ -876,7 +876,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
setMediaItemsInternal(
|
setMediaItemsInternal(
|
||||||
mediaItems,
|
mediaItems,
|
||||||
/* startWindowIndex= */ C.INDEX_UNSET,
|
/* startIndex= */ C.INDEX_UNSET,
|
||||||
/* startPositionMs= */ C.TIME_UNSET,
|
/* startPositionMs= */ C.TIME_UNSET,
|
||||||
/* resetToDefaultPosition= */ false);
|
/* resetToDefaultPosition= */ false);
|
||||||
}
|
}
|
||||||
@ -898,14 +898,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
setMediaItemsInternal(
|
setMediaItemsInternal(
|
||||||
mediaItems,
|
mediaItems,
|
||||||
/* startWindowIndex= */ C.INDEX_UNSET,
|
/* startIndex= */ C.INDEX_UNSET,
|
||||||
/* startPositionMs= */ C.TIME_UNSET,
|
/* startPositionMs= */ C.TIME_UNSET,
|
||||||
/* resetToDefaultPosition= */ resetPosition);
|
/* resetToDefaultPosition= */ resetPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMediaItems(
|
public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
|
||||||
List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs) {
|
|
||||||
if (!isPlayerCommandAvailable(COMMAND_CHANGE_MEDIA_ITEMS)) {
|
if (!isPlayerCommandAvailable(COMMAND_CHANGE_MEDIA_ITEMS)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -917,11 +916,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
controllerStub,
|
controllerStub,
|
||||||
seq,
|
seq,
|
||||||
new BundleListRetriever(BundleableUtil.toBundleList(mediaItems)),
|
new BundleListRetriever(BundleableUtil.toBundleList(mediaItems)),
|
||||||
startWindowIndex,
|
startIndex,
|
||||||
startPositionMs));
|
startPositionMs));
|
||||||
|
|
||||||
setMediaItemsInternal(
|
setMediaItemsInternal(
|
||||||
mediaItems, startWindowIndex, startPositionMs, /* resetToDefaultPosition= */ false);
|
mediaItems, startIndex, startPositionMs, /* resetToDefaultPosition= */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1132,39 +1131,39 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
rebuildPeriods(oldTimeline, newWindows, newPeriods);
|
rebuildPeriods(oldTimeline, newWindows, newPeriods);
|
||||||
Timeline newTimeline = createMaskingTimeline(newWindows, newPeriods);
|
Timeline newTimeline = createMaskingTimeline(newWindows, newPeriods);
|
||||||
|
|
||||||
int oldWindowIndex = getCurrentWindowIndex();
|
int oldMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
int newWindowIndex = oldWindowIndex;
|
int newMediaItemIndex = oldMediaItemIndex;
|
||||||
int oldPeriodIndex = playerInfo.sessionPositionInfo.positionInfo.periodIndex;
|
int oldPeriodIndex = playerInfo.sessionPositionInfo.positionInfo.periodIndex;
|
||||||
int newPeriodIndex = oldPeriodIndex;
|
int newPeriodIndex = oldPeriodIndex;
|
||||||
boolean currentItemRemoved =
|
boolean currentItemRemoved =
|
||||||
getCurrentWindowIndex() >= fromIndex && getCurrentWindowIndex() < clippedToIndex;
|
getCurrentMediaItemIndex() >= fromIndex && getCurrentMediaItemIndex() < clippedToIndex;
|
||||||
Window window = new Window();
|
Window window = new Window();
|
||||||
if (oldTimeline.isEmpty()) {
|
if (oldTimeline.isEmpty()) {
|
||||||
// No masking required. Just forwarding command to session.
|
// No masking required. Just forwarding command to session.
|
||||||
} else {
|
} else {
|
||||||
if (newTimeline.isEmpty()) {
|
if (newTimeline.isEmpty()) {
|
||||||
newWindowIndex = C.INDEX_UNSET;
|
newMediaItemIndex = C.INDEX_UNSET;
|
||||||
newPeriodIndex = 0;
|
newPeriodIndex = 0;
|
||||||
} else {
|
} else {
|
||||||
if (currentItemRemoved) {
|
if (currentItemRemoved) {
|
||||||
int oldNextWindowIndex =
|
int oldNextMediaItemIndex =
|
||||||
resolveSubsequentWindowIndex(
|
resolveSubsequentMediaItemIndex(
|
||||||
getRepeatMode(),
|
getRepeatMode(),
|
||||||
getShuffleModeEnabled(),
|
getShuffleModeEnabled(),
|
||||||
oldWindowIndex,
|
oldMediaItemIndex,
|
||||||
oldTimeline,
|
oldTimeline,
|
||||||
fromIndex,
|
fromIndex,
|
||||||
toIndex);
|
toIndex);
|
||||||
if (oldNextWindowIndex == C.INDEX_UNSET) {
|
if (oldNextMediaItemIndex == C.INDEX_UNSET) {
|
||||||
newWindowIndex = newTimeline.getFirstWindowIndex(getShuffleModeEnabled());
|
newMediaItemIndex = newTimeline.getFirstWindowIndex(getShuffleModeEnabled());
|
||||||
} else if (oldNextWindowIndex >= clippedToIndex) {
|
} else if (oldNextMediaItemIndex >= clippedToIndex) {
|
||||||
newWindowIndex = oldNextWindowIndex - (clippedToIndex - fromIndex);
|
newMediaItemIndex = oldNextMediaItemIndex - (clippedToIndex - fromIndex);
|
||||||
} else {
|
} else {
|
||||||
newWindowIndex = oldNextWindowIndex;
|
newMediaItemIndex = oldNextMediaItemIndex;
|
||||||
}
|
}
|
||||||
newPeriodIndex = newTimeline.getWindow(newWindowIndex, window).firstPeriodIndex;
|
newPeriodIndex = newTimeline.getWindow(newMediaItemIndex, window).firstPeriodIndex;
|
||||||
} else if (oldWindowIndex >= clippedToIndex) {
|
} else if (oldMediaItemIndex >= clippedToIndex) {
|
||||||
newWindowIndex -= (clippedToIndex - fromIndex);
|
newMediaItemIndex -= (clippedToIndex - fromIndex);
|
||||||
newPeriodIndex =
|
newPeriodIndex =
|
||||||
getNewPeriodIndexWithoutRemovedPeriods(
|
getNewPeriodIndexWithoutRemovedPeriods(
|
||||||
oldTimeline, oldPeriodIndex, fromIndex, clippedToIndex);
|
oldTimeline, oldPeriodIndex, fromIndex, clippedToIndex);
|
||||||
@ -1174,7 +1173,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
PlayerInfo newPlayerInfo;
|
PlayerInfo newPlayerInfo;
|
||||||
if (currentItemRemoved) {
|
if (currentItemRemoved) {
|
||||||
PositionInfo newPositionInfo;
|
PositionInfo newPositionInfo;
|
||||||
if (newWindowIndex == C.INDEX_UNSET) {
|
if (newMediaItemIndex == C.INDEX_UNSET) {
|
||||||
newPositionInfo = SessionPositionInfo.DEFAULT_POSITION_INFO;
|
newPositionInfo = SessionPositionInfo.DEFAULT_POSITION_INFO;
|
||||||
newPlayerInfo =
|
newPlayerInfo =
|
||||||
maskTimelineAndPositionInfo(
|
maskTimelineAndPositionInfo(
|
||||||
@ -1184,13 +1183,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
SessionPositionInfo.DEFAULT,
|
SessionPositionInfo.DEFAULT,
|
||||||
DISCONTINUITY_REASON_REMOVE);
|
DISCONTINUITY_REASON_REMOVE);
|
||||||
} else {
|
} else {
|
||||||
Window newWindow = newTimeline.getWindow(newWindowIndex, new Window());
|
Window newWindow = newTimeline.getWindow(newMediaItemIndex, new Window());
|
||||||
long defaultPositionMs = newWindow.getDefaultPositionMs();
|
long defaultPositionMs = newWindow.getDefaultPositionMs();
|
||||||
long durationMs = newWindow.getDurationMs();
|
long durationMs = newWindow.getDurationMs();
|
||||||
newPositionInfo =
|
newPositionInfo =
|
||||||
new PositionInfo(
|
new PositionInfo(
|
||||||
/* windowUid= */ null,
|
/* windowUid= */ null,
|
||||||
newWindowIndex,
|
newMediaItemIndex,
|
||||||
newWindow.mediaItem,
|
newWindow.mediaItem,
|
||||||
/* periodUid= */ null,
|
/* periodUid= */ null,
|
||||||
newPeriodIndex,
|
newPeriodIndex,
|
||||||
@ -1222,7 +1221,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
maskTimelineAndPositionInfo(
|
maskTimelineAndPositionInfo(
|
||||||
playerInfo,
|
playerInfo,
|
||||||
newTimeline,
|
newTimeline,
|
||||||
newWindowIndex,
|
newMediaItemIndex,
|
||||||
newPeriodIndex,
|
newPeriodIndex,
|
||||||
DISCONTINUITY_REASON_REMOVE);
|
DISCONTINUITY_REASON_REMOVE);
|
||||||
}
|
}
|
||||||
@ -1233,7 +1232,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
&& newPlayerInfo.playbackState != STATE_ENDED
|
&& newPlayerInfo.playbackState != STATE_ENDED
|
||||||
&& fromIndex < clippedToIndex
|
&& fromIndex < clippedToIndex
|
||||||
&& clippedToIndex == oldTimeline.getWindowCount()
|
&& clippedToIndex == oldTimeline.getWindowCount()
|
||||||
&& getCurrentWindowIndex() >= fromIndex;
|
&& getCurrentMediaItemIndex() >= fromIndex;
|
||||||
if (transitionsToEnded) {
|
if (transitionsToEnded) {
|
||||||
newPlayerInfo = newPlayerInfo.copyWithPlaybackState(STATE_ENDED, /* playerError= */ null);
|
newPlayerInfo = newPlayerInfo.copyWithPlaybackState(STATE_ENDED, /* playerError= */ null);
|
||||||
}
|
}
|
||||||
@ -1299,7 +1298,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCurrentWindowIndex() {
|
public int getCurrentMediaItemIndex() {
|
||||||
return playerInfo.sessionPositionInfo.positionInfo.mediaItemIndex == C.INDEX_UNSET
|
return playerInfo.sessionPositionInfo.positionInfo.mediaItemIndex == C.INDEX_UNSET
|
||||||
? 0
|
? 0
|
||||||
: playerInfo.sessionPositionInfo.positionInfo.mediaItemIndex;
|
: playerInfo.sessionPositionInfo.positionInfo.mediaItemIndex;
|
||||||
@ -1307,38 +1306,38 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
// TODO(b/184479406): Get the index directly from Player rather than Timeline.
|
// TODO(b/184479406): Get the index directly from Player rather than Timeline.
|
||||||
@Override
|
@Override
|
||||||
public int getPreviousWindowIndex() {
|
public int getPreviousMediaItemIndex() {
|
||||||
return playerInfo.timeline.isEmpty()
|
return playerInfo.timeline.isEmpty()
|
||||||
? C.INDEX_UNSET
|
? C.INDEX_UNSET
|
||||||
: playerInfo.timeline.getPreviousWindowIndex(
|
: playerInfo.timeline.getPreviousWindowIndex(
|
||||||
getCurrentWindowIndex(),
|
getCurrentMediaItemIndex(),
|
||||||
convertRepeatModeForNavigation(playerInfo.repeatMode),
|
convertRepeatModeForNavigation(playerInfo.repeatMode),
|
||||||
playerInfo.shuffleModeEnabled);
|
playerInfo.shuffleModeEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/184479406): Get the index directly from Player rather than Timeline.
|
// TODO(b/184479406): Get the index directly from Player rather than Timeline.
|
||||||
@Override
|
@Override
|
||||||
public int getNextWindowIndex() {
|
public int getNextMediaItemIndex() {
|
||||||
return playerInfo.timeline.isEmpty()
|
return playerInfo.timeline.isEmpty()
|
||||||
? C.INDEX_UNSET
|
? C.INDEX_UNSET
|
||||||
: playerInfo.timeline.getNextWindowIndex(
|
: playerInfo.timeline.getNextWindowIndex(
|
||||||
getCurrentWindowIndex(),
|
getCurrentMediaItemIndex(),
|
||||||
convertRepeatModeForNavigation(playerInfo.repeatMode),
|
convertRepeatModeForNavigation(playerInfo.repeatMode),
|
||||||
playerInfo.shuffleModeEnabled);
|
playerInfo.shuffleModeEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPreviousWindow() {
|
public boolean hasPreviousMediaItem() {
|
||||||
return getPreviousWindowIndex() != C.INDEX_UNSET;
|
return getPreviousMediaItemIndex() != C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNextWindow() {
|
public boolean hasNextMediaItem() {
|
||||||
return getNextWindowIndex() != C.INDEX_UNSET;
|
return getNextMediaItemIndex() != C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToPreviousWindow() {
|
public void seekToPreviousMediaItem() {
|
||||||
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)) {
|
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1347,13 +1346,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM,
|
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM,
|
||||||
(iSession, seq) -> iSession.seekToPreviousMediaItem(controllerStub, seq));
|
(iSession, seq) -> iSession.seekToPreviousMediaItem(controllerStub, seq));
|
||||||
|
|
||||||
if (getPreviousWindowIndex() != C.INDEX_UNSET) {
|
if (getPreviousMediaItemIndex() != C.INDEX_UNSET) {
|
||||||
seekToInternal(getPreviousWindowIndex(), /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(getPreviousMediaItemIndex(), /* positionMs= */ C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToNextWindow() {
|
public void seekToNextMediaItem() {
|
||||||
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)) {
|
if (!isPlayerCommandAvailable(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1362,8 +1361,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
|
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
|
||||||
(iSession, seq) -> iSession.seekToNextMediaItem(controllerStub, seq));
|
(iSession, seq) -> iSession.seekToNextMediaItem(controllerStub, seq));
|
||||||
|
|
||||||
if (getNextWindowIndex() != C.INDEX_UNSET) {
|
if (getNextMediaItemIndex() != C.INDEX_UNSET) {
|
||||||
seekToInternal(getNextWindowIndex(), /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(getNextMediaItemIndex(), /* positionMs= */ C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1380,16 +1379,16 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
if (timeline.isEmpty() || isPlayingAd()) {
|
if (timeline.isEmpty() || isPlayingAd()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean hasPreviousWindow = hasPreviousWindow();
|
boolean hasPreviousMediaItem = hasPreviousMediaItem();
|
||||||
Window window = timeline.getWindow(getCurrentWindowIndex(), new Window());
|
Window window = timeline.getWindow(getCurrentMediaItemIndex(), new Window());
|
||||||
if (window.isDynamic && window.isLive()) {
|
if (window.isDynamic && window.isLive()) {
|
||||||
if (hasPreviousWindow) {
|
if (hasPreviousMediaItem) {
|
||||||
seekToInternal(getPreviousWindowIndex(), /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(getPreviousMediaItemIndex(), /* positionMs= */ C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
} else if (hasPreviousWindow && getCurrentPosition() <= getMaxSeekToPreviousPosition()) {
|
} else if (hasPreviousMediaItem && getCurrentPosition() <= getMaxSeekToPreviousPosition()) {
|
||||||
seekToInternal(getPreviousWindowIndex(), /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(getPreviousMediaItemIndex(), /* positionMs= */ C.TIME_UNSET);
|
||||||
} else {
|
} else {
|
||||||
seekToInternal(getCurrentWindowIndex(), /* positionMs= */ 0);
|
seekToInternal(getCurrentMediaItemIndex(), /* positionMs= */ 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1411,12 +1410,12 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
if (timeline.isEmpty() || isPlayingAd()) {
|
if (timeline.isEmpty() || isPlayingAd()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasNextWindow()) {
|
if (hasNextMediaItem()) {
|
||||||
seekToInternal(getNextWindowIndex(), /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(getNextMediaItemIndex(), /* positionMs= */ C.TIME_UNSET);
|
||||||
} else {
|
} else {
|
||||||
Window window = timeline.getWindow(getCurrentWindowIndex(), new Window());
|
Window window = timeline.getWindow(getCurrentMediaItemIndex(), new Window());
|
||||||
if (window.isDynamic && window.isLive()) {
|
if (window.isDynamic && window.isLive()) {
|
||||||
seekToInternal(getCurrentWindowIndex(), /* positionMs= */ C.TIME_UNSET);
|
seekToInternal(getCurrentMediaItemIndex(), /* positionMs= */ C.TIME_UNSET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1944,7 +1943,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
Timeline newTimeline = createMaskingTimeline(newWindows, newPeriods);
|
Timeline newTimeline = createMaskingTimeline(newWindows, newPeriods);
|
||||||
|
|
||||||
if (!newTimeline.isEmpty()) {
|
if (!newTimeline.isEmpty()) {
|
||||||
int oldWindowIndex = getCurrentWindowIndex();
|
int oldWindowIndex = getCurrentMediaItemIndex();
|
||||||
int newWindowIndex = oldWindowIndex;
|
int newWindowIndex = oldWindowIndex;
|
||||||
if (oldWindowIndex >= fromIndex && oldWindowIndex < toIndex) {
|
if (oldWindowIndex >= fromIndex && oldWindowIndex < toIndex) {
|
||||||
// if old window index was part of items that should be moved.
|
// if old window index was part of items that should be moved.
|
||||||
@ -1991,7 +1990,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
positionMs = min(positionMs, durationMs);
|
positionMs = min(positionMs, durationMs);
|
||||||
}
|
}
|
||||||
positionMs = max(positionMs, 0);
|
positionMs = max(positionMs, 0);
|
||||||
seekToInternal(getCurrentWindowIndex(), positionMs);
|
seekToInternal(getCurrentMediaItemIndex(), positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seekToInternal(int windowIndex, long positionMs) {
|
private void seekToInternal(int windowIndex, long positionMs) {
|
||||||
@ -2865,28 +2864,28 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int resolveSubsequentWindowIndex(
|
private static int resolveSubsequentMediaItemIndex(
|
||||||
@RepeatMode int repeatMode,
|
@RepeatMode int repeatMode,
|
||||||
boolean shuffleModeEnabled,
|
boolean shuffleModeEnabled,
|
||||||
int oldWindowIndex,
|
int oldMediaItemIndex,
|
||||||
Timeline oldTimeline,
|
Timeline oldTimeline,
|
||||||
int fromIndex,
|
int fromIndex,
|
||||||
int toIndex) {
|
int toIndex) {
|
||||||
int newWindowIndex = C.INDEX_UNSET;
|
int newMediaItemIndex = C.INDEX_UNSET;
|
||||||
int maxIterations = oldTimeline.getWindowCount();
|
int maxIterations = oldTimeline.getWindowCount();
|
||||||
for (int i = 0; i < maxIterations; i++) {
|
for (int i = 0; i < maxIterations; i++) {
|
||||||
oldWindowIndex =
|
oldMediaItemIndex =
|
||||||
oldTimeline.getNextWindowIndex(oldWindowIndex, repeatMode, shuffleModeEnabled);
|
oldTimeline.getNextWindowIndex(oldMediaItemIndex, repeatMode, shuffleModeEnabled);
|
||||||
if (oldWindowIndex == C.INDEX_UNSET) {
|
if (oldMediaItemIndex == C.INDEX_UNSET) {
|
||||||
// We've reached the end of the old timeline.
|
// We've reached the end of the old timeline.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (oldWindowIndex < fromIndex || oldWindowIndex >= toIndex) {
|
if (oldMediaItemIndex < fromIndex || oldMediaItemIndex >= toIndex) {
|
||||||
newWindowIndex = oldWindowIndex;
|
newMediaItemIndex = oldMediaItemIndex;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newWindowIndex;
|
return newMediaItemIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will be called on the main thread.
|
// This will be called on the main thread.
|
||||||
|
@ -352,48 +352,49 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToDefaultPosition() {
|
public void seekToDefaultPosition() {
|
||||||
seekToInternal(getCurrentWindowIndex(), /* positionMs= */ 0);
|
seekToInternal(getCurrentMediaItemIndex(), /* positionMs= */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToDefaultPosition(int windowIndex) {
|
public void seekToDefaultPosition(int mediaItemIndex) {
|
||||||
seekToInternal(windowIndex, /* positionMs= */ 0);
|
seekToInternal(mediaItemIndex, /* positionMs= */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekTo(long positionMs) {
|
public void seekTo(long positionMs) {
|
||||||
seekToInternal(getCurrentWindowIndex(), positionMs);
|
seekToInternal(getCurrentMediaItemIndex(), positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekTo(int windowIndex, long positionMs) {
|
public void seekTo(int mediaItemIndex, long positionMs) {
|
||||||
seekToInternal(windowIndex, positionMs);
|
seekToInternal(mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seekToInternal(int windowIndex, long positionMs) {
|
private void seekToInternal(int mediaItemIndex, long positionMs) {
|
||||||
int currentWindowIndex = getCurrentWindowIndex();
|
int currentMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
Timeline currentTimeline = controllerInfo.playerInfo.timeline;
|
Timeline currentTimeline = controllerInfo.playerInfo.timeline;
|
||||||
if (currentWindowIndex != windowIndex
|
if (currentMediaItemIndex != mediaItemIndex
|
||||||
&& (windowIndex < 0 || windowIndex >= currentTimeline.getWindowCount())) {
|
&& (mediaItemIndex < 0 || mediaItemIndex >= currentTimeline.getWindowCount())) {
|
||||||
throw new IllegalSeekPositionException(currentTimeline, windowIndex, positionMs);
|
throw new IllegalSeekPositionException(currentTimeline, mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
if (isPlayingAd()) {
|
if (isPlayingAd()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int newWindowIndex = currentWindowIndex;
|
int newMediaItemIndex = currentMediaItemIndex;
|
||||||
@MediaItemTransitionReason int mediaItemTransitionReason = C.INDEX_UNSET;
|
@MediaItemTransitionReason int mediaItemTransitionReason = C.INDEX_UNSET;
|
||||||
if (windowIndex != currentWindowIndex) {
|
if (mediaItemIndex != currentMediaItemIndex) {
|
||||||
QueueTimeline queueTimeline = (QueueTimeline) controllerInfo.playerInfo.timeline;
|
QueueTimeline queueTimeline = (QueueTimeline) controllerInfo.playerInfo.timeline;
|
||||||
long queueId = queueTimeline.getQueueId(windowIndex);
|
long queueId = queueTimeline.getQueueId(mediaItemIndex);
|
||||||
if (queueId != QueueItem.UNKNOWN_ID) {
|
if (queueId != QueueItem.UNKNOWN_ID) {
|
||||||
controllerCompat.getTransportControls().skipToQueueItem(queueId);
|
controllerCompat.getTransportControls().skipToQueueItem(queueId);
|
||||||
newWindowIndex = windowIndex;
|
newMediaItemIndex = mediaItemIndex;
|
||||||
mediaItemTransitionReason = MEDIA_ITEM_TRANSITION_REASON_SEEK;
|
mediaItemTransitionReason = MEDIA_ITEM_TRANSITION_REASON_SEEK;
|
||||||
} else {
|
} else {
|
||||||
Log.w(
|
Log.w(
|
||||||
TAG,
|
TAG,
|
||||||
"Cannot seek to new window due to the missing queue Id at window, windowIndex="
|
"Cannot seek to new media item due to the missing queue Id at media item,"
|
||||||
+ windowIndex);
|
+ " mediaItemIndex="
|
||||||
|
+ mediaItemIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@DiscontinuityReason int discontinuityReason;
|
@DiscontinuityReason int discontinuityReason;
|
||||||
@ -433,9 +434,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
}
|
}
|
||||||
PositionInfo positionInfo =
|
PositionInfo positionInfo =
|
||||||
createPositionInfo(
|
createPositionInfo(
|
||||||
newWindowIndex,
|
newMediaItemIndex,
|
||||||
!currentTimeline.isEmpty()
|
!currentTimeline.isEmpty()
|
||||||
? currentTimeline.getWindow(newWindowIndex, new Window()).mediaItem
|
? currentTimeline.getWindow(newMediaItemIndex, new Window()).mediaItem
|
||||||
: null,
|
: null,
|
||||||
newPositionMs);
|
newPositionMs);
|
||||||
PlayerInfo maskedPlayerInfo =
|
PlayerInfo maskedPlayerInfo =
|
||||||
@ -522,7 +523,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCurrentLiveOffset() {
|
public long getCurrentLiveOffset() {
|
||||||
// We can't know whether it's live window or not.
|
// We can't know whether the content is live or not.
|
||||||
return C.TIME_UNSET;
|
return C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +676,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMediaItems(
|
public void setMediaItems(
|
||||||
List<MediaItem> unusedMediaItems, int unusedStartWindowIndex, long unusedStartPositionMs) {
|
List<MediaItem> unusedMediaItems, int unusedStartIndex, long unusedStartPositionMs) {
|
||||||
Log.w(TAG, "Session doesn't support setting media items");
|
Log.w(TAG, "Session doesn't support setting media items");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,11 +743,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
|
|
||||||
QueueTimeline queueTimeline = (QueueTimeline) controllerInfo.playerInfo.timeline;
|
QueueTimeline queueTimeline = (QueueTimeline) controllerInfo.playerInfo.timeline;
|
||||||
QueueTimeline newQueueTimeline = queueTimeline.copyWithNewMediaItems(index, mediaItems);
|
QueueTimeline newQueueTimeline = queueTimeline.copyWithNewMediaItems(index, mediaItems);
|
||||||
int currentWindowIndex = getCurrentWindowIndex();
|
int currentMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
int newCurrentWindowIndex =
|
int newCurrentMediaItemIndex =
|
||||||
calculateCurrentItemIndexAfterAddItems(currentWindowIndex, index, mediaItems.size());
|
calculateCurrentItemIndexAfterAddItems(currentMediaItemIndex, index, mediaItems.size());
|
||||||
PlayerInfo maskedPlayerInfo =
|
PlayerInfo maskedPlayerInfo =
|
||||||
controllerInfo.playerInfo.copyWithTimeline(newQueueTimeline, newCurrentWindowIndex);
|
controllerInfo.playerInfo.copyWithTimeline(newQueueTimeline, newCurrentMediaItemIndex);
|
||||||
ControllerInfo maskedControllerInfo =
|
ControllerInfo maskedControllerInfo =
|
||||||
new ControllerInfo(
|
new ControllerInfo(
|
||||||
maskedPlayerInfo,
|
maskedPlayerInfo,
|
||||||
@ -780,21 +781,21 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
|
|
||||||
QueueTimeline queueTimeline = (QueueTimeline) controllerInfo.playerInfo.timeline;
|
QueueTimeline queueTimeline = (QueueTimeline) controllerInfo.playerInfo.timeline;
|
||||||
QueueTimeline newQueueTimeline = queueTimeline.copyWithRemovedMediaItems(fromIndex, toIndex);
|
QueueTimeline newQueueTimeline = queueTimeline.copyWithRemovedMediaItems(fromIndex, toIndex);
|
||||||
int currentWindowIndex = getCurrentWindowIndex();
|
int currentMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
int newCurrentWindowIndex =
|
int newCurrentMediaItemIndex =
|
||||||
calculateCurrentItemIndexAfterRemoveItems(currentWindowIndex, fromIndex, toIndex);
|
calculateCurrentItemIndexAfterRemoveItems(currentMediaItemIndex, fromIndex, toIndex);
|
||||||
if (newCurrentWindowIndex == C.INDEX_UNSET) {
|
if (newCurrentMediaItemIndex == C.INDEX_UNSET) {
|
||||||
newCurrentWindowIndex =
|
newCurrentMediaItemIndex =
|
||||||
Util.constrainValue(fromIndex, /* min= */ 0, newQueueTimeline.getWindowCount() - 1);
|
Util.constrainValue(fromIndex, /* min= */ 0, newQueueTimeline.getWindowCount() - 1);
|
||||||
Log.w(
|
Log.w(
|
||||||
TAG,
|
TAG,
|
||||||
"Currently playing item is removed. Assumes item at "
|
"Currently playing item is removed. Assumes item at "
|
||||||
+ newCurrentWindowIndex
|
+ newCurrentMediaItemIndex
|
||||||
+ " is the"
|
+ " is the"
|
||||||
+ " new current item");
|
+ " new current item");
|
||||||
}
|
}
|
||||||
PlayerInfo maskedPlayerInfo =
|
PlayerInfo maskedPlayerInfo =
|
||||||
controllerInfo.playerInfo.copyWithTimeline(newQueueTimeline, newCurrentWindowIndex);
|
controllerInfo.playerInfo.copyWithTimeline(newQueueTimeline, newCurrentMediaItemIndex);
|
||||||
|
|
||||||
ControllerInfo maskedControllerInfo =
|
ControllerInfo maskedControllerInfo =
|
||||||
new ControllerInfo(
|
new ControllerInfo(
|
||||||
@ -834,27 +835,27 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
int lastItemIndexAfterRemove = size - moveItemsSize - 1;
|
int lastItemIndexAfterRemove = size - moveItemsSize - 1;
|
||||||
newIndex = min(newIndex, lastItemIndexAfterRemove);
|
newIndex = min(newIndex, lastItemIndexAfterRemove);
|
||||||
|
|
||||||
int currentWindowIndex = getCurrentWindowIndex();
|
int currentMediaItemIndex = getCurrentMediaItemIndex();
|
||||||
int currentWindowIndexAfterRemove =
|
int currentMediaItemIndexAfterRemove =
|
||||||
calculateCurrentItemIndexAfterRemoveItems(currentWindowIndex, fromIndex, toIndex);
|
calculateCurrentItemIndexAfterRemoveItems(currentMediaItemIndex, fromIndex, toIndex);
|
||||||
if (currentWindowIndexAfterRemove == C.INDEX_UNSET) {
|
if (currentMediaItemIndexAfterRemove == C.INDEX_UNSET) {
|
||||||
currentWindowIndexAfterRemove =
|
currentMediaItemIndexAfterRemove =
|
||||||
Util.constrainValue(fromIndex, /* min= */ 0, /* toIndex= */ lastItemIndexAfterRemove);
|
Util.constrainValue(fromIndex, /* min= */ 0, /* toIndex= */ lastItemIndexAfterRemove);
|
||||||
Log.w(
|
Log.w(
|
||||||
TAG,
|
TAG,
|
||||||
"Currently playing item will be removed and added back to mimic move."
|
"Currently playing item will be removed and added back to mimic move."
|
||||||
+ " Assumes item at "
|
+ " Assumes item at "
|
||||||
+ currentWindowIndexAfterRemove
|
+ currentMediaItemIndexAfterRemove
|
||||||
+ " would be the new current item");
|
+ " would be the new current item");
|
||||||
}
|
}
|
||||||
int newCurrentWindowIndex =
|
int newCurrentMediaItemIndex =
|
||||||
calculateCurrentItemIndexAfterAddItems(
|
calculateCurrentItemIndexAfterAddItems(
|
||||||
currentWindowIndexAfterRemove, newIndex, moveItemsSize);
|
currentMediaItemIndexAfterRemove, newIndex, moveItemsSize);
|
||||||
|
|
||||||
QueueTimeline newQueueTimeline =
|
QueueTimeline newQueueTimeline =
|
||||||
queueTimeline.copyWithMovedMediaItems(fromIndex, toIndex, newIndex);
|
queueTimeline.copyWithMovedMediaItems(fromIndex, toIndex, newIndex);
|
||||||
PlayerInfo maskedPlayerInfo =
|
PlayerInfo maskedPlayerInfo =
|
||||||
controllerInfo.playerInfo.copyWithTimeline(newQueueTimeline, newCurrentWindowIndex);
|
controllerInfo.playerInfo.copyWithTimeline(newQueueTimeline, newCurrentMediaItemIndex);
|
||||||
|
|
||||||
ControllerInfo maskedControllerInfo =
|
ControllerInfo maskedControllerInfo =
|
||||||
new ControllerInfo(
|
new ControllerInfo(
|
||||||
@ -880,55 +881,55 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCurrentPeriodIndex() {
|
public int getCurrentPeriodIndex() {
|
||||||
return getCurrentWindowIndex();
|
return getCurrentMediaItemIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCurrentWindowIndex() {
|
public int getCurrentMediaItemIndex() {
|
||||||
return controllerInfo.playerInfo.sessionPositionInfo.positionInfo.mediaItemIndex;
|
return controllerInfo.playerInfo.sessionPositionInfo.positionInfo.mediaItemIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreviousWindowIndex() {
|
public int getPreviousMediaItemIndex() {
|
||||||
return C.INDEX_UNSET;
|
return C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNextWindowIndex() {
|
public int getNextMediaItemIndex() {
|
||||||
return C.INDEX_UNSET;
|
return C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPreviousWindow() {
|
public boolean hasPreviousMediaItem() {
|
||||||
return connected;
|
return connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNextWindow() {
|
public boolean hasNextMediaItem() {
|
||||||
return connected;
|
return connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToPreviousWindow() {
|
public void seekToPreviousMediaItem() {
|
||||||
// Intentionally don't do state masking when current window index is uncertain.
|
// Intentionally don't do state masking when current media item index is uncertain.
|
||||||
controllerCompat.getTransportControls().skipToPrevious();
|
controllerCompat.getTransportControls().skipToPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToNextWindow() {
|
public void seekToNextMediaItem() {
|
||||||
// Intentionally don't do state masking when current window index is uncertain.
|
// Intentionally don't do state masking when current media item index is uncertain.
|
||||||
controllerCompat.getTransportControls().skipToNext();
|
controllerCompat.getTransportControls().skipToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToPrevious() {
|
public void seekToPrevious() {
|
||||||
// Intentionally don't do state masking when current window index is uncertain.
|
// Intentionally don't do state masking when current media item index is uncertain.
|
||||||
controllerCompat.getTransportControls().skipToPrevious();
|
controllerCompat.getTransportControls().skipToPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToNext() {
|
public void seekToNext() {
|
||||||
// Intentionally don't do state masking when current window index is uncertain.
|
// Intentionally don't do state masking when current media item index is uncertain.
|
||||||
controllerCompat.getTransportControls().skipToNext();
|
controllerCompat.getTransportControls().skipToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1712,9 +1713,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
currentMediaItemIndex = currentTimeline.getWindowCount() - 1;
|
currentMediaItemIndex = currentTimeline.getWindowCount() - 1;
|
||||||
} else {
|
} else {
|
||||||
currentTimeline = currentTimeline.copyWithFakeMediaItem(/* fakeMediaItem= */ null);
|
currentTimeline = currentTimeline.copyWithFakeMediaItem(/* fakeMediaItem= */ null);
|
||||||
// Shouldn't be C.INDEX_UNSET to make getCurrentWindowIndex() return masked index.
|
// Shouldn't be C.INDEX_UNSET to make getCurrentMediaItemIndex() return masked index.
|
||||||
// In other words, this index is either the currently playing window index or the would-be
|
// In other words, this index is either the currently playing media item index or the
|
||||||
// playing index when playing.
|
// would-be playing index when playing.
|
||||||
currentMediaItemIndex = 0;
|
currentMediaItemIndex = 0;
|
||||||
}
|
}
|
||||||
} else if (currentMediaItemIndex != C.INDEX_UNSET) {
|
} else if (currentMediaItemIndex != C.INDEX_UNSET) {
|
||||||
@ -2044,13 +2045,13 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PositionInfo createPositionInfo(
|
private static PositionInfo createPositionInfo(
|
||||||
int windowIndex, @Nullable MediaItem mediaItem, long currentPositionMs) {
|
int mediaItemIndex, @Nullable MediaItem mediaItem, long currentPositionMs) {
|
||||||
return new PositionInfo(
|
return new PositionInfo(
|
||||||
/* windowUid= */ null,
|
/* windowUid= */ null,
|
||||||
/* windowIndex= */ windowIndex,
|
/* mediaItemIndex= */ mediaItemIndex,
|
||||||
mediaItem,
|
mediaItem,
|
||||||
/* periodUid= */ null,
|
/* periodUid= */ null,
|
||||||
/* periodIndex= */ windowIndex,
|
/* periodIndex= */ mediaItemIndex,
|
||||||
/* positionMs= */ currentPositionMs,
|
/* positionMs= */ currentPositionMs,
|
||||||
/* contentPositionMs= */ currentPositionMs,
|
/* contentPositionMs= */ currentPositionMs,
|
||||||
/* adGroupIndex= */ C.INDEX_UNSET,
|
/* adGroupIndex= */ C.INDEX_UNSET,
|
||||||
|
@ -34,9 +34,9 @@ interface IRemoteMediaController {
|
|||||||
void setPlayWhenReady(String controllerId, boolean playWhenReady);
|
void setPlayWhenReady(String controllerId, boolean playWhenReady);
|
||||||
void prepare(String controllerId);
|
void prepare(String controllerId);
|
||||||
void seekToDefaultPosition(String controllerId);
|
void seekToDefaultPosition(String controllerId);
|
||||||
void seekToDefaultPositionWithWindowIndex(String controllerId, int windowIndex);
|
void seekToDefaultPositionWithMediaItemIndex(String controllerId, int mediaItemIndex);
|
||||||
void seekTo(String controllerId, long positionMs);
|
void seekTo(String controllerId, long positionMs);
|
||||||
void seekToWithWindowIndex(String controllerId, int windowIndex, long positionMs);
|
void seekToWithMediaItemIndex(String controllerId, int mediaItemIndex, long positionMs);
|
||||||
void seekBack(String controllerId);
|
void seekBack(String controllerId);
|
||||||
void seekForward(String controllerId);
|
void seekForward(String controllerId);
|
||||||
void setPlaybackParameters(String controllerId, in Bundle playbackParametersBundle);
|
void setPlaybackParameters(String controllerId, in Bundle playbackParametersBundle);
|
||||||
@ -49,8 +49,8 @@ interface IRemoteMediaController {
|
|||||||
void setMediaItems(String controllerId, in List<Bundle> mediaItems);
|
void setMediaItems(String controllerId, in List<Bundle> mediaItems);
|
||||||
void setMediaItemsWithResetPosition(
|
void setMediaItemsWithResetPosition(
|
||||||
String controllerId, in List<Bundle> mediaItems, boolean resetPosition);
|
String controllerId, in List<Bundle> mediaItems, boolean resetPosition);
|
||||||
void setMediaItemsWithStartWindowIndex(
|
void setMediaItemsWithStartIndex(
|
||||||
String controllerId, in List<Bundle> mediaItems, int startWindowIndex, long startPositionMs);
|
String controllerId, in List<Bundle> mediaItems, int startIndex, long startPositionMs);
|
||||||
void createAndSetFakeMediaItems(String controllerId, int size);
|
void createAndSetFakeMediaItems(String controllerId, int size);
|
||||||
void setMediaUri(String controllerId, in Uri uri, in Bundle extras);
|
void setMediaUri(String controllerId, in Uri uri, in Bundle extras);
|
||||||
void setPlaylistMetadata(String controllerId, in Bundle playlistMetadata);
|
void setPlaylistMetadata(String controllerId, in Bundle playlistMetadata);
|
||||||
@ -63,8 +63,8 @@ interface IRemoteMediaController {
|
|||||||
void clearMediaItems(String controllerId);
|
void clearMediaItems(String controllerId);
|
||||||
void moveMediaItem(String controllerId, int currentIndex, int newIndex);
|
void moveMediaItem(String controllerId, int currentIndex, int newIndex);
|
||||||
void moveMediaItems(String controllerId, int fromIndex, int toIndex, int newIndex);
|
void moveMediaItems(String controllerId, int fromIndex, int toIndex, int newIndex);
|
||||||
void seekToPreviousWindow(String controllerId);
|
void seekToPreviousMediaItem(String controllerId);
|
||||||
void seekToNextWindow(String controllerId);
|
void seekToNextMediaItem(String controllerId);
|
||||||
void seekToPrevious(String controllerId);
|
void seekToPrevious(String controllerId);
|
||||||
void seekToNext(String controllerId);
|
void seekToNext(String controllerId);
|
||||||
void setShuffleModeEnabled(String controllerId, boolean shuffleModeEnabled);
|
void setShuffleModeEnabled(String controllerId, boolean shuffleModeEnabled);
|
||||||
|
@ -69,7 +69,7 @@ interface IRemoteMediaSession {
|
|||||||
void setPlaylistMetadata(String sessionId, in Bundle metadata);
|
void setPlaylistMetadata(String sessionId, in Bundle metadata);
|
||||||
void setShuffleModeEnabled(String sessionId, boolean shuffleMode);
|
void setShuffleModeEnabled(String sessionId, boolean shuffleMode);
|
||||||
void setRepeatMode(String sessionId, int repeatMode);
|
void setRepeatMode(String sessionId, int repeatMode);
|
||||||
void setCurrentWindowIndex(String sessionId, int index);
|
void setCurrentMediaItemIndex(String sessionId, int index);
|
||||||
void setTrackSelectionParameters(String sessionId, in Bundle parameters);
|
void setTrackSelectionParameters(String sessionId, in Bundle parameters);
|
||||||
void notifyTimelineChanged(String sessionId, int reason);
|
void notifyTimelineChanged(String sessionId, int reason);
|
||||||
void notifyPlaylistMetadataChanged(String sessionId);
|
void notifyPlaylistMetadataChanged(String sessionId);
|
||||||
|
@ -68,7 +68,7 @@ public class CommonConstants {
|
|||||||
public static final String KEY_PLAYER_ERROR = "playerError";
|
public static final String KEY_PLAYER_ERROR = "playerError";
|
||||||
public static final String KEY_AUDIO_ATTRIBUTES = "audioAttributes";
|
public static final String KEY_AUDIO_ATTRIBUTES = "audioAttributes";
|
||||||
public static final String KEY_TIMELINE = "timeline";
|
public static final String KEY_TIMELINE = "timeline";
|
||||||
public static final String KEY_CURRENT_WINDOW_INDEX = "currentWindowIndex";
|
public static final String KEY_CURRENT_MEDIA_ITEM_INDEX = "currentMediaItemIndex";
|
||||||
public static final String KEY_CURRENT_PERIOD_INDEX = "currentPeriodIndex";
|
public static final String KEY_CURRENT_PERIOD_INDEX = "currentPeriodIndex";
|
||||||
public static final String KEY_DURATION = "duration";
|
public static final String KEY_DURATION = "duration";
|
||||||
public static final String KEY_CURRENT_POSITION = "currentPosition";
|
public static final String KEY_CURRENT_POSITION = "currentPosition";
|
||||||
|
@ -126,7 +126,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
|
|||||||
.setPlaybackParameters(new PlaybackParameters(testSpeed))
|
.setPlaybackParameters(new PlaybackParameters(testSpeed))
|
||||||
.setTimeline(testTimeline)
|
.setTimeline(testTimeline)
|
||||||
.setPlaylistMetadata(testPlaylistMetadata)
|
.setPlaylistMetadata(testPlaylistMetadata)
|
||||||
.setCurrentWindowIndex(testItemIndex)
|
.setCurrentMediaItemIndex(testItemIndex)
|
||||||
.setShuffleModeEnabled(testShuffleModeEnabled)
|
.setShuffleModeEnabled(testShuffleModeEnabled)
|
||||||
.setRepeatMode(testRepeatMode)
|
.setRepeatMode(testRepeatMode)
|
||||||
.build();
|
.build();
|
||||||
@ -370,7 +370,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
|
|||||||
.setPlaybackParameters(playbackParameters)
|
.setPlaybackParameters(playbackParameters)
|
||||||
.setTimeline(testTimeline)
|
.setTimeline(testTimeline)
|
||||||
.setPlaylistMetadata(testPlaylistMetadata)
|
.setPlaylistMetadata(testPlaylistMetadata)
|
||||||
.setCurrentWindowIndex(testItemIndex)
|
.setCurrentMediaItemIndex(testItemIndex)
|
||||||
.setShuffleModeEnabled(testShuffleModeEnabled)
|
.setShuffleModeEnabled(testShuffleModeEnabled)
|
||||||
.setRepeatMode(testRepeatMode)
|
.setRepeatMode(testRepeatMode)
|
||||||
.build();
|
.build();
|
||||||
@ -802,7 +802,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
|
|||||||
};
|
};
|
||||||
controllerCompat.registerCallback(callback, handler);
|
controllerCompat.registerCallback(callback, handler);
|
||||||
|
|
||||||
session.getMockPlayer().setCurrentWindowIndex(testItemIndex);
|
session.getMockPlayer().setCurrentMediaItemIndex(testItemIndex);
|
||||||
session.getMockPlayer().setCurrentPosition(testPosition);
|
session.getMockPlayer().setCurrentPosition(testPosition);
|
||||||
session
|
session
|
||||||
.getMockPlayer()
|
.getMockPlayer()
|
||||||
|
@ -455,7 +455,7 @@ public class MediaControllerListenerTest {
|
|||||||
.setIsPlayingAd(testIsPlayingAd)
|
.setIsPlayingAd(testIsPlayingAd)
|
||||||
.setCurrentAdGroupIndex(testCurrentAdGroupIndex)
|
.setCurrentAdGroupIndex(testCurrentAdGroupIndex)
|
||||||
.setCurrentAdIndexInAdGroup(testCurrentAdIndexInAdGroup)
|
.setCurrentAdIndexInAdGroup(testCurrentAdIndexInAdGroup)
|
||||||
.setCurrentWindowIndex(testWindowIndex)
|
.setCurrentMediaItemIndex(testWindowIndex)
|
||||||
.setCurrentPeriodIndex(testPeriodIndex)
|
.setCurrentPeriodIndex(testPeriodIndex)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
@ -485,7 +485,7 @@ public class MediaControllerListenerTest {
|
|||||||
remoteSession
|
remoteSession
|
||||||
.getMockPlayer()
|
.getMockPlayer()
|
||||||
.notifyTimelineChanged(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
|
.notifyTimelineChanged(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
|
||||||
remoteSession.getMockPlayer().setCurrentWindowIndex(currentIndex);
|
remoteSession.getMockPlayer().setCurrentMediaItemIndex(currentIndex);
|
||||||
remoteSession
|
remoteSession
|
||||||
.getMockPlayer()
|
.getMockPlayer()
|
||||||
.notifyMediaItemTransition(
|
.notifyMediaItemTransition(
|
||||||
@ -514,7 +514,7 @@ public class MediaControllerListenerTest {
|
|||||||
}));
|
}));
|
||||||
int testIndex = 3;
|
int testIndex = 3;
|
||||||
int testReason = Player.MEDIA_ITEM_TRANSITION_REASON_SEEK;
|
int testReason = Player.MEDIA_ITEM_TRANSITION_REASON_SEEK;
|
||||||
remoteSession.getMockPlayer().setCurrentWindowIndex(testIndex);
|
remoteSession.getMockPlayer().setCurrentMediaItemIndex(testIndex);
|
||||||
remoteSession.getMockPlayer().notifyMediaItemTransition(testIndex, testReason);
|
remoteSession.getMockPlayer().notifyMediaItemTransition(testIndex, testReason);
|
||||||
Timeline.Window window = new Timeline.Window();
|
Timeline.Window window = new Timeline.Window();
|
||||||
MediaItem currentMediaItem = timeline.getWindow(testIndex, window).mediaItem;
|
MediaItem currentMediaItem = timeline.getWindow(testIndex, window).mediaItem;
|
||||||
@ -529,7 +529,7 @@ public class MediaControllerListenerTest {
|
|||||||
public void onMediaItemTransition_withNullMediaItem() throws Exception {
|
public void onMediaItemTransition_withNullMediaItem() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 1);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 1);
|
||||||
remoteSession.getMockPlayer().setTimeline(timeline);
|
remoteSession.getMockPlayer().setTimeline(timeline);
|
||||||
remoteSession.getMockPlayer().setCurrentWindowIndex(0);
|
remoteSession.getMockPlayer().setCurrentMediaItemIndex(0);
|
||||||
remoteSession
|
remoteSession
|
||||||
.getMockPlayer()
|
.getMockPlayer()
|
||||||
.notifyMediaItemTransition(0, Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED);
|
.notifyMediaItemTransition(0, Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED);
|
||||||
@ -820,7 +820,7 @@ public class MediaControllerListenerTest {
|
|||||||
/* shuffledIndices= */ new int[] {0, 2, 1});
|
/* shuffledIndices= */ new int[] {0, 2, 1});
|
||||||
player.setTimeline(timeline);
|
player.setTimeline(timeline);
|
||||||
player.notifyTimelineChanged(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
|
player.notifyTimelineChanged(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
|
||||||
player.setCurrentWindowIndex(2);
|
player.setCurrentMediaItemIndex(2);
|
||||||
player.setShuffleModeEnabled(false);
|
player.setShuffleModeEnabled(false);
|
||||||
player.notifyShuffleModeEnabledChanged();
|
player.notifyShuffleModeEnabledChanged();
|
||||||
|
|
||||||
@ -860,7 +860,7 @@ public class MediaControllerListenerTest {
|
|||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
player.setTimeline(timeline);
|
player.setTimeline(timeline);
|
||||||
player.notifyTimelineChanged(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
|
player.notifyTimelineChanged(Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
|
||||||
player.setCurrentWindowIndex(2);
|
player.setCurrentMediaItemIndex(2);
|
||||||
player.setRepeatMode(Player.REPEAT_MODE_OFF);
|
player.setRepeatMode(Player.REPEAT_MODE_OFF);
|
||||||
player.notifyRepeatModeChanged();
|
player.notifyRepeatModeChanged();
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -246,9 +246,9 @@ public class MediaControllerTest {
|
|||||||
TrackSelectionParameters trackSelectionParameters =
|
TrackSelectionParameters trackSelectionParameters =
|
||||||
TrackSelectionParameters.DEFAULT_WITHOUT_CONTEXT.buildUpon().setMaxVideoSizeSd().build();
|
TrackSelectionParameters.DEFAULT_WITHOUT_CONTEXT.buildUpon().setMaxVideoSizeSd().build();
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(5);
|
Timeline timeline = MediaTestUtils.createTimeline(5);
|
||||||
int currentWindowIndex = 3;
|
int currentMediaItemIndex = 3;
|
||||||
MediaItem currentMediaItem =
|
MediaItem currentMediaItem =
|
||||||
timeline.getWindow(currentWindowIndex, new Timeline.Window()).mediaItem;
|
timeline.getWindow(currentMediaItemIndex, new Timeline.Window()).mediaItem;
|
||||||
|
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
@ -277,7 +277,7 @@ public class MediaControllerTest {
|
|||||||
.setMaxSeekToPreviousPositionMs(maxSeekToPreviousPositionMs)
|
.setMaxSeekToPreviousPositionMs(maxSeekToPreviousPositionMs)
|
||||||
.setTrackSelectionParameters(trackSelectionParameters)
|
.setTrackSelectionParameters(trackSelectionParameters)
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(currentWindowIndex)
|
.setCurrentMediaItemIndex(currentMediaItemIndex)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
@ -309,7 +309,7 @@ public class MediaControllerTest {
|
|||||||
AtomicLong maxSeekToPreviousPositionMsRef = new AtomicLong();
|
AtomicLong maxSeekToPreviousPositionMsRef = new AtomicLong();
|
||||||
AtomicReference<TrackSelectionParameters> trackSelectionParametersRef = new AtomicReference<>();
|
AtomicReference<TrackSelectionParameters> trackSelectionParametersRef = new AtomicReference<>();
|
||||||
AtomicReference<Timeline> timelineRef = new AtomicReference<>();
|
AtomicReference<Timeline> timelineRef = new AtomicReference<>();
|
||||||
AtomicInteger currentWindowIndexRef = new AtomicInteger();
|
AtomicInteger currentMediaItemIndexRef = new AtomicInteger();
|
||||||
AtomicReference<MediaItem> currentMediaItemRef = new AtomicReference<>();
|
AtomicReference<MediaItem> currentMediaItemRef = new AtomicReference<>();
|
||||||
threadTestRule
|
threadTestRule
|
||||||
.getHandler()
|
.getHandler()
|
||||||
@ -341,7 +341,7 @@ public class MediaControllerTest {
|
|||||||
maxSeekToPreviousPositionMsRef.set(controller.getMaxSeekToPreviousPosition());
|
maxSeekToPreviousPositionMsRef.set(controller.getMaxSeekToPreviousPosition());
|
||||||
trackSelectionParametersRef.set(controller.getTrackSelectionParameters());
|
trackSelectionParametersRef.set(controller.getTrackSelectionParameters());
|
||||||
timelineRef.set(controller.getCurrentTimeline());
|
timelineRef.set(controller.getCurrentTimeline());
|
||||||
currentWindowIndexRef.set(controller.getCurrentWindowIndex());
|
currentMediaItemIndexRef.set(controller.getCurrentMediaItemIndex());
|
||||||
currentMediaItemRef.set(controller.getCurrentMediaItem());
|
currentMediaItemRef.set(controller.getCurrentMediaItem());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -370,7 +370,7 @@ public class MediaControllerTest {
|
|||||||
assertThat(maxSeekToPreviousPositionMsRef.get()).isEqualTo(maxSeekToPreviousPositionMs);
|
assertThat(maxSeekToPreviousPositionMsRef.get()).isEqualTo(maxSeekToPreviousPositionMs);
|
||||||
assertThat(trackSelectionParametersRef.get()).isEqualTo(trackSelectionParameters);
|
assertThat(trackSelectionParametersRef.get()).isEqualTo(trackSelectionParameters);
|
||||||
assertTimelineMediaItemsEquals(timelineRef.get(), timeline);
|
assertTimelineMediaItemsEquals(timelineRef.get(), timeline);
|
||||||
assertThat(currentWindowIndexRef.get()).isEqualTo(currentWindowIndex);
|
assertThat(currentMediaItemIndexRef.get()).isEqualTo(currentMediaItemIndex);
|
||||||
assertThat(currentMediaItemRef.get()).isEqualTo(currentMediaItem);
|
assertThat(currentMediaItemRef.get()).isEqualTo(currentMediaItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,19 +509,19 @@ public class MediaControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCurrentWindowIndex() throws Exception {
|
public void getCurrentMediaItemIndex() throws Exception {
|
||||||
int testWindowIndex = 1;
|
int testMediaItemIndex = 1;
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setCurrentWindowIndex(testWindowIndex)
|
.setCurrentMediaItemIndex(testMediaItemIndex)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int currentWindowIndex =
|
int currentMediaItemIndex =
|
||||||
threadTestRule.getHandler().postAndSync(controller::getCurrentWindowIndex);
|
threadTestRule.getHandler().postAndSync(controller::getCurrentMediaItemIndex);
|
||||||
|
|
||||||
assertThat(currentWindowIndex).isEqualTo(testWindowIndex);
|
assertThat(currentMediaItemIndex).isEqualTo(testMediaItemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -541,83 +541,83 @@ public class MediaControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPreviousWindowIndex() throws Exception {
|
public void getPreviousMediaItemIndex() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(1)
|
.setCurrentMediaItemIndex(1)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int previousWindowIndex =
|
int previousMediaItemIndex =
|
||||||
threadTestRule.getHandler().postAndSync(controller::getPreviousWindowIndex);
|
threadTestRule.getHandler().postAndSync(controller::getPreviousMediaItemIndex);
|
||||||
|
|
||||||
assertThat(previousWindowIndex).isEqualTo(0);
|
assertThat(previousMediaItemIndex).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPreviousWindowIndex_withRepeatModeOne() throws Exception {
|
public void getPreviousMediaItemIndex_withRepeatModeOne() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(1)
|
.setCurrentMediaItemIndex(1)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_ONE)
|
.setRepeatMode(Player.REPEAT_MODE_ONE)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int previousWindowIndex =
|
int previousMediaItemIndex =
|
||||||
threadTestRule.getHandler().postAndSync(controller::getPreviousWindowIndex);
|
threadTestRule.getHandler().postAndSync(controller::getPreviousMediaItemIndex);
|
||||||
|
|
||||||
assertThat(previousWindowIndex).isEqualTo(0);
|
assertThat(previousMediaItemIndex).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPreviousWindowIndex_atTheFirstWindow() throws Exception {
|
public void getPreviousMediaItemIndex_atTheFirstMediaItem() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(0)
|
.setCurrentMediaItemIndex(0)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int previousWindowIndex =
|
int previousMediaItemIndex =
|
||||||
threadTestRule.getHandler().postAndSync(controller::getPreviousWindowIndex);
|
threadTestRule.getHandler().postAndSync(controller::getPreviousMediaItemIndex);
|
||||||
|
|
||||||
assertThat(previousWindowIndex).isEqualTo(C.INDEX_UNSET);
|
assertThat(previousMediaItemIndex).isEqualTo(C.INDEX_UNSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPreviousWindowIndex_atTheFirstWindowWithRepeatModeAll() throws Exception {
|
public void getPreviousMediaItemIndex_atTheFirstMediaItemWithRepeatModeAll() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(0)
|
.setCurrentMediaItemIndex(0)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_ALL)
|
.setRepeatMode(Player.REPEAT_MODE_ALL)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int previousWindowIndex =
|
int previousMediaItemIndex =
|
||||||
threadTestRule.getHandler().postAndSync(controller::getPreviousWindowIndex);
|
threadTestRule.getHandler().postAndSync(controller::getPreviousMediaItemIndex);
|
||||||
|
|
||||||
assertThat(previousWindowIndex).isEqualTo(2);
|
assertThat(previousMediaItemIndex).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPreviousWindowIndex_withShuffleModeEnabled() throws Exception {
|
public void getPreviousMediaItemIndex_withShuffleModeEnabled() throws Exception {
|
||||||
Timeline timeline =
|
Timeline timeline =
|
||||||
new PlaylistTimeline(
|
new PlaylistTimeline(
|
||||||
MediaTestUtils.createMediaItems(/* size= */ 3),
|
MediaTestUtils.createMediaItems(/* size= */ 3),
|
||||||
@ -625,93 +625,97 @@ public class MediaControllerTest {
|
|||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(2)
|
.setCurrentMediaItemIndex(2)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
||||||
.setShuffleModeEnabled(true)
|
.setShuffleModeEnabled(true)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int previousWindowIndex =
|
int previousMediaItemIndex =
|
||||||
threadTestRule.getHandler().postAndSync(controller::getPreviousWindowIndex);
|
threadTestRule.getHandler().postAndSync(controller::getPreviousMediaItemIndex);
|
||||||
|
|
||||||
assertThat(previousWindowIndex).isEqualTo(0);
|
assertThat(previousMediaItemIndex).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNextWindowIndex() throws Exception {
|
public void getNextMediaItemIndex() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(1)
|
.setCurrentMediaItemIndex(1)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int nextWindowIndex = threadTestRule.getHandler().postAndSync(controller::getNextWindowIndex);
|
int nextMediaItemIndex =
|
||||||
|
threadTestRule.getHandler().postAndSync(controller::getNextMediaItemIndex);
|
||||||
|
|
||||||
assertThat(nextWindowIndex).isEqualTo(2);
|
assertThat(nextMediaItemIndex).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNextWindowIndex_withRepeatModeOne() throws Exception {
|
public void getNextMediaItemIndex_withRepeatModeOne() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(1)
|
.setCurrentMediaItemIndex(1)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_ONE)
|
.setRepeatMode(Player.REPEAT_MODE_ONE)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int nextWindowIndex = threadTestRule.getHandler().postAndSync(controller::getNextWindowIndex);
|
int nextMediaItemIndex =
|
||||||
|
threadTestRule.getHandler().postAndSync(controller::getNextMediaItemIndex);
|
||||||
|
|
||||||
assertThat(nextWindowIndex).isEqualTo(2);
|
assertThat(nextMediaItemIndex).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNextWindowIndex_atTheLastWindow() throws Exception {
|
public void getNextMediaItemIndex_atTheLastMediaItem() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(2)
|
.setCurrentMediaItemIndex(2)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int nextWindowIndex = threadTestRule.getHandler().postAndSync(controller::getNextWindowIndex);
|
int nextMediaItemIndex =
|
||||||
|
threadTestRule.getHandler().postAndSync(controller::getNextMediaItemIndex);
|
||||||
|
|
||||||
assertThat(nextWindowIndex).isEqualTo(C.INDEX_UNSET);
|
assertThat(nextMediaItemIndex).isEqualTo(C.INDEX_UNSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNextWindowIndex_atTheLastWindowWithRepeatModeAll() throws Exception {
|
public void getNextMediaItemIndex_atTheLastMediaItemWithRepeatModeAll() throws Exception {
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
Timeline timeline = MediaTestUtils.createTimeline(/* windowCount= */ 3);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(2)
|
.setCurrentMediaItemIndex(2)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_ALL)
|
.setRepeatMode(Player.REPEAT_MODE_ALL)
|
||||||
.setShuffleModeEnabled(false)
|
.setShuffleModeEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int nextWindowIndex = threadTestRule.getHandler().postAndSync(controller::getNextWindowIndex);
|
int nextMediaItemIndex =
|
||||||
|
threadTestRule.getHandler().postAndSync(controller::getNextMediaItemIndex);
|
||||||
|
|
||||||
assertThat(nextWindowIndex).isEqualTo(0);
|
assertThat(nextMediaItemIndex).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getNextWindowIndex_withShuffleModeEnabled() throws Exception {
|
public void getNextMediaItemIndex_withShuffleModeEnabled() throws Exception {
|
||||||
Timeline timeline =
|
Timeline timeline =
|
||||||
new PlaylistTimeline(
|
new PlaylistTimeline(
|
||||||
MediaTestUtils.createMediaItems(/* size= */ 3),
|
MediaTestUtils.createMediaItems(/* size= */ 3),
|
||||||
@ -719,16 +723,17 @@ public class MediaControllerTest {
|
|||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder()
|
new RemoteMediaSession.MockPlayerConfigBuilder()
|
||||||
.setTimeline(timeline)
|
.setTimeline(timeline)
|
||||||
.setCurrentWindowIndex(2)
|
.setCurrentMediaItemIndex(2)
|
||||||
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
.setRepeatMode(Player.REPEAT_MODE_OFF)
|
||||||
.setShuffleModeEnabled(true)
|
.setShuffleModeEnabled(true)
|
||||||
.build();
|
.build();
|
||||||
remoteSession.setPlayer(playerConfig);
|
remoteSession.setPlayer(playerConfig);
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
int nextWindowIndex = threadTestRule.getHandler().postAndSync(controller::getNextWindowIndex);
|
int nextMediaItemIndex =
|
||||||
|
threadTestRule.getHandler().postAndSync(controller::getNextMediaItemIndex);
|
||||||
|
|
||||||
assertThat(nextWindowIndex).isEqualTo(1);
|
assertThat(nextMediaItemIndex).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -748,7 +753,7 @@ public class MediaControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getMediaItemAt() throws Exception {
|
public void getMediaItemAt() throws Exception {
|
||||||
int windowCount = 3;
|
int windowCount = 3;
|
||||||
int windowIndex = 1;
|
int mediaItemIndex = 1;
|
||||||
Timeline timeline = MediaTestUtils.createTimeline(windowCount);
|
Timeline timeline = MediaTestUtils.createTimeline(windowCount);
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder().setTimeline(timeline).build();
|
new RemoteMediaSession.MockPlayerConfigBuilder().setTimeline(timeline).build();
|
||||||
@ -756,10 +761,10 @@ public class MediaControllerTest {
|
|||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
MediaItem mediaItem =
|
MediaItem mediaItem =
|
||||||
threadTestRule.getHandler().postAndSync(() -> controller.getMediaItemAt(windowIndex));
|
threadTestRule.getHandler().postAndSync(() -> controller.getMediaItemAt(mediaItemIndex));
|
||||||
|
|
||||||
assertThat(mediaItem)
|
assertThat(mediaItem)
|
||||||
.isEqualTo(timeline.getWindow(windowIndex, new Timeline.Window()).mediaItem);
|
.isEqualTo(timeline.getWindow(mediaItemIndex, new Timeline.Window()).mediaItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RemoteMediaSession createRemoteMediaSession(String id, Bundle tokenExtras)
|
private RemoteMediaSession createRemoteMediaSession(String id, Bundle tokenExtras)
|
||||||
|
@ -435,8 +435,8 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
|
|||||||
controller.getTransportControls().skipToQueueItem(queue.get(targetIndex).getQueueId());
|
controller.getTransportControls().skipToQueueItem(queue.get(targetIndex).getQueueId());
|
||||||
|
|
||||||
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
||||||
assertThat(player.seekToDefaultPositionWithWindowIndexCalled).isTrue();
|
assertThat(player.seekToDefaultPositionWithMediaItemIndexCalled).isTrue();
|
||||||
assertThat(player.seekWindowIndex).isEqualTo(targetIndex);
|
assertThat(player.seekMediaItemIndex).isEqualTo(targetIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -172,8 +172,8 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToDefaultPosition_withWindowIndex() throws Exception {
|
public void seekToDefaultPosition_withMediaItemIndex() throws Exception {
|
||||||
int testWindowIndex = 1;
|
int testMediaItemIndex = 1;
|
||||||
List<QueueItem> testQueue = MediaTestUtils.createQueueItems(/* size= */ 3);
|
List<QueueItem> testQueue = MediaTestUtils.createQueueItems(/* size= */ 3);
|
||||||
|
|
||||||
session.setQueue(testQueue);
|
session.setQueue(testQueue);
|
||||||
@ -182,16 +182,17 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
|
|||||||
|
|
||||||
sessionCallback.reset(2);
|
sessionCallback.reset(2);
|
||||||
|
|
||||||
controller.seekToDefaultPosition(testWindowIndex);
|
controller.seekToDefaultPosition(testMediaItemIndex);
|
||||||
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
||||||
assertThat(sessionCallback.onSkipToQueueItemCalled).isTrue();
|
assertThat(sessionCallback.onSkipToQueueItemCalled).isTrue();
|
||||||
assertThat(sessionCallback.queueItemId).isEqualTo(testQueue.get(testWindowIndex).getQueueId());
|
assertThat(sessionCallback.queueItemId)
|
||||||
|
.isEqualTo(testQueue.get(testMediaItemIndex).getQueueId());
|
||||||
assertThat(sessionCallback.onSeekToCalled).isTrue();
|
assertThat(sessionCallback.onSeekToCalled).isTrue();
|
||||||
assertThat(sessionCallback.seekPosition).isEqualTo(/* pos= */ 0);
|
assertThat(sessionCallback.seekPosition).isEqualTo(/* pos= */ 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToDefaultPosition_withFakeWindowIndex_seeksWithPosition() throws Exception {
|
public void seekToDefaultPosition_withFakeMediaItemIndex_seeksWithPosition() throws Exception {
|
||||||
List<QueueItem> testQueue = MediaTestUtils.createQueueItems(/* size= */ 3);
|
List<QueueItem> testQueue = MediaTestUtils.createQueueItems(/* size= */ 3);
|
||||||
int fakeItemIndex = testQueue.size();
|
int fakeItemIndex = testQueue.size();
|
||||||
MediaMetadataCompat testMetadata =
|
MediaMetadataCompat testMetadata =
|
||||||
@ -226,8 +227,8 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekTo_withWindowIndex() throws Exception {
|
public void seekTo_withMediaItemIndex() throws Exception {
|
||||||
int testWindowIndex = 1;
|
int testMediaItemIndex = 1;
|
||||||
long testPositionMs = 12L;
|
long testPositionMs = 12L;
|
||||||
|
|
||||||
List<QueueItem> testQueue = MediaTestUtils.createQueueItems(/* size= */ 3);
|
List<QueueItem> testQueue = MediaTestUtils.createQueueItems(/* size= */ 3);
|
||||||
@ -238,10 +239,11 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
|
|||||||
|
|
||||||
sessionCallback.reset(2);
|
sessionCallback.reset(2);
|
||||||
|
|
||||||
controller.seekTo(testWindowIndex, testPositionMs);
|
controller.seekTo(testMediaItemIndex, testPositionMs);
|
||||||
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
||||||
assertThat(sessionCallback.onSkipToQueueItemCalled).isTrue();
|
assertThat(sessionCallback.onSkipToQueueItemCalled).isTrue();
|
||||||
assertThat(sessionCallback.queueItemId).isEqualTo(testQueue.get(testWindowIndex).getQueueId());
|
assertThat(sessionCallback.queueItemId)
|
||||||
|
.isEqualTo(testQueue.get(testMediaItemIndex).getQueueId());
|
||||||
assertThat(sessionCallback.onSeekToCalled).isTrue();
|
assertThat(sessionCallback.onSeekToCalled).isTrue();
|
||||||
assertThat(sessionCallback.seekPosition).isEqualTo(testPositionMs);
|
assertThat(sessionCallback.seekPosition).isEqualTo(testPositionMs);
|
||||||
}
|
}
|
||||||
@ -350,21 +352,21 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToPreviousWindow() throws Exception {
|
public void seekToPreviousMediaItem() throws Exception {
|
||||||
RemoteMediaController controller = createControllerAndWaitConnection();
|
RemoteMediaController controller = createControllerAndWaitConnection();
|
||||||
sessionCallback.reset(1);
|
sessionCallback.reset(1);
|
||||||
|
|
||||||
controller.seekToPreviousWindow();
|
controller.seekToPreviousMediaItem();
|
||||||
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
||||||
assertThat(sessionCallback.onSkipToPreviousCalled).isTrue();
|
assertThat(sessionCallback.onSkipToPreviousCalled).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToNextWindow() throws Exception {
|
public void seekToNextMediaItem() throws Exception {
|
||||||
RemoteMediaController controller = createControllerAndWaitConnection();
|
RemoteMediaController controller = createControllerAndWaitConnection();
|
||||||
sessionCallback.reset(1);
|
sessionCallback.reset(1);
|
||||||
|
|
||||||
controller.seekToNextWindow();
|
controller.seekToNextMediaItem();
|
||||||
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
assertThat(sessionCallback.await(TIMEOUT_MS)).isTrue();
|
||||||
assertThat(sessionCallback.onSkipToNextCalled).isTrue();
|
assertThat(sessionCallback.onSkipToNextCalled).isTrue();
|
||||||
}
|
}
|
||||||
|
@ -164,14 +164,15 @@ public class MediaSessionPermissionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToNextWindow() throws Exception {
|
public void seekToNextMediaItem() throws Exception {
|
||||||
testOnCommandRequest(COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, RemoteMediaController::seekToNextWindow);
|
testOnCommandRequest(
|
||||||
|
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, RemoteMediaController::seekToNextMediaItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToPreviousWindow() throws Exception {
|
public void seekToPreviousMediaItem() throws Exception {
|
||||||
testOnCommandRequest(
|
testOnCommandRequest(
|
||||||
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, RemoteMediaController::seekToPreviousWindow);
|
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, RemoteMediaController::seekToPreviousMediaItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -138,12 +138,12 @@ public class MediaSessionPlayerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToDefaultPosition_withWindowIndex() throws Exception {
|
public void seekToDefaultPosition_withMediaItemIndex() throws Exception {
|
||||||
int windowIndex = 3;
|
int mediaItemIndex = 3;
|
||||||
controller.seekToDefaultPosition(windowIndex);
|
controller.seekToDefaultPosition(mediaItemIndex);
|
||||||
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
||||||
assertThat(player.seekToDefaultPositionWithWindowIndexCalled).isTrue();
|
assertThat(player.seekToDefaultPositionWithMediaItemIndexCalled).isTrue();
|
||||||
assertThat(player.seekWindowIndex).isEqualTo(windowIndex);
|
assertThat(player.seekMediaItemIndex).isEqualTo(mediaItemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -156,13 +156,13 @@ public class MediaSessionPlayerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekTo_withWindowIndex() throws Exception {
|
public void seekTo_withMediaItemIndex() throws Exception {
|
||||||
int windowIndex = 3;
|
int mediaItemIndex = 3;
|
||||||
long seekPositionMs = 12125L;
|
long seekPositionMs = 12125L;
|
||||||
controller.seekTo(windowIndex, seekPositionMs);
|
controller.seekTo(mediaItemIndex, seekPositionMs);
|
||||||
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
||||||
assertThat(player.seekToWithWindowIndexCalled).isTrue();
|
assertThat(player.seekToWithMediaItemIndexCalled).isTrue();
|
||||||
assertThat(player.seekWindowIndex).isEqualTo(windowIndex);
|
assertThat(player.seekMediaItemIndex).isEqualTo(mediaItemIndex);
|
||||||
assertThat(player.seekPositionMs).isEqualTo(seekPositionMs);
|
assertThat(player.seekPositionMs).isEqualTo(seekPositionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,17 +260,17 @@ public class MediaSessionPlayerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setMediaItems_withStartWindowIndex() throws Exception {
|
public void setMediaItems_withStartMediaItemIndex() throws Exception {
|
||||||
List<MediaItem> items = MediaTestUtils.createMediaItems(/* size= */ 2);
|
List<MediaItem> items = MediaTestUtils.createMediaItems(/* size= */ 2);
|
||||||
int startWindowIndex = 1;
|
int startMediaItemIndex = 1;
|
||||||
long startPositionMs = 1234;
|
long startPositionMs = 1234;
|
||||||
|
|
||||||
controller.setMediaItems(items, startWindowIndex, startPositionMs);
|
controller.setMediaItems(items, startMediaItemIndex, startPositionMs);
|
||||||
|
|
||||||
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
||||||
assertThat(player.setMediaItemsWithStartWindowIndexCalled).isTrue();
|
assertThat(player.setMediaItemsWithStartIndexCalled).isTrue();
|
||||||
assertThat(player.mediaItems).isEqualTo(items);
|
assertThat(player.mediaItems).isEqualTo(items);
|
||||||
assertThat(player.startWindowIndex).isEqualTo(startWindowIndex);
|
assertThat(player.startMediaItemIndex).isEqualTo(startMediaItemIndex);
|
||||||
assertThat(player.startPositionMs).isEqualTo(startPositionMs);
|
assertThat(player.startPositionMs).isEqualTo(startPositionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,15 +426,15 @@ public class MediaSessionPlayerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToPreviousWindow() throws Exception {
|
public void seekToPreviousMediaItem() throws Exception {
|
||||||
controller.seekToPreviousWindow();
|
controller.seekToPreviousMediaItem();
|
||||||
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
||||||
assertThat(player.seekToPreviousMediaItemCalled).isTrue();
|
assertThat(player.seekToPreviousMediaItemCalled).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void seekToNextWindow() throws Exception {
|
public void seekToNextMediaItem() throws Exception {
|
||||||
controller.seekToNextWindow();
|
controller.seekToNextMediaItem();
|
||||||
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
assertThat(player.countDownLatch.await(TIMEOUT_MS, MILLISECONDS)).isTrue();
|
||||||
assertThat(player.seekToNextMediaItemCalled).isTrue();
|
assertThat(player.seekToNextMediaItemCalled).isTrue();
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ public class MediaSessionTest {
|
|||||||
Log.d(TAG, "7) Time spent on API call(ms): " + (endTime - startTime));
|
Log.d(TAG, "7) Time spent on API call(ms): " + (endTime - startTime));
|
||||||
|
|
||||||
startTime = endTime;
|
startTime = endTime;
|
||||||
controller.seekToNextWindow();
|
controller.seekToNextMediaItem();
|
||||||
endTime = SystemClock.elapsedRealtime();
|
endTime = SystemClock.elapsedRealtime();
|
||||||
Log.d(TAG, "8) Time spent on API call(ms): " + (endTime - startTime));
|
Log.d(TAG, "8) Time spent on API call(ms): " + (endTime - startTime));
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public class MediaSessionTest {
|
|||||||
Log.d(TAG, "9) Time spent on API call(ms): " + (endTime - startTime));
|
Log.d(TAG, "9) Time spent on API call(ms): " + (endTime - startTime));
|
||||||
|
|
||||||
startTime = endTime;
|
startTime = endTime;
|
||||||
controller.seekToPreviousWindow();
|
controller.seekToPreviousMediaItem();
|
||||||
endTime = SystemClock.elapsedRealtime();
|
endTime = SystemClock.elapsedRealtime();
|
||||||
Log.d(TAG, "10) Time spent on API call(ms): " + (endTime - startTime));
|
Log.d(TAG, "10) Time spent on API call(ms): " + (endTime - startTime));
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,8 @@ public class MockPlayerTest {
|
|||||||
int startWindowIndex = 3;
|
int startWindowIndex = 3;
|
||||||
long startPositionMs = 132L;
|
long startPositionMs = 132L;
|
||||||
player.setMediaItems(list, startWindowIndex, startPositionMs);
|
player.setMediaItems(list, startWindowIndex, startPositionMs);
|
||||||
assertThat(player.setMediaItemsWithStartWindowIndexCalled).isTrue();
|
assertThat(player.setMediaItemsWithStartIndexCalled).isTrue();
|
||||||
assertThat(player.startWindowIndex).isEqualTo(startWindowIndex);
|
assertThat(player.startMediaItemIndex).isEqualTo(startWindowIndex);
|
||||||
assertThat(player.startPositionMs).isEqualTo(startPositionMs);
|
assertThat(player.startPositionMs).isEqualTo(startPositionMs);
|
||||||
assertThat(player.mediaItems).isSameInstanceAs(list);
|
assertThat(player.mediaItems).isSameInstanceAs(list);
|
||||||
}
|
}
|
||||||
|
@ -216,12 +216,12 @@ public class MediaControllerProviderService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToDefaultPositionWithWindowIndex(String controllerId, int windowIndex)
|
public void seekToDefaultPositionWithMediaItemIndex(String controllerId, int mediaItemIndex)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
runOnHandler(
|
runOnHandler(
|
||||||
() -> {
|
() -> {
|
||||||
MediaController controller = mediaControllerMap.get(controllerId);
|
MediaController controller = mediaControllerMap.get(controllerId);
|
||||||
controller.seekToDefaultPosition(windowIndex);
|
controller.seekToDefaultPosition(mediaItemIndex);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,12 +235,12 @@ public class MediaControllerProviderService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToWithWindowIndex(String controllerId, int windowIndex, long positionMs)
|
public void seekToWithMediaItemIndex(String controllerId, int mediaItemIndex, long positionMs)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
runOnHandler(
|
runOnHandler(
|
||||||
() -> {
|
() -> {
|
||||||
MediaController controller = mediaControllerMap.get(controllerId);
|
MediaController controller = mediaControllerMap.get(controllerId);
|
||||||
controller.seekTo(windowIndex, positionMs);
|
controller.seekTo(mediaItemIndex, positionMs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,18 +336,15 @@ public class MediaControllerProviderService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMediaItemsWithStartWindowIndex(
|
public void setMediaItemsWithStartIndex(
|
||||||
String controllerId,
|
String controllerId, List<Bundle> mediaItemBundles, int startIndex, long startPositionMs)
|
||||||
List<Bundle> mediaItemBundles,
|
|
||||||
int startWindowIndex,
|
|
||||||
long startPositionMs)
|
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
runOnHandler(
|
runOnHandler(
|
||||||
() -> {
|
() -> {
|
||||||
MediaController controller = mediaControllerMap.get(controllerId);
|
MediaController controller = mediaControllerMap.get(controllerId);
|
||||||
controller.setMediaItems(
|
controller.setMediaItems(
|
||||||
BundleableUtil.fromBundleList(MediaItem.CREATOR, mediaItemBundles),
|
BundleableUtil.fromBundleList(MediaItem.CREATOR, mediaItemBundles),
|
||||||
startWindowIndex,
|
startIndex,
|
||||||
startPositionMs);
|
startPositionMs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -478,20 +475,20 @@ public class MediaControllerProviderService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToPreviousWindow(String controllerId) throws RemoteException {
|
public void seekToPreviousMediaItem(String controllerId) throws RemoteException {
|
||||||
runOnHandler(
|
runOnHandler(
|
||||||
() -> {
|
() -> {
|
||||||
MediaController controller = mediaControllerMap.get(controllerId);
|
MediaController controller = mediaControllerMap.get(controllerId);
|
||||||
controller.seekToPreviousWindow();
|
controller.seekToPreviousMediaItem();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToNextWindow(String controllerId) throws RemoteException {
|
public void seekToNextMediaItem(String controllerId) throws RemoteException {
|
||||||
runOnHandler(
|
runOnHandler(
|
||||||
() -> {
|
() -> {
|
||||||
MediaController controller = mediaControllerMap.get(controllerId);
|
MediaController controller = mediaControllerMap.get(controllerId);
|
||||||
controller.seekToNextWindow();
|
controller.seekToNextMediaItem();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD
|
|||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD_INDEX_IN_AD_GROUP;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD_INDEX_IN_AD_GROUP;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_CUES;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_CUES;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_LIVE_OFFSET;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_LIVE_OFFSET;
|
||||||
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_MEDIA_ITEM_INDEX;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_PERIOD_INDEX;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_PERIOD_INDEX;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_POSITION;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_POSITION;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_WINDOW_INDEX;
|
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_INFO;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_INFO;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_MUTED;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_MUTED;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_VOLUME;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_VOLUME;
|
||||||
@ -287,7 +287,7 @@ public class MediaSessionProviderService extends Service {
|
|||||||
BundleableUtil.fromNullableBundle(
|
BundleableUtil.fromNullableBundle(
|
||||||
Timeline.CREATOR, config.getBundle(KEY_TIMELINE), player.timeline);
|
Timeline.CREATOR, config.getBundle(KEY_TIMELINE), player.timeline);
|
||||||
player.currentMediaItemIndex =
|
player.currentMediaItemIndex =
|
||||||
config.getInt(KEY_CURRENT_WINDOW_INDEX, player.currentMediaItemIndex);
|
config.getInt(KEY_CURRENT_MEDIA_ITEM_INDEX, player.currentMediaItemIndex);
|
||||||
player.currentPeriodIndex =
|
player.currentPeriodIndex =
|
||||||
config.getInt(KEY_CURRENT_PERIOD_INDEX, player.currentPeriodIndex);
|
config.getInt(KEY_CURRENT_PERIOD_INDEX, player.currentPeriodIndex);
|
||||||
player.playlistMetadata =
|
player.playlistMetadata =
|
||||||
@ -749,7 +749,7 @@ public class MediaSessionProviderService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentWindowIndex(String sessionId, int index) throws RemoteException {
|
public void setCurrentMediaItemIndex(String sessionId, int index) throws RemoteException {
|
||||||
runOnHandler(
|
runOnHandler(
|
||||||
() -> {
|
() -> {
|
||||||
MediaSession session = sessionMap.get(sessionId);
|
MediaSession session = sessionMap.get(sessionId);
|
||||||
|
@ -55,7 +55,7 @@ public class MockPlayer implements Player {
|
|||||||
@Nullable PlaybackException playerError;
|
@Nullable PlaybackException playerError;
|
||||||
public AudioAttributes audioAttributes;
|
public AudioAttributes audioAttributes;
|
||||||
public long seekPositionMs;
|
public long seekPositionMs;
|
||||||
public int seekWindowIndex;
|
public int seekMediaItemIndex;
|
||||||
public long currentPosition;
|
public long currentPosition;
|
||||||
public long bufferedPosition;
|
public long bufferedPosition;
|
||||||
public long duration;
|
public long duration;
|
||||||
@ -73,7 +73,7 @@ public class MockPlayer implements Player {
|
|||||||
public MediaItem mediaItem;
|
public MediaItem mediaItem;
|
||||||
public List<MediaItem> mediaItems;
|
public List<MediaItem> mediaItems;
|
||||||
public boolean resetPosition;
|
public boolean resetPosition;
|
||||||
public int startWindowIndex;
|
public int startMediaItemIndex;
|
||||||
public long startPositionMs;
|
public long startPositionMs;
|
||||||
public MediaMetadata playlistMetadata;
|
public MediaMetadata playlistMetadata;
|
||||||
public int index;
|
public int index;
|
||||||
@ -112,9 +112,9 @@ public class MockPlayer implements Player {
|
|||||||
public boolean stopCalled;
|
public boolean stopCalled;
|
||||||
public boolean releaseCalled;
|
public boolean releaseCalled;
|
||||||
public boolean seekToDefaultPositionCalled;
|
public boolean seekToDefaultPositionCalled;
|
||||||
public boolean seekToDefaultPositionWithWindowIndexCalled;
|
public boolean seekToDefaultPositionWithMediaItemIndexCalled;
|
||||||
public boolean seekToCalled;
|
public boolean seekToCalled;
|
||||||
public boolean seekToWithWindowIndexCalled;
|
public boolean seekToWithMediaItemIndexCalled;
|
||||||
public boolean setPlaybackSpeedCalled;
|
public boolean setPlaybackSpeedCalled;
|
||||||
public boolean setPlaybackParametersCalled;
|
public boolean setPlaybackParametersCalled;
|
||||||
public boolean setMediaItemCalled;
|
public boolean setMediaItemCalled;
|
||||||
@ -122,7 +122,7 @@ public class MockPlayer implements Player {
|
|||||||
public boolean setMediaItemWithResetPositionCalled;
|
public boolean setMediaItemWithResetPositionCalled;
|
||||||
public boolean setMediaItemsCalled;
|
public boolean setMediaItemsCalled;
|
||||||
public boolean setMediaItemsWithResetPositionCalled;
|
public boolean setMediaItemsWithResetPositionCalled;
|
||||||
public boolean setMediaItemsWithStartWindowIndexCalled;
|
public boolean setMediaItemsWithStartIndexCalled;
|
||||||
public boolean setPlaylistMetadataCalled;
|
public boolean setPlaylistMetadataCalled;
|
||||||
public boolean addMediaItemCalled;
|
public boolean addMediaItemCalled;
|
||||||
public boolean addMediaItemWithIndexCalled;
|
public boolean addMediaItemWithIndexCalled;
|
||||||
@ -180,7 +180,7 @@ public class MockPlayer implements Player {
|
|||||||
cues = ImmutableList.of();
|
cues = ImmutableList.of();
|
||||||
deviceInfo = DeviceInfo.UNKNOWN;
|
deviceInfo = DeviceInfo.UNKNOWN;
|
||||||
seekPositionMs = C.TIME_UNSET;
|
seekPositionMs = C.TIME_UNSET;
|
||||||
seekWindowIndex = C.INDEX_UNSET;
|
seekMediaItemIndex = C.INDEX_UNSET;
|
||||||
mediaMetadata = MediaMetadata.EMPTY;
|
mediaMetadata = MediaMetadata.EMPTY;
|
||||||
|
|
||||||
currentPosition = 0;
|
currentPosition = 0;
|
||||||
@ -271,8 +271,8 @@ public class MockPlayer implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekToDefaultPosition(int mediaItemIndex) {
|
public void seekToDefaultPosition(int mediaItemIndex) {
|
||||||
seekToDefaultPositionWithWindowIndexCalled = true;
|
seekToDefaultPositionWithMediaItemIndexCalled = true;
|
||||||
seekWindowIndex = mediaItemIndex;
|
seekMediaItemIndex = mediaItemIndex;
|
||||||
countDownLatch.countDown();
|
countDownLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,8 +285,8 @@ public class MockPlayer implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekTo(int mediaItemIndex, long positionMs) {
|
public void seekTo(int mediaItemIndex, long positionMs) {
|
||||||
seekToWithWindowIndexCalled = true;
|
seekToWithMediaItemIndexCalled = true;
|
||||||
seekWindowIndex = mediaItemIndex;
|
seekMediaItemIndex = mediaItemIndex;
|
||||||
seekPositionMs = positionMs;
|
seekPositionMs = positionMs;
|
||||||
countDownLatch.countDown();
|
countDownLatch.countDown();
|
||||||
}
|
}
|
||||||
@ -666,9 +666,9 @@ public class MockPlayer implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
|
public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs) {
|
||||||
setMediaItemsWithStartWindowIndexCalled = true;
|
setMediaItemsWithStartIndexCalled = true;
|
||||||
this.mediaItems = mediaItems;
|
this.mediaItems = mediaItems;
|
||||||
this.startWindowIndex = startIndex;
|
this.startMediaItemIndex = startIndex;
|
||||||
this.startPositionMs = startPositionMs;
|
this.startPositionMs = startPositionMs;
|
||||||
countDownLatch.countDown();
|
countDownLatch.countDown();
|
||||||
}
|
}
|
||||||
|
@ -112,16 +112,16 @@ public class RemoteMediaController {
|
|||||||
binder.seekToDefaultPosition(controllerId);
|
binder.seekToDefaultPosition(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seekToDefaultPosition(int windowIndex) throws RemoteException {
|
public void seekToDefaultPosition(int mediaItemIndex) throws RemoteException {
|
||||||
binder.seekToDefaultPositionWithWindowIndex(controllerId, windowIndex);
|
binder.seekToDefaultPositionWithMediaItemIndex(controllerId, mediaItemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seekTo(long positionMs) throws RemoteException {
|
public void seekTo(long positionMs) throws RemoteException {
|
||||||
binder.seekTo(controllerId, positionMs);
|
binder.seekTo(controllerId, positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seekTo(int windowIndex, long positionMs) throws RemoteException {
|
public void seekTo(int mediaItemIndex, long positionMs) throws RemoteException {
|
||||||
binder.seekToWithWindowIndex(controllerId, windowIndex, positionMs);
|
binder.seekToWithMediaItemIndex(controllerId, mediaItemIndex, positionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seekBack() throws RemoteException {
|
public void seekBack() throws RemoteException {
|
||||||
@ -162,10 +162,10 @@ public class RemoteMediaController {
|
|||||||
controllerId, BundleableUtil.toBundleList(mediaItems), resetPosition);
|
controllerId, BundleableUtil.toBundleList(mediaItems), resetPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMediaItems(List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs)
|
public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
binder.setMediaItemsWithStartWindowIndex(
|
binder.setMediaItemsWithStartIndex(
|
||||||
controllerId, BundleableUtil.toBundleList(mediaItems), startWindowIndex, startPositionMs);
|
controllerId, BundleableUtil.toBundleList(mediaItems), startIndex, startPositionMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -222,12 +222,12 @@ public class RemoteMediaController {
|
|||||||
binder.moveMediaItems(controllerId, fromIndex, toIndex, newIndex);
|
binder.moveMediaItems(controllerId, fromIndex, toIndex, newIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seekToPreviousWindow() throws RemoteException {
|
public void seekToPreviousMediaItem() throws RemoteException {
|
||||||
binder.seekToPreviousWindow(controllerId);
|
binder.seekToPreviousMediaItem(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seekToNextWindow() throws RemoteException {
|
public void seekToNextMediaItem() throws RemoteException {
|
||||||
binder.seekToNextWindow(controllerId);
|
binder.seekToNextMediaItem(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seekToPrevious() throws RemoteException {
|
public void seekToPrevious() throws RemoteException {
|
||||||
|
@ -26,9 +26,9 @@ import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD
|
|||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD_INDEX_IN_AD_GROUP;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD_INDEX_IN_AD_GROUP;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_CUES;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_CUES;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_LIVE_OFFSET;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_LIVE_OFFSET;
|
||||||
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_MEDIA_ITEM_INDEX;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_PERIOD_INDEX;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_PERIOD_INDEX;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_POSITION;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_POSITION;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_WINDOW_INDEX;
|
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_INFO;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_INFO;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_MUTED;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_MUTED;
|
||||||
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_VOLUME;
|
import static androidx.media3.test.session.common.CommonConstants.KEY_DEVICE_VOLUME;
|
||||||
@ -343,8 +343,8 @@ public class RemoteMediaSession {
|
|||||||
binder.setShuffleModeEnabled(sessionId, shuffleModeEnabled);
|
binder.setShuffleModeEnabled(sessionId, shuffleModeEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentWindowIndex(int index) throws RemoteException {
|
public void setCurrentMediaItemIndex(int index) throws RemoteException {
|
||||||
binder.setCurrentWindowIndex(sessionId, index);
|
binder.setCurrentMediaItemIndex(sessionId, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTrackSelectionParameters(TrackSelectionParameters parameters)
|
public void setTrackSelectionParameters(TrackSelectionParameters parameters)
|
||||||
@ -571,8 +571,8 @@ public class RemoteMediaSession {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockPlayerConfigBuilder setCurrentWindowIndex(int index) {
|
public MockPlayerConfigBuilder setCurrentMediaItemIndex(int index) {
|
||||||
bundle.putInt(KEY_CURRENT_WINDOW_INDEX, index);
|
bundle.putInt(KEY_CURRENT_MEDIA_ITEM_INDEX, index);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user