Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f37e9800
authored
Oct 27, 2021
by
ibaker
Committed by
Ian Baker
Nov 08, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Migrate media3.session references from Window to MediaItem
#minor-release PiperOrigin-RevId: 405927299
parent
d83fe03d
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
606 additions
and
596 deletions
libraries/session/src/main/java/androidx/media3/session/MediaController.java
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplBase.java
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplLegacy.java
libraries/test_session_common/src/main/aidl/androidx/media3/test/session/common/IRemoteMediaController.aidl
libraries/test_session_common/src/main/aidl/androidx/media3/test/session/common/IRemoteMediaSession.aidl
libraries/test_session_common/src/main/java/androidx/media3/test/session/common/CommonConstants.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerCompatCallbackWithMediaSessionTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerStateMaskingTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionCallbackWithMediaControllerCompatTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionCompatCallbackWithMediaControllerTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionPermissionTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionPlayerTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionTest.java
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MockPlayerTest.java
libraries/test_session_current/src/main/java/androidx/media3/session/MediaControllerProviderService.java
libraries/test_session_current/src/main/java/androidx/media3/session/MediaSessionProviderService.java
libraries/test_session_current/src/main/java/androidx/media3/session/MockPlayer.java
libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaController.java
libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaSession.java
libraries/session/src/main/java/androidx/media3/session/MediaController.java
View file @
f37e9800
...
@@ -1270,7 +1270,7 @@ public class MediaController implements Player {
...
@@ -1270,7 +1270,7 @@ public class MediaController implements Player {
@Override
@Override
public
int
getCurrentMediaItemIndex
()
{
public
int
getCurrentMediaItemIndex
()
{
verifyApplicationThread
();
verifyApplicationThread
();
return
isConnected
()
?
impl
.
getCurrent
Window
Index
()
:
C
.
INDEX_UNSET
;
return
isConnected
()
?
impl
.
getCurrent
MediaItem
Index
()
:
C
.
INDEX_UNSET
;
}
}
@UnstableApi
@UnstableApi
...
@@ -1291,7 +1291,7 @@ public class MediaController implements Player {
...
@@ -1291,7 +1291,7 @@ public class MediaController implements Player {
@Override
@Override
public
int
getPreviousMediaItemIndex
()
{
public
int
getPreviousMediaItemIndex
()
{
verifyApplicationThread
();
verifyApplicationThread
();
return
isConnected
()
?
impl
.
getPrevious
Window
Index
()
:
C
.
INDEX_UNSET
;
return
isConnected
()
?
impl
.
getPrevious
MediaItem
Index
()
:
C
.
INDEX_UNSET
;
}
}
@UnstableApi
@UnstableApi
...
@@ -1312,7 +1312,7 @@ public class MediaController implements Player {
...
@@ -1312,7 +1312,7 @@ public class MediaController implements Player {
@Override
@Override
public
int
getNextMediaItemIndex
()
{
public
int
getNextMediaItemIndex
()
{
verifyApplicationThread
();
verifyApplicationThread
();
return
isConnected
()
?
impl
.
getNext
Window
Index
()
:
C
.
INDEX_UNSET
;
return
isConnected
()
?
impl
.
getNext
MediaItem
Index
()
:
C
.
INDEX_UNSET
;
}
}
@UnstableApi
@UnstableApi
...
@@ -1348,13 +1348,13 @@ public class MediaController implements Player {
...
@@ -1348,13 +1348,13 @@ public class MediaController implements Player {
@Override
@Override
public
boolean
hasPreviousMediaItem
()
{
public
boolean
hasPreviousMediaItem
()
{
verifyApplicationThread
();
verifyApplicationThread
();
return
isConnected
()
&&
impl
.
hasPrevious
Window
();
return
isConnected
()
&&
impl
.
hasPrevious
MediaItem
();
}
}
@Override
@Override
public
boolean
hasNextMediaItem
()
{
public
boolean
hasNextMediaItem
()
{
verifyApplicationThread
();
verifyApplicationThread
();
return
isConnected
()
&&
impl
.
hasNext
Window
();
return
isConnected
()
&&
impl
.
hasNext
MediaItem
();
}
}
@UnstableApi
@UnstableApi
...
@@ -1392,7 +1392,7 @@ public class MediaController implements Player {
...
@@ -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
.
seekToPrevious
Window
();
impl
.
seekToPrevious
MediaItem
();
}
}
@UnstableApi
@UnstableApi
...
@@ -1416,7 +1416,7 @@ public class MediaController implements Player {
...
@@ -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
.
seekToNext
Window
();
impl
.
seekToNext
MediaItem
();
}
}
/**
/**
...
@@ -1824,7 +1824,6 @@ public class MediaController implements Player {
...
@@ -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 {
...
@@ -1850,11 +1849,11 @@ public class MediaController implements Player {
void
seekToDefaultPosition
();
void
seekToDefaultPosition
();
void
seekToDefaultPosition
(
int
window
Index
);
void
seekToDefaultPosition
(
int
mediaItem
Index
);
void
seekTo
(
long
positionMs
);
void
seekTo
(
long
positionMs
);
void
seekTo
(
int
window
Index
,
long
positionMs
);
void
seekTo
(
int
mediaItem
Index
,
long
positionMs
);
long
getSeekBackIncrement
();
long
getSeekBackIncrement
();
...
@@ -1920,7 +1919,7 @@ public class MediaController implements Player {
...
@@ -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
start
Window
Index
,
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 {
...
@@ -1948,19 +1947,19 @@ public class MediaController implements Player {
int
getCurrentPeriodIndex
();
int
getCurrentPeriodIndex
();
int
getCurrent
Window
Index
();
int
getCurrent
MediaItem
Index
();
int
getPrevious
Window
Index
();
int
getPrevious
MediaItem
Index
();
int
getNext
Window
Index
();
int
getNext
MediaItem
Index
();
boolean
hasPrevious
Window
();
boolean
hasPrevious
MediaItem
();
boolean
hasNext
Window
();
boolean
hasNext
MediaItem
();
void
seekToPrevious
Window
();
void
seekToPrevious
MediaItem
();
void
seekToNext
Window
();
void
seekToNext
MediaItem
();
void
seekToPrevious
();
void
seekToPrevious
();
...
...
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplBase.java
View file @
f37e9800
...
@@ -488,11 +488,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -488,11 +488,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
}
}
});
});
seekToInternal
(
getCurrent
Window
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
getCurrent
MediaItem
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
}
}
@Override
@Override
public
void
seekToDefaultPosition
(
int
window
Index
)
{
public
void
seekToDefaultPosition
(
int
mediaItem
Index
)
{
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;
...
@@ -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
,
window
Index
);
iSession
.
seekToDefaultPositionWithMediaItemIndex
(
controllerStub
,
seq
,
mediaItem
Index
);
}
}
});
});
seekToInternal
(
window
Index
,
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
mediaItem
Index
,
/* positionMs= */
C
.
TIME_UNSET
);
}
}
@Override
@Override
...
@@ -524,11 +524,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -524,11 +524,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
}
}
});
});
seekToInternal
(
getCurrent
Window
Index
(),
positionMs
);
seekToInternal
(
getCurrent
MediaItem
Index
(),
positionMs
);
}
}
@Override
@Override
public
void
seekTo
(
int
window
Index
,
long
positionMs
)
{
public
void
seekTo
(
int
mediaItem
Index
,
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;
...
@@ -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
,
window
Index
,
positionMs
);
iSession
.
seekToWithMediaItemIndex
(
controllerStub
,
seq
,
mediaItem
Index
,
positionMs
);
}
}
});
});
seekToInternal
(
window
Index
,
positionMs
);
seekToInternal
(
mediaItem
Index
,
positionMs
);
}
}
@Override
@Override
...
@@ -817,7 +817,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -817,7 +817,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
setMediaItemsInternal
(
setMediaItemsInternal
(
Collections
.
singletonList
(
mediaItem
),
Collections
.
singletonList
(
mediaItem
),
/* start
Window
Index= */
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;
...
@@ -836,7 +836,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
setMediaItemsInternal
(
setMediaItemsInternal
(
Collections
.
singletonList
(
mediaItem
),
Collections
.
singletonList
(
mediaItem
),
/* start
Window
Index= */
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;
...
@@ -855,7 +855,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
setMediaItemsInternal
(
setMediaItemsInternal
(
Collections
.
singletonList
(
mediaItem
),
Collections
.
singletonList
(
mediaItem
),
/* start
Window
Index= */
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;
...
@@ -876,7 +876,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
setMediaItemsInternal
(
setMediaItemsInternal
(
mediaItems
,
mediaItems
,
/* start
Window
Index= */
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;
...
@@ -898,14 +898,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
setMediaItemsInternal
(
setMediaItemsInternal
(
mediaItems
,
mediaItems
,
/* start
Window
Index= */
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;
...
@@ -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
)),
start
Window
Index
,
startIndex
,
startPositionMs
));
startPositionMs
));
setMediaItemsInternal
(
setMediaItemsInternal
(
mediaItems
,
start
Window
Index
,
startPositionMs
,
/* resetToDefaultPosition= */
false
);
mediaItems
,
startIndex
,
startPositionMs
,
/* resetToDefaultPosition= */
false
);
}
}
@Override
@Override
...
@@ -1132,39 +1131,39 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -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
old
WindowIndex
=
getCurrentWindow
Index
();
int
old
MediaItemIndex
=
getCurrentMediaItem
Index
();
int
new
WindowIndex
=
oldWindow
Index
;
int
new
MediaItemIndex
=
oldMediaItem
Index
;
int
oldPeriodIndex
=
playerInfo
.
sessionPositionInfo
.
positionInfo
.
periodIndex
;
int
oldPeriodIndex
=
playerInfo
.
sessionPositionInfo
.
positionInfo
.
periodIndex
;
int
newPeriodIndex
=
oldPeriodIndex
;
int
newPeriodIndex
=
oldPeriodIndex
;
boolean
currentItemRemoved
=
boolean
currentItemRemoved
=
getCurrent
WindowIndex
()
>=
fromIndex
&&
getCurrentWindow
Index
()
<
clippedToIndex
;
getCurrent
MediaItemIndex
()
>=
fromIndex
&&
getCurrentMediaItem
Index
()
<
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
())
{
new
Window
Index
=
C
.
INDEX_UNSET
;
new
MediaItem
Index
=
C
.
INDEX_UNSET
;
newPeriodIndex
=
0
;
newPeriodIndex
=
0
;
}
else
{
}
else
{
if
(
currentItemRemoved
)
{
if
(
currentItemRemoved
)
{
int
oldNext
Window
Index
=
int
oldNext
MediaItem
Index
=
resolveSubsequent
Window
Index
(
resolveSubsequent
MediaItem
Index
(
getRepeatMode
(),
getRepeatMode
(),
getShuffleModeEnabled
(),
getShuffleModeEnabled
(),
old
Window
Index
,
old
MediaItem
Index
,
oldTimeline
,
oldTimeline
,
fromIndex
,
fromIndex
,
toIndex
);
toIndex
);
if
(
oldNext
Window
Index
==
C
.
INDEX_UNSET
)
{
if
(
oldNext
MediaItem
Index
==
C
.
INDEX_UNSET
)
{
new
Window
Index
=
newTimeline
.
getFirstWindowIndex
(
getShuffleModeEnabled
());
new
MediaItem
Index
=
newTimeline
.
getFirstWindowIndex
(
getShuffleModeEnabled
());
}
else
if
(
oldNext
Window
Index
>=
clippedToIndex
)
{
}
else
if
(
oldNext
MediaItem
Index
>=
clippedToIndex
)
{
new
WindowIndex
=
oldNextWindow
Index
-
(
clippedToIndex
-
fromIndex
);
new
MediaItemIndex
=
oldNextMediaItem
Index
-
(
clippedToIndex
-
fromIndex
);
}
else
{
}
else
{
new
WindowIndex
=
oldNextWindow
Index
;
new
MediaItemIndex
=
oldNextMediaItem
Index
;
}
}
newPeriodIndex
=
newTimeline
.
getWindow
(
new
Window
Index
,
window
).
firstPeriodIndex
;
newPeriodIndex
=
newTimeline
.
getWindow
(
new
MediaItem
Index
,
window
).
firstPeriodIndex
;
}
else
if
(
old
Window
Index
>=
clippedToIndex
)
{
}
else
if
(
old
MediaItem
Index
>=
clippedToIndex
)
{
new
Window
Index
-=
(
clippedToIndex
-
fromIndex
);
new
MediaItem
Index
-=
(
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;
...
@@ -1174,7 +1173,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
PlayerInfo
newPlayerInfo
;
PlayerInfo
newPlayerInfo
;
if
(
currentItemRemoved
)
{
if
(
currentItemRemoved
)
{
PositionInfo
newPositionInfo
;
PositionInfo
newPositionInfo
;
if
(
new
Window
Index
==
C
.
INDEX_UNSET
)
{
if
(
new
MediaItem
Index
==
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;
...
@@ -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
(
new
Window
Index
,
new
Window
());
Window
newWindow
=
newTimeline
.
getWindow
(
new
MediaItem
Index
,
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
,
new
Window
Index
,
new
MediaItem
Index
,
newWindow
.
mediaItem
,
newWindow
.
mediaItem
,
/* periodUid= */
null
,
/* periodUid= */
null
,
newPeriodIndex
,
newPeriodIndex
,
...
@@ -1222,7 +1221,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -1222,7 +1221,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
maskTimelineAndPositionInfo
(
maskTimelineAndPositionInfo
(
playerInfo
,
playerInfo
,
newTimeline
,
newTimeline
,
new
Window
Index
,
new
MediaItem
Index
,
newPeriodIndex
,
newPeriodIndex
,
DISCONTINUITY_REASON_REMOVE
);
DISCONTINUITY_REASON_REMOVE
);
}
}
...
@@ -1233,7 +1232,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -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
()
&&
getCurrent
Window
Index
()
>=
fromIndex
;
&&
getCurrent
MediaItem
Index
()
>=
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;
...
@@ -1299,7 +1298,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
}
}
@Override
@Override
public
int
getCurrent
Window
Index
()
{
public
int
getCurrent
MediaItem
Index
()
{
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;
...
@@ -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
getPrevious
Window
Index
()
{
public
int
getPrevious
MediaItem
Index
()
{
return
playerInfo
.
timeline
.
isEmpty
()
return
playerInfo
.
timeline
.
isEmpty
()
?
C
.
INDEX_UNSET
?
C
.
INDEX_UNSET
:
playerInfo
.
timeline
.
getPreviousWindowIndex
(
:
playerInfo
.
timeline
.
getPreviousWindowIndex
(
getCurrent
Window
Index
(),
getCurrent
MediaItem
Index
(),
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
getNext
Window
Index
()
{
public
int
getNext
MediaItem
Index
()
{
return
playerInfo
.
timeline
.
isEmpty
()
return
playerInfo
.
timeline
.
isEmpty
()
?
C
.
INDEX_UNSET
?
C
.
INDEX_UNSET
:
playerInfo
.
timeline
.
getNextWindowIndex
(
:
playerInfo
.
timeline
.
getNextWindowIndex
(
getCurrent
Window
Index
(),
getCurrent
MediaItem
Index
(),
convertRepeatModeForNavigation
(
playerInfo
.
repeatMode
),
convertRepeatModeForNavigation
(
playerInfo
.
repeatMode
),
playerInfo
.
shuffleModeEnabled
);
playerInfo
.
shuffleModeEnabled
);
}
}
@Override
@Override
public
boolean
hasPrevious
Window
()
{
public
boolean
hasPrevious
MediaItem
()
{
return
getPrevious
Window
Index
()
!=
C
.
INDEX_UNSET
;
return
getPrevious
MediaItem
Index
()
!=
C
.
INDEX_UNSET
;
}
}
@Override
@Override
public
boolean
hasNext
Window
()
{
public
boolean
hasNext
MediaItem
()
{
return
getNext
Window
Index
()
!=
C
.
INDEX_UNSET
;
return
getNext
MediaItem
Index
()
!=
C
.
INDEX_UNSET
;
}
}
@Override
@Override
public
void
seekToPrevious
Window
()
{
public
void
seekToPrevious
MediaItem
()
{
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;
...
@@ -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
(
getPrevious
Window
Index
()
!=
C
.
INDEX_UNSET
)
{
if
(
getPrevious
MediaItem
Index
()
!=
C
.
INDEX_UNSET
)
{
seekToInternal
(
getPrevious
Window
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
getPrevious
MediaItem
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
}
}
}
}
@Override
@Override
public
void
seekToNext
Window
()
{
public
void
seekToNext
MediaItem
()
{
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;
...
@@ -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
(
getNext
Window
Index
()
!=
C
.
INDEX_UNSET
)
{
if
(
getNext
MediaItem
Index
()
!=
C
.
INDEX_UNSET
)
{
seekToInternal
(
getNext
Window
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
getNext
MediaItem
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
}
}
}
}
...
@@ -1380,16 +1379,16 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -1380,16 +1379,16 @@ import org.checkerframework.checker.nullness.qual.NonNull;
if
(
timeline
.
isEmpty
()
||
isPlayingAd
())
{
if
(
timeline
.
isEmpty
()
||
isPlayingAd
())
{
return
;
return
;
}
}
boolean
hasPrevious
Window
=
hasPreviousWindow
();
boolean
hasPrevious
MediaItem
=
hasPreviousMediaItem
();
Window
window
=
timeline
.
getWindow
(
getCurrent
Window
Index
(),
new
Window
());
Window
window
=
timeline
.
getWindow
(
getCurrent
MediaItem
Index
(),
new
Window
());
if
(
window
.
isDynamic
&&
window
.
isLive
())
{
if
(
window
.
isDynamic
&&
window
.
isLive
())
{
if
(
hasPrevious
Window
)
{
if
(
hasPrevious
MediaItem
)
{
seekToInternal
(
getPrevious
Window
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
getPrevious
MediaItem
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
}
}
}
else
if
(
hasPrevious
Window
&&
getCurrentPosition
()
<=
getMaxSeekToPreviousPosition
())
{
}
else
if
(
hasPrevious
MediaItem
&&
getCurrentPosition
()
<=
getMaxSeekToPreviousPosition
())
{
seekToInternal
(
getPrevious
Window
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
getPrevious
MediaItem
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
}
else
{
}
else
{
seekToInternal
(
getCurrent
Window
Index
(),
/* positionMs= */
0
);
seekToInternal
(
getCurrent
MediaItem
Index
(),
/* positionMs= */
0
);
}
}
}
}
...
@@ -1411,12 +1410,12 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -1411,12 +1410,12 @@ import org.checkerframework.checker.nullness.qual.NonNull;
if
(
timeline
.
isEmpty
()
||
isPlayingAd
())
{
if
(
timeline
.
isEmpty
()
||
isPlayingAd
())
{
return
;
return
;
}
}
if
(
hasNext
Window
())
{
if
(
hasNext
MediaItem
())
{
seekToInternal
(
getNext
Window
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
getNext
MediaItem
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
}
else
{
}
else
{
Window
window
=
timeline
.
getWindow
(
getCurrent
Window
Index
(),
new
Window
());
Window
window
=
timeline
.
getWindow
(
getCurrent
MediaItem
Index
(),
new
Window
());
if
(
window
.
isDynamic
&&
window
.
isLive
())
{
if
(
window
.
isDynamic
&&
window
.
isLive
())
{
seekToInternal
(
getCurrent
Window
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
seekToInternal
(
getCurrent
MediaItem
Index
(),
/* positionMs= */
C
.
TIME_UNSET
);
}
}
}
}
}
}
...
@@ -1944,7 +1943,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
...
@@ -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
=
getCurrent
Window
Index
();
int
oldWindowIndex
=
getCurrent
MediaItem
Index
();
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;
...
@@ -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
(
getCurrent
Window
Index
(),
positionMs
);
seekToInternal
(
getCurrent
MediaItem
Index
(),
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;
...
@@ -2865,28 +2864,28 @@ import org.checkerframework.checker.nullness.qual.NonNull;
}
}
}
}
private
static
int
resolveSubsequent
Window
Index
(
private
static
int
resolveSubsequent
MediaItem
Index
(
@RepeatMode
int
repeatMode
,
@RepeatMode
int
repeatMode
,
boolean
shuffleModeEnabled
,
boolean
shuffleModeEnabled
,
int
old
Window
Index
,
int
old
MediaItem
Index
,
Timeline
oldTimeline
,
Timeline
oldTimeline
,
int
fromIndex
,
int
fromIndex
,
int
toIndex
)
{
int
toIndex
)
{
int
new
Window
Index
=
C
.
INDEX_UNSET
;
int
new
MediaItem
Index
=
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
++)
{
old
Window
Index
=
old
MediaItem
Index
=
oldTimeline
.
getNextWindowIndex
(
old
Window
Index
,
repeatMode
,
shuffleModeEnabled
);
oldTimeline
.
getNextWindowIndex
(
old
MediaItem
Index
,
repeatMode
,
shuffleModeEnabled
);
if
(
old
Window
Index
==
C
.
INDEX_UNSET
)
{
if
(
old
MediaItem
Index
==
C
.
INDEX_UNSET
)
{
// We've reached the end of the old timeline.
// We've reached the end of the old timeline.
break
;
break
;
}
}
if
(
old
WindowIndex
<
fromIndex
||
oldWindow
Index
>=
toIndex
)
{
if
(
old
MediaItemIndex
<
fromIndex
||
oldMediaItem
Index
>=
toIndex
)
{
new
WindowIndex
=
oldWindow
Index
;
new
MediaItemIndex
=
oldMediaItem
Index
;
break
;
break
;
}
}
}
}
return
new
Window
Index
;
return
new
MediaItem
Index
;
}
}
// This will be called on the main thread.
// This will be called on the main thread.
...
...
libraries/session/src/main/java/androidx/media3/session/MediaControllerImplLegacy.java
View file @
f37e9800
...
@@ -352,48 +352,49 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -352,48 +352,49 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
void
seekToDefaultPosition
()
{
public
void
seekToDefaultPosition
()
{
seekToInternal
(
getCurrent
Window
Index
(),
/* positionMs= */
0
);
seekToInternal
(
getCurrent
MediaItem
Index
(),
/* positionMs= */
0
);
}
}
@Override
@Override
public
void
seekToDefaultPosition
(
int
window
Index
)
{
public
void
seekToDefaultPosition
(
int
mediaItem
Index
)
{
seekToInternal
(
window
Index
,
/* positionMs= */
0
);
seekToInternal
(
mediaItem
Index
,
/* positionMs= */
0
);
}
}
@Override
@Override
public
void
seekTo
(
long
positionMs
)
{
public
void
seekTo
(
long
positionMs
)
{
seekToInternal
(
getCurrent
Window
Index
(),
positionMs
);
seekToInternal
(
getCurrent
MediaItem
Index
(),
positionMs
);
}
}
@Override
@Override
public
void
seekTo
(
int
window
Index
,
long
positionMs
)
{
public
void
seekTo
(
int
mediaItem
Index
,
long
positionMs
)
{
seekToInternal
(
window
Index
,
positionMs
);
seekToInternal
(
mediaItem
Index
,
positionMs
);
}
}
private
void
seekToInternal
(
int
window
Index
,
long
positionMs
)
{
private
void
seekToInternal
(
int
mediaItem
Index
,
long
positionMs
)
{
int
current
WindowIndex
=
getCurrentWindow
Index
();
int
current
MediaItemIndex
=
getCurrentMediaItem
Index
();
Timeline
currentTimeline
=
controllerInfo
.
playerInfo
.
timeline
;
Timeline
currentTimeline
=
controllerInfo
.
playerInfo
.
timeline
;
if
(
current
WindowIndex
!=
window
Index
if
(
current
MediaItemIndex
!=
mediaItem
Index
&&
(
windowIndex
<
0
||
window
Index
>=
currentTimeline
.
getWindowCount
()))
{
&&
(
mediaItemIndex
<
0
||
mediaItem
Index
>=
currentTimeline
.
getWindowCount
()))
{
throw
new
IllegalSeekPositionException
(
currentTimeline
,
window
Index
,
positionMs
);
throw
new
IllegalSeekPositionException
(
currentTimeline
,
mediaItem
Index
,
positionMs
);
}
}
if
(
isPlayingAd
())
{
if
(
isPlayingAd
())
{
return
;
return
;
}
}
int
new
WindowIndex
=
currentWindow
Index
;
int
new
MediaItemIndex
=
currentMediaItem
Index
;
@MediaItemTransitionReason
int
mediaItemTransitionReason
=
C
.
INDEX_UNSET
;
@MediaItemTransitionReason
int
mediaItemTransitionReason
=
C
.
INDEX_UNSET
;
if
(
windowIndex
!=
currentWindow
Index
)
{
if
(
mediaItemIndex
!=
currentMediaItem
Index
)
{
QueueTimeline
queueTimeline
=
(
QueueTimeline
)
controllerInfo
.
playerInfo
.
timeline
;
QueueTimeline
queueTimeline
=
(
QueueTimeline
)
controllerInfo
.
playerInfo
.
timeline
;
long
queueId
=
queueTimeline
.
getQueueId
(
window
Index
);
long
queueId
=
queueTimeline
.
getQueueId
(
mediaItem
Index
);
if
(
queueId
!=
QueueItem
.
UNKNOWN_ID
)
{
if
(
queueId
!=
QueueItem
.
UNKNOWN_ID
)
{
controllerCompat
.
getTransportControls
().
skipToQueueItem
(
queueId
);
controllerCompat
.
getTransportControls
().
skipToQueueItem
(
queueId
);
new
WindowIndex
=
window
Index
;
new
MediaItemIndex
=
mediaItem
Index
;
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;
...
@@ -433,9 +434,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
}
PositionInfo
positionInfo
=
PositionInfo
positionInfo
=
createPositionInfo
(
createPositionInfo
(
new
Window
Index
,
new
MediaItem
Index
,
!
currentTimeline
.
isEmpty
()
!
currentTimeline
.
isEmpty
()
?
currentTimeline
.
getWindow
(
new
Window
Index
,
new
Window
()).
mediaItem
?
currentTimeline
.
getWindow
(
new
MediaItem
Index
,
new
Window
()).
mediaItem
:
null
,
:
null
,
newPositionMs
);
newPositionMs
);
PlayerInfo
maskedPlayerInfo
=
PlayerInfo
maskedPlayerInfo
=
...
@@ -522,7 +523,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -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;
...
@@ -675,7 +676,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
void
setMediaItems
(
public
void
setMediaItems
(
List
<
MediaItem
>
unusedMediaItems
,
int
unusedStart
Window
Index
,
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;
...
@@ -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
current
WindowIndex
=
getCurrentWindow
Index
();
int
current
MediaItemIndex
=
getCurrentMediaItem
Index
();
int
newCurrent
Window
Index
=
int
newCurrent
MediaItem
Index
=
calculateCurrentItemIndexAfterAddItems
(
current
Window
Index
,
index
,
mediaItems
.
size
());
calculateCurrentItemIndexAfterAddItems
(
current
MediaItem
Index
,
index
,
mediaItems
.
size
());
PlayerInfo
maskedPlayerInfo
=
PlayerInfo
maskedPlayerInfo
=
controllerInfo
.
playerInfo
.
copyWithTimeline
(
newQueueTimeline
,
newCurrent
Window
Index
);
controllerInfo
.
playerInfo
.
copyWithTimeline
(
newQueueTimeline
,
newCurrent
MediaItem
Index
);
ControllerInfo
maskedControllerInfo
=
ControllerInfo
maskedControllerInfo
=
new
ControllerInfo
(
new
ControllerInfo
(
maskedPlayerInfo
,
maskedPlayerInfo
,
...
@@ -780,21 +781,21 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -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
current
WindowIndex
=
getCurrentWindow
Index
();
int
current
MediaItemIndex
=
getCurrentMediaItem
Index
();
int
newCurrent
Window
Index
=
int
newCurrent
MediaItem
Index
=
calculateCurrentItemIndexAfterRemoveItems
(
current
Window
Index
,
fromIndex
,
toIndex
);
calculateCurrentItemIndexAfterRemoveItems
(
current
MediaItem
Index
,
fromIndex
,
toIndex
);
if
(
newCurrent
Window
Index
==
C
.
INDEX_UNSET
)
{
if
(
newCurrent
MediaItem
Index
==
C
.
INDEX_UNSET
)
{
newCurrent
Window
Index
=
newCurrent
MediaItem
Index
=
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 "
+
newCurrent
Window
Index
+
newCurrent
MediaItem
Index
+
" is the"
+
" is the"
+
" new current item"
);
+
" new current item"
);
}
}
PlayerInfo
maskedPlayerInfo
=
PlayerInfo
maskedPlayerInfo
=
controllerInfo
.
playerInfo
.
copyWithTimeline
(
newQueueTimeline
,
newCurrent
Window
Index
);
controllerInfo
.
playerInfo
.
copyWithTimeline
(
newQueueTimeline
,
newCurrent
MediaItem
Index
);
ControllerInfo
maskedControllerInfo
=
ControllerInfo
maskedControllerInfo
=
new
ControllerInfo
(
new
ControllerInfo
(
...
@@ -834,27 +835,27 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -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
current
WindowIndex
=
getCurrentWindow
Index
();
int
current
MediaItemIndex
=
getCurrentMediaItem
Index
();
int
current
Window
IndexAfterRemove
=
int
current
MediaItem
IndexAfterRemove
=
calculateCurrentItemIndexAfterRemoveItems
(
current
Window
Index
,
fromIndex
,
toIndex
);
calculateCurrentItemIndexAfterRemoveItems
(
current
MediaItem
Index
,
fromIndex
,
toIndex
);
if
(
current
Window
IndexAfterRemove
==
C
.
INDEX_UNSET
)
{
if
(
current
MediaItem
IndexAfterRemove
==
C
.
INDEX_UNSET
)
{
current
Window
IndexAfterRemove
=
current
MediaItem
IndexAfterRemove
=
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 "
+
current
Window
IndexAfterRemove
+
current
MediaItem
IndexAfterRemove
+
" would be the new current item"
);
+
" would be the new current item"
);
}
}
int
newCurrent
Window
Index
=
int
newCurrent
MediaItem
Index
=
calculateCurrentItemIndexAfterAddItems
(
calculateCurrentItemIndexAfterAddItems
(
current
Window
IndexAfterRemove
,
newIndex
,
moveItemsSize
);
current
MediaItem
IndexAfterRemove
,
newIndex
,
moveItemsSize
);
QueueTimeline
newQueueTimeline
=
QueueTimeline
newQueueTimeline
=
queueTimeline
.
copyWithMovedMediaItems
(
fromIndex
,
toIndex
,
newIndex
);
queueTimeline
.
copyWithMovedMediaItems
(
fromIndex
,
toIndex
,
newIndex
);
PlayerInfo
maskedPlayerInfo
=
PlayerInfo
maskedPlayerInfo
=
controllerInfo
.
playerInfo
.
copyWithTimeline
(
newQueueTimeline
,
newCurrent
Window
Index
);
controllerInfo
.
playerInfo
.
copyWithTimeline
(
newQueueTimeline
,
newCurrent
MediaItem
Index
);
ControllerInfo
maskedControllerInfo
=
ControllerInfo
maskedControllerInfo
=
new
ControllerInfo
(
new
ControllerInfo
(
...
@@ -880,55 +881,55 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -880,55 +881,55 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override
@Override
public
int
getCurrentPeriodIndex
()
{
public
int
getCurrentPeriodIndex
()
{
return
getCurrent
Window
Index
();
return
getCurrent
MediaItem
Index
();
}
}
@Override
@Override
public
int
getCurrent
Window
Index
()
{
public
int
getCurrent
MediaItem
Index
()
{
return
controllerInfo
.
playerInfo
.
sessionPositionInfo
.
positionInfo
.
mediaItemIndex
;
return
controllerInfo
.
playerInfo
.
sessionPositionInfo
.
positionInfo
.
mediaItemIndex
;
}
}
@Override
@Override
public
int
getPrevious
Window
Index
()
{
public
int
getPrevious
MediaItem
Index
()
{
return
C
.
INDEX_UNSET
;
return
C
.
INDEX_UNSET
;
}
}
@Override
@Override
public
int
getNext
Window
Index
()
{
public
int
getNext
MediaItem
Index
()
{
return
C
.
INDEX_UNSET
;
return
C
.
INDEX_UNSET
;
}
}
@Override
@Override
public
boolean
hasPrevious
Window
()
{
public
boolean
hasPrevious
MediaItem
()
{
return
connected
;
return
connected
;
}
}
@Override
@Override
public
boolean
hasNext
Window
()
{
public
boolean
hasNext
MediaItem
()
{
return
connected
;
return
connected
;
}
}
@Override
@Override
public
void
seekToPrevious
Window
()
{
public
void
seekToPrevious
MediaItem
()
{
// 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
Window
()
{
public
void
seekToNext
MediaItem
()
{
// 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;
...
@@ -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 getCurrent
Window
Index() return masked index.
// Shouldn't be C.INDEX_UNSET to make getCurrent
MediaItem
Index() return masked index.
// In other words, this index is either the currently playing
window index or the would-b
e
// In other words, this index is either the currently playing
media item index or th
e
// 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;
...
@@ -2044,13 +2045,13 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
}
private
static
PositionInfo
createPositionInfo
(
private
static
PositionInfo
createPositionInfo
(
int
window
Index
,
@Nullable
MediaItem
mediaItem
,
long
currentPositionMs
)
{
int
mediaItem
Index
,
@Nullable
MediaItem
mediaItem
,
long
currentPositionMs
)
{
return
new
PositionInfo
(
return
new
PositionInfo
(
/* windowUid= */
null
,
/* windowUid= */
null
,
/*
windowIndex= */
window
Index
,
/*
mediaItemIndex= */
mediaItem
Index
,
mediaItem
,
mediaItem
,
/* periodUid= */
null
,
/* periodUid= */
null
,
/* periodIndex= */
window
Index
,
/* periodIndex= */
mediaItem
Index
,
/* positionMs= */
currentPositionMs
,
/* positionMs= */
currentPositionMs
,
/* contentPositionMs= */
currentPositionMs
,
/* contentPositionMs= */
currentPositionMs
,
/* adGroupIndex= */
C
.
INDEX_UNSET
,
/* adGroupIndex= */
C
.
INDEX_UNSET
,
...
...
libraries/test_session_common/src/main/aidl/androidx/media3/test/session/common/IRemoteMediaController.aidl
View file @
f37e9800
...
@@ -34,9 +34,9 @@ interface IRemoteMediaController {
...
@@ -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
seekToDefaultPositionWith
WindowIndex
(
String
controllerId
,
int
window
Index
);
void
seekToDefaultPositionWith
MediaItemIndex
(
String
controllerId
,
int
mediaItem
Index
);
void
seekTo
(
String
controllerId
,
long
positionMs
);
void
seekTo
(
String
controllerId
,
long
positionMs
);
void
seekToWith
WindowIndex
(
String
controllerId
,
int
window
Index
,
long
positionMs
);
void
seekToWith
MediaItemIndex
(
String
controllerId
,
int
mediaItem
Index
,
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 {
...
@@ -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
setMediaItemsWithStart
Window
Index
(
void
setMediaItemsWithStartIndex
(
String
controllerId
,
in
List
<
Bundle
>
mediaItems
,
int
start
Window
Index
,
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 {
...
@@ -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
seekToPrevious
Window
(
String
controllerId
);
void
seekToPrevious
MediaItem
(
String
controllerId
);
void
seekToNext
Window
(
String
controllerId
);
void
seekToNext
MediaItem
(
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
);
...
...
libraries/test_session_common/src/main/aidl/androidx/media3/test/session/common/IRemoteMediaSession.aidl
View file @
f37e9800
...
@@ -69,7 +69,7 @@ interface IRemoteMediaSession {
...
@@ -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
setCurrent
Window
Index
(
String
sessionId
,
int
index
);
void
setCurrent
MediaItem
Index
(
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
);
...
...
libraries/test_session_common/src/main/java/androidx/media3/test/session/common/CommonConstants.java
View file @
f37e9800
...
@@ -68,7 +68,7 @@ public class CommonConstants {
...
@@ -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
=
"currentWindow
Index"
;
public
static
final
String
KEY_CURRENT_
MEDIA_ITEM_INDEX
=
"currentMediaItem
Index"
;
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"
;
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerCompatCallbackWithMediaSessionTest.java
View file @
f37e9800
...
@@ -126,7 +126,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
...
@@ -126,7 +126,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
.
setPlaybackParameters
(
new
PlaybackParameters
(
testSpeed
))
.
setPlaybackParameters
(
new
PlaybackParameters
(
testSpeed
))
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setPlaylistMetadata
(
testPlaylistMetadata
)
.
setPlaylistMetadata
(
testPlaylistMetadata
)
.
setCurrent
Window
Index
(
testItemIndex
)
.
setCurrent
MediaItem
Index
(
testItemIndex
)
.
setShuffleModeEnabled
(
testShuffleModeEnabled
)
.
setShuffleModeEnabled
(
testShuffleModeEnabled
)
.
setRepeatMode
(
testRepeatMode
)
.
setRepeatMode
(
testRepeatMode
)
.
build
();
.
build
();
...
@@ -370,7 +370,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
...
@@ -370,7 +370,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
.
setPlaybackParameters
(
playbackParameters
)
.
setPlaybackParameters
(
playbackParameters
)
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setPlaylistMetadata
(
testPlaylistMetadata
)
.
setPlaylistMetadata
(
testPlaylistMetadata
)
.
setCurrent
Window
Index
(
testItemIndex
)
.
setCurrent
MediaItem
Index
(
testItemIndex
)
.
setShuffleModeEnabled
(
testShuffleModeEnabled
)
.
setShuffleModeEnabled
(
testShuffleModeEnabled
)
.
setRepeatMode
(
testRepeatMode
)
.
setRepeatMode
(
testRepeatMode
)
.
build
();
.
build
();
...
@@ -802,7 +802,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
...
@@ -802,7 +802,7 @@ public class MediaControllerCompatCallbackWithMediaSessionTest {
};
};
controllerCompat
.
registerCallback
(
callback
,
handler
);
controllerCompat
.
registerCallback
(
callback
,
handler
);
session
.
getMockPlayer
().
setCurrent
Window
Index
(
testItemIndex
);
session
.
getMockPlayer
().
setCurrent
MediaItem
Index
(
testItemIndex
);
session
.
getMockPlayer
().
setCurrentPosition
(
testPosition
);
session
.
getMockPlayer
().
setCurrentPosition
(
testPosition
);
session
session
.
getMockPlayer
()
.
getMockPlayer
()
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerListenerTest.java
View file @
f37e9800
...
@@ -455,7 +455,7 @@ public class MediaControllerListenerTest {
...
@@ -455,7 +455,7 @@ public class MediaControllerListenerTest {
.
setIsPlayingAd
(
testIsPlayingAd
)
.
setIsPlayingAd
(
testIsPlayingAd
)
.
setCurrentAdGroupIndex
(
testCurrentAdGroupIndex
)
.
setCurrentAdGroupIndex
(
testCurrentAdGroupIndex
)
.
setCurrentAdIndexInAdGroup
(
testCurrentAdIndexInAdGroup
)
.
setCurrentAdIndexInAdGroup
(
testCurrentAdIndexInAdGroup
)
.
setCurrent
Window
Index
(
testWindowIndex
)
.
setCurrent
MediaItem
Index
(
testWindowIndex
)
.
setCurrentPeriodIndex
(
testPeriodIndex
)
.
setCurrentPeriodIndex
(
testPeriodIndex
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -485,7 +485,7 @@ public class MediaControllerListenerTest {
...
@@ -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
().
setCurrent
Window
Index
(
currentIndex
);
remoteSession
.
getMockPlayer
().
setCurrent
MediaItem
Index
(
currentIndex
);
remoteSession
remoteSession
.
getMockPlayer
()
.
getMockPlayer
()
.
notifyMediaItemTransition
(
.
notifyMediaItemTransition
(
...
@@ -514,7 +514,7 @@ public class MediaControllerListenerTest {
...
@@ -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
().
setCurrent
Window
Index
(
testIndex
);
remoteSession
.
getMockPlayer
().
setCurrent
MediaItem
Index
(
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 {
...
@@ -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
().
setCurrent
Window
Index
(
0
);
remoteSession
.
getMockPlayer
().
setCurrent
MediaItem
Index
(
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 {
...
@@ -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
.
setCurrent
Window
Index
(
2
);
player
.
setCurrent
MediaItem
Index
(
2
);
player
.
setShuffleModeEnabled
(
false
);
player
.
setShuffleModeEnabled
(
false
);
player
.
notifyShuffleModeEnabledChanged
();
player
.
notifyShuffleModeEnabledChanged
();
...
@@ -860,7 +860,7 @@ public class MediaControllerListenerTest {
...
@@ -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
.
setCurrent
Window
Index
(
2
);
player
.
setCurrent
MediaItem
Index
(
2
);
player
.
setRepeatMode
(
Player
.
REPEAT_MODE_OFF
);
player
.
setRepeatMode
(
Player
.
REPEAT_MODE_OFF
);
player
.
notifyRepeatModeChanged
();
player
.
notifyRepeatModeChanged
();
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerStateMaskingTest.java
View file @
f37e9800
...
@@ -634,7 +634,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -634,7 +634,7 @@ public class MediaControllerStateMaskingTest {
}
}
@Test
@Test
public
void
seekToNext
Window
()
throws
Exception
{
public
void
seekToNext
MediaItem
()
throws
Exception
{
int
initialMediaItemIndex
=
1
;
int
initialMediaItemIndex
=
1
;
String
firstMediaId
=
"firstMediaId"
;
String
firstMediaId
=
"firstMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
...
@@ -647,7 +647,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -647,7 +647,7 @@ public class MediaControllerStateMaskingTest {
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
MediaTestUtils
.
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
.
setCurrent
Window
Index
(
initialMediaItemIndex
)
.
setCurrent
MediaItem
Index
(
initialMediaItemIndex
)
.
setCurrentPeriodIndex
(
initialMediaItemIndex
)
.
setCurrentPeriodIndex
(
initialMediaItemIndex
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -681,13 +681,13 @@ public class MediaControllerStateMaskingTest {
...
@@ -681,13 +681,13 @@ public class MediaControllerStateMaskingTest {
}
}
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
seekToNext
Window
();
controller
.
seekToNext
MediaItem
();
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
});
});
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
...
@@ -696,11 +696,11 @@ public class MediaControllerStateMaskingTest {
...
@@ -696,11 +696,11 @@ public class MediaControllerStateMaskingTest {
assertThat
(
newPositionInfoRef
.
get
().
mediaItemIndex
).
isEqualTo
(
testMediaItemIndex
);
assertThat
(
newPositionInfoRef
.
get
().
mediaItemIndex
).
isEqualTo
(
testMediaItemIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
current
Window
IndexRef
.
get
()).
isEqualTo
(
testMediaItemIndex
);
assertThat
(
current
MediaItem
IndexRef
.
get
()).
isEqualTo
(
testMediaItemIndex
);
}
}
@Test
@Test
public
void
seekToPrevious
Window
()
throws
Exception
{
public
void
seekToPrevious
MediaItem
()
throws
Exception
{
int
initialMediaItemIndex
=
1
;
int
initialMediaItemIndex
=
1
;
String
firstMediaId
=
"firstMediaId"
;
String
firstMediaId
=
"firstMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
...
@@ -713,7 +713,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -713,7 +713,7 @@ public class MediaControllerStateMaskingTest {
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
MediaTestUtils
.
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
.
setCurrent
Window
Index
(
initialMediaItemIndex
)
.
setCurrent
MediaItem
Index
(
initialMediaItemIndex
)
.
setCurrentPeriodIndex
(
initialMediaItemIndex
)
.
setCurrentPeriodIndex
(
initialMediaItemIndex
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -747,13 +747,13 @@ public class MediaControllerStateMaskingTest {
...
@@ -747,13 +747,13 @@ public class MediaControllerStateMaskingTest {
}
}
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
seekToPrevious
Window
();
controller
.
seekToPrevious
MediaItem
();
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
});
});
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
...
@@ -762,7 +762,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -762,7 +762,7 @@ public class MediaControllerStateMaskingTest {
assertThat
(
newPositionInfoRef
.
get
().
mediaItemIndex
).
isEqualTo
(
testMediaItemIndex
);
assertThat
(
newPositionInfoRef
.
get
().
mediaItemIndex
).
isEqualTo
(
testMediaItemIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
current
Window
IndexRef
.
get
()).
isEqualTo
(
testMediaItemIndex
);
assertThat
(
current
MediaItem
IndexRef
.
get
()).
isEqualTo
(
testMediaItemIndex
);
}
}
@Test
@Test
...
@@ -770,19 +770,19 @@ public class MediaControllerStateMaskingTest {
...
@@ -770,19 +770,19 @@ public class MediaControllerStateMaskingTest {
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
long
initialTotalBufferedDuration
=
1_200
;
long
initialTotalBufferedDuration
=
1_200
;
int
test
Window
Index
=
0
;
int
test
MediaItem
Index
=
0
;
long
testPosition
=
9_000
;
long
testPosition
=
9_000
;
long
testBufferedPosition
=
initialBufferedPosition
;
long
testBufferedPosition
=
initialBufferedPosition
;
long
testTotalBufferedDuration
=
200
;
long
testTotalBufferedDuration
=
200
;
Timeline
testTimeline
=
createTimeline
(
1
);
Timeline
testTimeline
=
createTimeline
(
1
);
MediaItem
testCurrentMediaItem
=
MediaItem
testCurrentMediaItem
=
testTimeline
.
getWindow
(
test
Window
Index
,
new
Window
()).
mediaItem
;
testTimeline
.
getWindow
(
test
MediaItem
Index
,
new
Window
()).
mediaItem
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setCurrent
WindowIndex
(
testWindow
Index
)
.
setCurrent
MediaItemIndex
(
testMediaItem
Index
)
.
setCurrentPeriodIndex
(
test
Window
Index
)
.
setCurrentPeriodIndex
(
test
MediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
...
@@ -839,19 +839,19 @@ public class MediaControllerStateMaskingTest {
...
@@ -839,19 +839,19 @@ public class MediaControllerStateMaskingTest {
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
long
initialTotalBufferedDuration
=
1_200
;
long
initialTotalBufferedDuration
=
1_200
;
int
test
Window
Index
=
0
;
int
test
MediaItem
Index
=
0
;
long
testPosition
=
9_200
;
long
testPosition
=
9_200
;
long
testBufferedPosition
=
initialBufferedPosition
;
long
testBufferedPosition
=
initialBufferedPosition
;
long
testTotalBufferedDuration
=
0
;
long
testTotalBufferedDuration
=
0
;
Timeline
testTimeline
=
createTimeline
(
3
);
Timeline
testTimeline
=
createTimeline
(
3
);
MediaItem
testCurrentMediaItem
=
MediaItem
testCurrentMediaItem
=
testTimeline
.
getWindow
(
test
Window
Index
,
new
Window
()).
mediaItem
;
testTimeline
.
getWindow
(
test
MediaItem
Index
,
new
Window
()).
mediaItem
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setCurrent
WindowIndex
(
testWindow
Index
)
.
setCurrent
MediaItemIndex
(
testMediaItem
Index
)
.
setCurrentPeriodIndex
(
test
Window
Index
)
.
setCurrentPeriodIndex
(
test
MediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
...
@@ -908,19 +908,19 @@ public class MediaControllerStateMaskingTest {
...
@@ -908,19 +908,19 @@ public class MediaControllerStateMaskingTest {
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
long
initialTotalBufferedDuration
=
1_200
;
long
initialTotalBufferedDuration
=
1_200
;
int
test
Window
Index
=
0
;
int
test
MediaItem
Index
=
0
;
long
testPosition
=
1_000
;
long
testPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
long
testTotalBufferedDuration
=
0
;
long
testTotalBufferedDuration
=
0
;
Timeline
testTimeline
=
createTimeline
(
1
);
Timeline
testTimeline
=
createTimeline
(
1
);
MediaItem
testCurrentMediaItem
=
MediaItem
testCurrentMediaItem
=
testTimeline
.
getWindow
(
test
Window
Index
,
new
Window
()).
mediaItem
;
testTimeline
.
getWindow
(
test
MediaItem
Index
,
new
Window
()).
mediaItem
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setCurrent
WindowIndex
(
testWindow
Index
)
.
setCurrent
MediaItemIndex
(
testMediaItem
Index
)
.
setCurrentPeriodIndex
(
test
Window
Index
)
.
setCurrentPeriodIndex
(
test
MediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
...
@@ -975,7 +975,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -975,7 +975,7 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
seekTo_toDifferentPeriodInSameWindow
()
throws
Exception
{
public
void
seekTo_toDifferentPeriodInSameWindow
()
throws
Exception
{
long
defaultPeriodDuration
=
10_000
;
long
defaultPeriodDuration
=
10_000
;
int
initial
Window
Index
=
0
;
int
initial
MediaItem
Index
=
0
;
int
initialPeriodIndex
=
0
;
int
initialPeriodIndex
=
0
;
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
...
@@ -989,7 +989,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -989,7 +989,7 @@ public class MediaControllerStateMaskingTest {
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
3
},
defaultPeriodDuration
))
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
3
},
defaultPeriodDuration
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
...
@@ -1046,7 +1046,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1046,7 +1046,7 @@ public class MediaControllerStateMaskingTest {
public
void
seekTo_toDifferentPeriodInSameWindow_doesNotCallOnMediaItemTransition
()
public
void
seekTo_toDifferentPeriodInSameWindow_doesNotCallOnMediaItemTransition
()
throws
Exception
{
throws
Exception
{
long
defaultPeriodDuration
=
10_000
;
long
defaultPeriodDuration
=
10_000
;
int
initial
Window
Index
=
0
;
int
initial
MediaItem
Index
=
0
;
int
initialPeriodIndex
=
0
;
int
initialPeriodIndex
=
0
;
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
testPosition
=
16_000
;
long
testPosition
=
16_000
;
...
@@ -1055,7 +1055,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1055,7 +1055,7 @@ public class MediaControllerStateMaskingTest {
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
3
},
defaultPeriodDuration
))
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
3
},
defaultPeriodDuration
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
...
@@ -1079,24 +1079,24 @@ public class MediaControllerStateMaskingTest {
...
@@ -1079,24 +1079,24 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
seekTo_toDifferentPeriodInDifferentWindow
()
throws
Exception
{
public
void
seekTo_toDifferentPeriodInDifferentWindow
()
throws
Exception
{
int
initial
Window
Index
=
2
;
int
initial
MediaItem
Index
=
2
;
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
long
initialTotalBufferedDuration
=
1_200
;
long
initialTotalBufferedDuration
=
1_200
;
int
test
Window
Index
=
0
;
int
test
MediaItem
Index
=
0
;
int
testPeriodIndex
=
0
;
int
testPeriodIndex
=
0
;
long
testPosition
=
1_000
;
long
testPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
long
testTotalBufferedDuration
=
0
;
long
testTotalBufferedDuration
=
0
;
Timeline
testTimeline
=
createTimeline
(
3
);
Timeline
testTimeline
=
createTimeline
(
3
);
MediaItem
testCurrentMediaItem
=
MediaItem
testCurrentMediaItem
=
testTimeline
.
getWindow
(
test
Window
Index
,
new
Window
()).
mediaItem
;
testTimeline
.
getWindow
(
test
MediaItem
Index
,
new
Window
()).
mediaItem
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
...
@@ -1124,7 +1124,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1124,7 +1124,7 @@ public class MediaControllerStateMaskingTest {
}
}
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
...
@@ -1134,8 +1134,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -1134,8 +1134,8 @@ public class MediaControllerStateMaskingTest {
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
seekTo
(
test
Window
Index
,
testPosition
);
controller
.
seekTo
(
test
MediaItem
Index
,
testPosition
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPositionRef
.
set
(
controller
.
getCurrentPosition
());
currentPositionRef
.
set
(
controller
.
getCurrentPosition
());
bufferedPositionRef
.
set
(
controller
.
getBufferedPosition
());
bufferedPositionRef
.
set
(
controller
.
getBufferedPosition
());
...
@@ -1146,7 +1146,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1146,7 +1146,7 @@ public class MediaControllerStateMaskingTest {
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
newPositionInfoRef
.
get
().
positionMs
).
isEqualTo
(
testPosition
);
assertThat
(
newPositionInfoRef
.
get
().
positionMs
).
isEqualTo
(
testPosition
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
...
@@ -1156,13 +1156,13 @@ public class MediaControllerStateMaskingTest {
...
@@ -1156,13 +1156,13 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
seekTo_whilePlayingAd_ignored
()
throws
Exception
{
public
void
seekTo_whilePlayingAd_ignored
()
throws
Exception
{
int
initial
Window
Index
=
0
;
int
initial
MediaItem
Index
=
0
;
int
initialPosition
=
0
;
int
initialPosition
=
0
;
int
seekPosition
=
3_000
;
int
seekPosition
=
3_000
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setIsPlayingAd
(
/* isPlayingAd= */
true
)
.
setIsPlayingAd
(
/* isPlayingAd= */
true
)
...
@@ -1170,59 +1170,59 @@ public class MediaControllerStateMaskingTest {
...
@@ -1170,59 +1170,59 @@ public class MediaControllerStateMaskingTest {
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPositionRef
=
new
AtomicInteger
();
AtomicInteger
currentPositionRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
seekTo
(
seekPosition
);
controller
.
seekTo
(
seekPosition
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
});
});
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
initialWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
initialMediaItem
Index
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
initialPosition
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
initialPosition
);
}
}
@Test
@Test
public
void
seekTo_samePosition_ignored
()
throws
Exception
{
public
void
seekTo_samePosition_ignored
()
throws
Exception
{
int
initial
Window
Index
=
0
;
int
initial
MediaItem
Index
=
0
;
int
initialPosition
=
3_000
;
int
initialPosition
=
3_000
;
int
seekPosition
=
3_000
;
int
seekPosition
=
3_000
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPositionRef
=
new
AtomicInteger
();
AtomicInteger
currentPositionRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
seekTo
(
seekPosition
);
controller
.
seekTo
(
seekPosition
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
});
});
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
initialWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
initialMediaItem
Index
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
initialPosition
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
initialPosition
);
}
}
@Test
@Test
public
void
seekTo_withEmptyTimeline
()
throws
Exception
{
public
void
seekTo_withEmptyTimeline
()
throws
Exception
{
int
initial
Window
Index
=
0
;
int
initial
MediaItem
Index
=
0
;
int
initialPeriodIndex
=
0
;
int
initialPeriodIndex
=
0
;
int
initialPosition
=
0
;
int
initialPosition
=
0
;
int
initialBufferedPosition
=
0
;
int
initialBufferedPosition
=
0
;
int
initialTotalBufferedPosition
=
0
;
int
initialTotalBufferedPosition
=
0
;
int
test
Window
Index
=
3
;
int
test
MediaItem
Index
=
3
;
int
testPeriodIndex
=
initialPeriodIndex
;
int
testPeriodIndex
=
initialPeriodIndex
;
long
testSeekPositionMs
=
3_000
;
long
testSeekPositionMs
=
3_000
;
long
testPosition
=
testSeekPositionMs
;
long
testPosition
=
testSeekPositionMs
;
...
@@ -1231,7 +1231,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1231,7 +1231,7 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
...
@@ -1261,7 +1261,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1261,7 +1261,7 @@ public class MediaControllerStateMaskingTest {
}
}
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPositionRef
=
new
AtomicInteger
();
AtomicInteger
currentPositionRef
=
new
AtomicInteger
();
AtomicInteger
bufferedPositionRef
=
new
AtomicInteger
();
AtomicInteger
bufferedPositionRef
=
new
AtomicInteger
();
...
@@ -1270,8 +1270,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -1270,8 +1270,8 @@ public class MediaControllerStateMaskingTest {
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
seekTo
(
test
Window
Index
,
testSeekPositionMs
);
controller
.
seekTo
(
test
MediaItem
Index
,
testSeekPositionMs
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
...
@@ -1281,7 +1281,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1281,7 +1281,7 @@ public class MediaControllerStateMaskingTest {
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
newPositionInfoRef
.
get
().
positionMs
).
isEqualTo
(
testSeekPositionMs
);
assertThat
(
newPositionInfoRef
.
get
().
positionMs
).
isEqualTo
(
testSeekPositionMs
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
...
@@ -1383,12 +1383,12 @@ public class MediaControllerStateMaskingTest {
...
@@ -1383,12 +1383,12 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
setMediaItems_withResetPosition
()
throws
Exception
{
public
void
setMediaItems_withResetPosition
()
throws
Exception
{
int
initial
Window
Index
=
2
;
int
initial
MediaItem
Index
=
2
;
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
long
initialTotalBufferedDuration
=
1_200
;
long
initialTotalBufferedDuration
=
1_200
;
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
int
test
Window
Index
=
0
;
int
test
MediaItem
Index
=
0
;
int
testPeriodIndex
=
0
;
int
testPeriodIndex
=
0
;
long
testPosition
=
0
;
long
testPosition
=
0
;
long
testBufferedPosition
=
0
;
long
testBufferedPosition
=
0
;
...
@@ -1397,8 +1397,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -1397,8 +1397,8 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
3
))
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
3
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
...
@@ -1434,7 +1434,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1434,7 +1434,7 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
AtomicLong
totalBufferedDurationRef
=
new
AtomicLong
();
AtomicLong
totalBufferedDurationRef
=
new
AtomicLong
();
...
@@ -1445,7 +1445,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1445,7 +1445,7 @@ public class MediaControllerStateMaskingTest {
()
->
{
()
->
{
controller
.
setMediaItems
(
controller
.
setMediaItems
(
createMediaItems
(
testMediaItemCount
),
/* resetPosition= */
true
);
createMediaItems
(
testMediaItemCount
),
/* resetPosition= */
true
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
totalBufferedDurationRef
.
set
((
int
)
controller
.
getTotalBufferedDuration
());
totalBufferedDurationRef
.
set
((
int
)
controller
.
getTotalBufferedDuration
());
...
@@ -1457,11 +1457,11 @@ public class MediaControllerStateMaskingTest {
...
@@ -1457,11 +1457,11 @@ public class MediaControllerStateMaskingTest {
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
testMediaItemCount
,
testMediaItemCount
,
test
Window
Index
,
test
MediaItem
Index
,
/* testFirstPeriodIndex= */
testPeriodIndex
,
/* testFirstPeriodIndex= */
testPeriodIndex
,
/* testLastPeriodIndex= */
testPeriodIndex
);
/* testLastPeriodIndex= */
testPeriodIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
...
@@ -1469,15 +1469,15 @@ public class MediaControllerStateMaskingTest {
...
@@ -1469,15 +1469,15 @@ public class MediaControllerStateMaskingTest {
}
}
@Test
@Test
public
void
setMediaItems_withStart
Window
IndexAndStartPosition
()
throws
Exception
{
public
void
setMediaItems_withStart
MediaItem
IndexAndStartPosition
()
throws
Exception
{
int
initial
Window
Index
=
2
;
int
initial
MediaItem
Index
=
2
;
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
long
initialTotalBufferedDuration
=
1_200
;
long
initialTotalBufferedDuration
=
1_200
;
String
dummyMediaId
=
"dummyMediaId"
;
String
dummyMediaId
=
"dummyMediaId"
;
String
test
WindowIndexMediaId
=
"testWindow
IndexMediaId"
;
String
test
MediaItemIndexMediaId
=
"testMediaItem
IndexMediaId"
;
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
int
test
Window
Index
=
1
;
int
test
MediaItem
Index
=
1
;
int
testPeriodIndex
=
1
;
int
testPeriodIndex
=
1
;
long
testPosition
=
1_000
;
long
testPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
...
@@ -1486,8 +1486,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -1486,8 +1486,8 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
3
))
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
3
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
...
@@ -1530,7 +1530,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1530,7 +1530,7 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
...
@@ -1540,10 +1540,10 @@ public class MediaControllerStateMaskingTest {
...
@@ -1540,10 +1540,10 @@ public class MediaControllerStateMaskingTest {
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
setMediaItems
(
controller
.
setMediaItems
(
createMediaItems
(
dummyMediaId
,
test
Window
IndexMediaId
),
createMediaItems
(
dummyMediaId
,
test
MediaItem
IndexMediaId
),
/* start
WindowIndex= */
testWindow
Index
,
/* start
MediaItemIndex= */
testMediaItem
Index
,
/* startPositionMs= */
testPosition
);
/* startPositionMs= */
testPosition
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
...
@@ -1555,14 +1555,14 @@ public class MediaControllerStateMaskingTest {
...
@@ -1555,14 +1555,14 @@ public class MediaControllerStateMaskingTest {
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
testMediaItemCount
,
testMediaItemCount
,
test
Window
Index
,
test
MediaItem
Index
,
/* testFirstPeriodIndex= */
testPeriodIndex
,
/* testFirstPeriodIndex= */
testPeriodIndex
,
/* testLastPeriodIndex= */
testPeriodIndex
);
/* testLastPeriodIndex= */
testPeriodIndex
);
assertThat
(
newMediaItemRef
.
get
().
mediaId
).
isEqualTo
(
test
Window
IndexMediaId
);
assertThat
(
newMediaItemRef
.
get
().
mediaId
).
isEqualTo
(
test
MediaItem
IndexMediaId
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
...
@@ -1571,12 +1571,12 @@ public class MediaControllerStateMaskingTest {
...
@@ -1571,12 +1571,12 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
setMediaItems_withEmptyList
()
throws
Exception
{
public
void
setMediaItems_withEmptyList
()
throws
Exception
{
int
initial
Window
Index
=
2
;
int
initial
MediaItem
Index
=
2
;
long
initialPosition
=
8_000
;
long
initialPosition
=
8_000
;
long
initialBufferedPosition
=
9_200
;
long
initialBufferedPosition
=
9_200
;
long
initialTotalBufferedDuration
=
1_200
;
long
initialTotalBufferedDuration
=
1_200
;
List
<
MediaItem
>
testMediaItemList
=
new
ArrayList
<>();
List
<
MediaItem
>
testMediaItemList
=
new
ArrayList
<>();
int
test
Window
Index
=
1
;
int
test
MediaItem
Index
=
1
;
int
testPeriodIndex
=
0
;
int
testPeriodIndex
=
0
;
long
testPosition
=
1_000
;
long
testPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
long
testBufferedPosition
=
1_000
;
...
@@ -1585,8 +1585,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -1585,8 +1585,8 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
3
))
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
3
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
setCurrentPosition
(
initialPosition
)
.
setCurrentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setContentPosition
(
initialPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
.
setBufferedPosition
(
initialBufferedPosition
)
...
@@ -1629,7 +1629,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1629,7 +1629,7 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
currentPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
AtomicLong
bufferedPositionRef
=
new
AtomicLong
();
...
@@ -1640,9 +1640,9 @@ public class MediaControllerStateMaskingTest {
...
@@ -1640,9 +1640,9 @@ public class MediaControllerStateMaskingTest {
()
->
{
()
->
{
controller
.
setMediaItems
(
controller
.
setMediaItems
(
testMediaItemList
,
testMediaItemList
,
/* start
WindowIndex= */
testWindow
Index
,
/* start
MediaItemIndex= */
testMediaItem
Index
,
/* startPositionMs= */
testPosition
);
/* startPositionMs= */
testPosition
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
currentPositionRef
.
set
((
int
)
controller
.
getCurrentPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
bufferedPositionRef
.
set
((
int
)
controller
.
getBufferedPosition
());
...
@@ -1656,7 +1656,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1656,7 +1656,7 @@ public class MediaControllerStateMaskingTest {
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_POSITION_DISCONTINUITY
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testPeriodIndex
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
currentPositionRef
.
get
()).
isEqualTo
(
testPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
assertThat
(
bufferedPositionRef
.
get
()).
isEqualTo
(
testBufferedPosition
);
...
@@ -1690,9 +1690,9 @@ public class MediaControllerStateMaskingTest {
...
@@ -1690,9 +1690,9 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
addMediaItems_toEmptyTimeline
()
throws
Exception
{
public
void
addMediaItems_toEmptyTimeline
()
throws
Exception
{
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
int
testCurrent
Window
Index
=
0
;
int
testCurrent
MediaItem
Index
=
0
;
int
testNext
Window
Index
=
1
;
int
testNext
MediaItem
Index
=
1
;
int
testPrevious
Window
Index
=
C
.
INDEX_UNSET
;
int
testPrevious
MediaItem
Index
=
C
.
INDEX_UNSET
;
int
testCurrentPeriodIndex
=
0
;
int
testCurrentPeriodIndex
=
0
;
List
<
MediaItem
>
testMediaItems
=
createMediaItems
(
testMediaItemCount
);
List
<
MediaItem
>
testMediaItems
=
createMediaItems
(
testMediaItemCount
);
MediaItem
testMediaItem
=
testMediaItems
.
get
(
testCurrentPeriodIndex
);
MediaItem
testMediaItem
=
testMediaItems
.
get
(
testCurrentPeriodIndex
);
...
@@ -1727,18 +1727,18 @@ public class MediaControllerStateMaskingTest {
...
@@ -1727,18 +1727,18 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
addMediaItems
(
testMediaItems
);
controller
.
addMediaItems
(
testMediaItems
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
next
WindowIndexRef
.
set
(
controller
.
getNextWindow
Index
());
next
MediaItemIndexRef
.
set
(
controller
.
getNextMediaItem
Index
());
previous
WindowIndexRef
.
set
(
controller
.
getPreviousWindow
Index
());
previous
MediaItemIndexRef
.
set
(
controller
.
getPreviousMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
});
});
...
@@ -1746,13 +1746,13 @@ public class MediaControllerStateMaskingTest {
...
@@ -1746,13 +1746,13 @@ public class MediaControllerStateMaskingTest {
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
testMediaItemCount
,
testMediaItemCount
,
testCurrent
Window
Index
,
testCurrent
MediaItem
Index
,
/* testFirstPeriodIndex= */
testCurrentPeriodIndex
,
/* testFirstPeriodIndex= */
testCurrentPeriodIndex
,
/* testLastPeriodIndex= */
testCurrentPeriodIndex
);
/* testLastPeriodIndex= */
testCurrentPeriodIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
next
WindowIndexRef
.
get
()).
isEqualTo
(
testNextWindow
Index
);
assertThat
(
next
MediaItemIndexRef
.
get
()).
isEqualTo
(
testNextMediaItem
Index
);
assertThat
(
previous
WindowIndexRef
.
get
()).
isEqualTo
(
testPreviousWindow
Index
);
assertThat
(
previous
MediaItemIndexRef
.
get
()).
isEqualTo
(
testPreviousMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
newMediaItemRef
.
get
()).
isEqualTo
(
testMediaItem
);
assertThat
(
newMediaItemRef
.
get
()).
isEqualTo
(
testMediaItem
);
}
}
...
@@ -1760,18 +1760,18 @@ public class MediaControllerStateMaskingTest {
...
@@ -1760,18 +1760,18 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
addMediaItems_toEndOfTimeline
()
throws
Exception
{
public
void
addMediaItems_toEndOfTimeline
()
throws
Exception
{
int
initialMediaItemCount
=
3
;
int
initialMediaItemCount
=
3
;
int
initial
Window
Index
=
2
;
int
initial
MediaItem
Index
=
2
;
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
int
testCurrent
WindowIndex
=
initialWindow
Index
;
int
testCurrent
MediaItemIndex
=
initialMediaItem
Index
;
int
testNext
WindowIndex
=
testCurrentWindow
Index
+
1
;
int
testNext
MediaItemIndex
=
testCurrentMediaItem
Index
+
1
;
int
testPrevious
WindowIndex
=
testCurrentWindow
Index
-
1
;
int
testPrevious
MediaItemIndex
=
testCurrentMediaItem
Index
-
1
;
int
testCurrentPeriodIndex
=
initial
Window
Index
;
int
testCurrentPeriodIndex
=
initial
MediaItem
Index
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
initialMediaItemCount
))
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
initialMediaItemCount
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -1795,18 +1795,18 @@ public class MediaControllerStateMaskingTest {
...
@@ -1795,18 +1795,18 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
addMediaItems
(
createMediaItems
(
testMediaItemCount
));
controller
.
addMediaItems
(
createMediaItems
(
testMediaItemCount
));
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
next
WindowIndexRef
.
set
(
controller
.
getNextWindow
Index
());
next
MediaItemIndexRef
.
set
(
controller
.
getNextMediaItem
Index
());
previous
WindowIndexRef
.
set
(
controller
.
getPreviousWindow
Index
());
previous
MediaItemIndexRef
.
set
(
controller
.
getPreviousMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
});
});
...
@@ -1814,33 +1814,33 @@ public class MediaControllerStateMaskingTest {
...
@@ -1814,33 +1814,33 @@ public class MediaControllerStateMaskingTest {
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
initialMediaItemCount
+
testMediaItemCount
,
initialMediaItemCount
+
testMediaItemCount
,
testCurrent
Window
Index
,
testCurrent
MediaItem
Index
,
/* testFirstPeriodIndex= */
testCurrentPeriodIndex
,
/* testFirstPeriodIndex= */
testCurrentPeriodIndex
,
/* testLastPeriodIndex= */
testCurrentPeriodIndex
);
/* testLastPeriodIndex= */
testCurrentPeriodIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
next
WindowIndexRef
.
get
()).
isEqualTo
(
testNextWindow
Index
);
assertThat
(
next
MediaItemIndexRef
.
get
()).
isEqualTo
(
testNextMediaItem
Index
);
assertThat
(
previous
WindowIndexRef
.
get
()).
isEqualTo
(
testPreviousWindow
Index
);
assertThat
(
previous
MediaItemIndexRef
.
get
()).
isEqualTo
(
testPreviousMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
}
}
@Test
@Test
public
void
addMediaItems_toTimelineWithSinglePeriodPerWindow
()
throws
Exception
{
public
void
addMediaItems_toTimelineWithSinglePeriodPerWindow
()
throws
Exception
{
int
initialMediaItemCount
=
3
;
int
initialMediaItemCount
=
3
;
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
int
initialPeriodIndex
=
1
;
int
initialPeriodIndex
=
1
;
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
assertAddMediaItems
(
assertAddMediaItems
(
initialMediaItemCount
,
initialMediaItemCount
,
initial
Window
Index
,
initial
MediaItem
Index
,
initialPeriodIndex
,
initialPeriodIndex
,
/* initialTimeline= */
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
1
,
1
,
1
}),
/* initialTimeline= */
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
1
,
1
,
1
}),
testMediaItemCount
,
testMediaItemCount
,
/* testIndex= */
1
,
/* testIndex= */
1
,
/* testCurrent
WindowIndex= */
initialWindow
Index
+
testMediaItemCount
,
/* testCurrent
MediaItemIndex= */
initialMediaItem
Index
+
testMediaItemCount
,
/* testNext
WindowIndex= */
initialWindow
Index
+
testMediaItemCount
+
1
,
/* testNext
MediaItemIndex= */
initialMediaItem
Index
+
testMediaItemCount
+
1
,
/* testPrevious
WindowIndex= */
initialWindow
Index
+
testMediaItemCount
-
1
,
/* testPrevious
MediaItemIndex= */
initialMediaItem
Index
+
testMediaItemCount
-
1
,
/* testCurrentPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
,
/* testCurrentPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
,
/* testCurrentWindowFirstPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
,
/* testCurrentWindowFirstPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
,
/* testCurrentWindowLastPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
);
/* testCurrentWindowLastPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
);
...
@@ -1849,7 +1849,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1849,7 +1849,7 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
addMediaItems_toTimelineWithMultiplePeriodsPerWindow
()
throws
Exception
{
public
void
addMediaItems_toTimelineWithMultiplePeriodsPerWindow
()
throws
Exception
{
int
initialMediaItemCount
=
3
;
int
initialMediaItemCount
=
3
;
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
int
initialWindowFirstPeriodIndex
=
2
;
int
initialWindowFirstPeriodIndex
=
2
;
int
initialWindowLastPeriodIndex
=
4
;
int
initialWindowLastPeriodIndex
=
4
;
int
initialPeriodIndex
=
3
;
int
initialPeriodIndex
=
3
;
...
@@ -1857,14 +1857,14 @@ public class MediaControllerStateMaskingTest {
...
@@ -1857,14 +1857,14 @@ public class MediaControllerStateMaskingTest {
assertAddMediaItems
(
assertAddMediaItems
(
initialMediaItemCount
,
initialMediaItemCount
,
initial
Window
Index
,
initial
MediaItem
Index
,
initialPeriodIndex
,
initialPeriodIndex
,
/* initialTimeline= */
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
2
,
3
,
2
}),
/* initialTimeline= */
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
2
,
3
,
2
}),
testMediaItemCount
,
testMediaItemCount
,
/* testIndex= */
1
,
/* testIndex= */
1
,
/* testCurrent
WindowIndex= */
initialWindow
Index
+
testMediaItemCount
,
/* testCurrent
MediaItemIndex= */
initialMediaItem
Index
+
testMediaItemCount
,
/* testNext
WindowIndex= */
initialWindow
Index
+
testMediaItemCount
+
1
,
/* testNext
MediaItemIndex= */
initialMediaItem
Index
+
testMediaItemCount
+
1
,
/* testPrevious
WindowIndex= */
initialWindow
Index
+
testMediaItemCount
-
1
,
/* testPrevious
MediaItemIndex= */
initialMediaItem
Index
+
testMediaItemCount
-
1
,
/* testCurrentPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
,
/* testCurrentPeriodIndex= */
initialPeriodIndex
+
testMediaItemCount
,
/* testCurrentWindowFirstPeriodIndex= */
initialWindowFirstPeriodIndex
+
testMediaItemCount
,
/* testCurrentWindowFirstPeriodIndex= */
initialWindowFirstPeriodIndex
+
testMediaItemCount
,
/* testCurrentWindowLastPeriodIndex= */
initialWindowLastPeriodIndex
+
testMediaItemCount
);
/* testCurrentWindowLastPeriodIndex= */
initialWindowLastPeriodIndex
+
testMediaItemCount
);
...
@@ -1872,14 +1872,14 @@ public class MediaControllerStateMaskingTest {
...
@@ -1872,14 +1872,14 @@ public class MediaControllerStateMaskingTest {
private
void
assertAddMediaItems
(
private
void
assertAddMediaItems
(
int
initialMediaItemCount
,
int
initialMediaItemCount
,
int
initial
Window
Index
,
int
initial
MediaItem
Index
,
int
initialPeriodIndex
,
int
initialPeriodIndex
,
Timeline
initialTimeline
,
Timeline
initialTimeline
,
int
testMediaItemCount
,
int
testMediaItemCount
,
int
testIndex
,
int
testIndex
,
int
testCurrent
Window
Index
,
int
testCurrent
MediaItem
Index
,
int
testNext
Window
Index
,
int
testNext
MediaItem
Index
,
int
testPrevious
Window
Index
,
int
testPrevious
MediaItem
Index
,
int
testCurrentPeriodIndex
,
int
testCurrentPeriodIndex
,
int
testCurrentWindowFirstPeriodIndex
,
int
testCurrentWindowFirstPeriodIndex
,
int
testCurrentWindowLastPeriodIndex
)
int
testCurrentWindowLastPeriodIndex
)
...
@@ -1887,7 +1887,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -1887,7 +1887,7 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
initialTimeline
)
.
setTimeline
(
initialTimeline
)
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -1912,9 +1912,9 @@ public class MediaControllerStateMaskingTest {
...
@@ -1912,9 +1912,9 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
...
@@ -1922,9 +1922,9 @@ public class MediaControllerStateMaskingTest {
...
@@ -1922,9 +1922,9 @@ public class MediaControllerStateMaskingTest {
()
->
{
()
->
{
controller
.
addMediaItems
(
controller
.
addMediaItems
(
/* index= */
testIndex
,
createMediaItems
(
testMediaItemCount
));
/* index= */
testIndex
,
createMediaItems
(
testMediaItemCount
));
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
next
WindowIndexRef
.
set
(
controller
.
getNextWindow
Index
());
next
MediaItemIndexRef
.
set
(
controller
.
getNextMediaItem
Index
());
previous
WindowIndexRef
.
set
(
controller
.
getPreviousWindow
Index
());
previous
MediaItemIndexRef
.
set
(
controller
.
getPreviousMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
});
});
...
@@ -1932,19 +1932,19 @@ public class MediaControllerStateMaskingTest {
...
@@ -1932,19 +1932,19 @@ public class MediaControllerStateMaskingTest {
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
initialMediaItemCount
+
testMediaItemCount
,
initialMediaItemCount
+
testMediaItemCount
,
testCurrent
Window
Index
,
testCurrent
MediaItem
Index
,
/* testFirstPeriodIndex= */
testCurrentWindowFirstPeriodIndex
,
/* testFirstPeriodIndex= */
testCurrentWindowFirstPeriodIndex
,
/* testLastPeriodIndex= */
testCurrentWindowLastPeriodIndex
);
/* testLastPeriodIndex= */
testCurrentWindowLastPeriodIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
next
WindowIndexRef
.
get
()).
isEqualTo
(
testNextWindow
Index
);
assertThat
(
next
MediaItemIndexRef
.
get
()).
isEqualTo
(
testNextMediaItem
Index
);
assertThat
(
previous
WindowIndexRef
.
get
()).
isEqualTo
(
testPreviousWindow
Index
);
assertThat
(
previous
MediaItemIndexRef
.
get
()).
isEqualTo
(
testPreviousMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
}
}
@Test
@Test
public
void
removeMediaItems_currentItemRemoved
()
throws
Exception
{
public
void
removeMediaItems_currentItemRemoved
()
throws
Exception
{
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
String
firstMediaId
=
"firstMediaId"
;
String
firstMediaId
=
"firstMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
thirdMediaId
=
"thirdMediaId"
;
String
thirdMediaId
=
"thirdMediaId"
;
...
@@ -1953,16 +1953,16 @@ public class MediaControllerStateMaskingTest {
...
@@ -1953,16 +1953,16 @@ public class MediaControllerStateMaskingTest {
int
testToIndex
=
2
;
int
testToIndex
=
2
;
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
int
testCurrentMediaItemIndex
=
testFromIndex
;
int
testCurrentMediaItemIndex
=
testFromIndex
;
int
testNext
Window
Index
=
C
.
INDEX_UNSET
;
int
testNext
MediaItem
Index
=
C
.
INDEX_UNSET
;
int
testPrevious
Window
Index
=
testCurrentMediaItemIndex
-
1
;
int
testPrevious
MediaItem
Index
=
testCurrentMediaItemIndex
-
1
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createTimeline
(
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2001,18 +2001,18 @@ public class MediaControllerStateMaskingTest {
...
@@ -2001,18 +2001,18 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
MediaItem
IndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
removeMediaItems
(
controller
.
removeMediaItems
(
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
next
WindowIndexRef
.
set
(
controller
.
getNextWindow
Index
());
next
MediaItemIndexRef
.
set
(
controller
.
getNextMediaItem
Index
());
previous
WindowIndexRef
.
set
(
controller
.
getPreviousWindow
Index
());
previous
MediaItemIndexRef
.
set
(
controller
.
getPreviousMediaItem
Index
());
});
});
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
...
@@ -2026,14 +2026,14 @@ public class MediaControllerStateMaskingTest {
...
@@ -2026,14 +2026,14 @@ public class MediaControllerStateMaskingTest {
assertThat
(
newPositionInfoRef
.
get
().
mediaItemIndex
).
isEqualTo
(
testCurrentMediaItemIndex
);
assertThat
(
newPositionInfoRef
.
get
().
mediaItemIndex
).
isEqualTo
(
testCurrentMediaItemIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
current
Window
IndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItemIndex
);
assertThat
(
current
MediaItem
IndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItemIndex
);
assertThat
(
next
WindowIndexRef
.
get
()).
isEqualTo
(
testNextWindow
Index
);
assertThat
(
next
MediaItemIndexRef
.
get
()).
isEqualTo
(
testNextMediaItem
Index
);
assertThat
(
previous
WindowIndexRef
.
get
()).
isEqualTo
(
testPreviousWindow
Index
);
assertThat
(
previous
MediaItemIndexRef
.
get
()).
isEqualTo
(
testPreviousMediaItem
Index
);
}
}
@Test
@Test
public
void
removeMediaItems_currentItemNotRemoved
()
throws
Exception
{
public
void
removeMediaItems_currentItemNotRemoved
()
throws
Exception
{
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
String
firstMediaId
=
"firstMediaId"
;
String
firstMediaId
=
"firstMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
thirdMediaId
=
"thirdMediaId"
;
String
thirdMediaId
=
"thirdMediaId"
;
...
@@ -2041,17 +2041,17 @@ public class MediaControllerStateMaskingTest {
...
@@ -2041,17 +2041,17 @@ public class MediaControllerStateMaskingTest {
int
testFromIndex
=
2
;
int
testFromIndex
=
2
;
int
testToIndex
=
3
;
int
testToIndex
=
3
;
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
int
testCurrent
WindowIndex
=
initialWindow
Index
;
int
testCurrent
MediaItemIndex
=
initialMediaItem
Index
;
int
testNext
Window
Index
=
C
.
INDEX_UNSET
;
int
testNext
MediaItem
Index
=
C
.
INDEX_UNSET
;
int
testPrevious
WindowIndex
=
testCurrentWindow
Index
-
1
;
int
testPrevious
MediaItemIndex
=
testCurrentMediaItem
Index
-
1
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createTimeline
(
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2075,39 +2075,39 @@ public class MediaControllerStateMaskingTest {
...
@@ -2075,39 +2075,39 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
MediaItem
IndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
removeMediaItems
(
controller
.
removeMediaItems
(
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
next
WindowIndexRef
.
set
(
controller
.
getNextWindow
Index
());
next
MediaItemIndexRef
.
set
(
controller
.
getNextMediaItem
Index
());
previous
WindowIndexRef
.
set
(
controller
.
getPreviousWindow
Index
());
previous
MediaItemIndexRef
.
set
(
controller
.
getPreviousMediaItem
Index
());
});
});
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
testMediaItemCount
,
testMediaItemCount
,
testCurrent
Window
Index
,
testCurrent
MediaItem
Index
,
/* testFirstPeriodIndex= */
testCurrent
Window
Index
,
/* testFirstPeriodIndex= */
testCurrent
MediaItem
Index
,
/* testLastPeriodIndex= */
testCurrent
Window
Index
);
/* testLastPeriodIndex= */
testCurrent
MediaItem
Index
);
Window
window
=
new
Window
();
Window
window
=
new
Window
();
assertThat
(
newTimelineRef
.
get
().
getWindow
(
testCurrent
Window
Index
,
window
).
mediaItem
.
mediaId
)
assertThat
(
newTimelineRef
.
get
().
getWindow
(
testCurrent
MediaItem
Index
,
window
).
mediaItem
.
mediaId
)
.
isEqualTo
(
testCurrentMediaId
);
.
isEqualTo
(
testCurrentMediaId
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
next
WindowIndexRef
.
get
()).
isEqualTo
(
testNextWindow
Index
);
assertThat
(
next
MediaItemIndexRef
.
get
()).
isEqualTo
(
testNextMediaItem
Index
);
assertThat
(
previous
WindowIndexRef
.
get
()).
isEqualTo
(
testPreviousWindow
Index
);
assertThat
(
previous
MediaItemIndexRef
.
get
()).
isEqualTo
(
testPreviousMediaItem
Index
);
}
}
@Test
@Test
public
void
removeMediaItems_removePreviousItemWithMultiplePeriods
()
throws
Exception
{
public
void
removeMediaItems_removePreviousItemWithMultiplePeriods
()
throws
Exception
{
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
int
initialWindowFirstPeriodIndex
=
2
;
int
initialWindowFirstPeriodIndex
=
2
;
int
initialWindowLastPeriodIndex
=
4
;
int
initialWindowLastPeriodIndex
=
4
;
int
initialPeriodIndex
=
3
;
int
initialPeriodIndex
=
3
;
...
@@ -2115,7 +2115,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2115,7 +2115,7 @@ public class MediaControllerStateMaskingTest {
int
testToIndex
=
1
;
int
testToIndex
=
1
;
int
testMediaItemCount
=
2
;
int
testMediaItemCount
=
2
;
int
prevWindowPeriodSize
=
2
;
int
prevWindowPeriodSize
=
2
;
int
testCurrent
Window
Index
=
0
;
int
testCurrent
MediaItem
Index
=
0
;
int
testCurrentPeriodIndex
=
initialPeriodIndex
-
prevWindowPeriodSize
;
int
testCurrentPeriodIndex
=
initialPeriodIndex
-
prevWindowPeriodSize
;
int
testCurrentWindowFirstPeriodIndex
=
initialWindowFirstPeriodIndex
-
prevWindowPeriodSize
;
int
testCurrentWindowFirstPeriodIndex
=
initialWindowFirstPeriodIndex
-
prevWindowPeriodSize
;
int
testCurrentWindowLastPeriodIndex
=
initialWindowLastPeriodIndex
-
prevWindowPeriodSize
;
int
testCurrentWindowLastPeriodIndex
=
initialWindowLastPeriodIndex
-
prevWindowPeriodSize
;
...
@@ -2125,7 +2125,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2125,7 +2125,7 @@ public class MediaControllerStateMaskingTest {
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
prevWindowPeriodSize
,
3
,
2
}))
new
int
[]
{
prevWindowPeriodSize
,
3
,
2
}))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2150,7 +2150,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2150,7 +2150,7 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
...
@@ -2158,7 +2158,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2158,7 +2158,7 @@ public class MediaControllerStateMaskingTest {
()
->
{
()
->
{
controller
.
removeMediaItems
(
controller
.
removeMediaItems
(
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
});
});
...
@@ -2166,17 +2166,17 @@ public class MediaControllerStateMaskingTest {
...
@@ -2166,17 +2166,17 @@ public class MediaControllerStateMaskingTest {
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
testMediaItemCount
,
testMediaItemCount
,
testCurrent
Window
Index
,
testCurrent
MediaItem
Index
,
/* testFirstPeriodIndex= */
testCurrentWindowFirstPeriodIndex
,
/* testFirstPeriodIndex= */
testCurrentWindowFirstPeriodIndex
,
/* testLastPeriodIndex= */
testCurrentWindowLastPeriodIndex
);
/* testLastPeriodIndex= */
testCurrentWindowLastPeriodIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
}
}
@Test
@Test
public
void
removeMediaItems_removeAllItems
()
throws
Exception
{
public
void
removeMediaItems_removeAllItems
()
throws
Exception
{
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
int
initialPlaybackState
=
STATE_READY
;
int
initialPlaybackState
=
STATE_READY
;
long
initialCurrentPosition
=
3_000
;
long
initialCurrentPosition
=
3_000
;
String
firstMediaId
=
"firstMediaId"
;
String
firstMediaId
=
"firstMediaId"
;
...
@@ -2185,9 +2185,9 @@ public class MediaControllerStateMaskingTest {
...
@@ -2185,9 +2185,9 @@ public class MediaControllerStateMaskingTest {
int
testFromIndex
=
0
;
int
testFromIndex
=
0
;
int
testToIndex
=
3
;
int
testToIndex
=
3
;
int
testMediaItemCount
=
0
;
int
testMediaItemCount
=
0
;
int
testCurrent
Window
Index
=
0
;
int
testCurrent
MediaItem
Index
=
0
;
int
testNext
Window
Index
=
C
.
INDEX_UNSET
;
int
testNext
MediaItem
Index
=
C
.
INDEX_UNSET
;
int
testPrevious
Window
Index
=
C
.
INDEX_UNSET
;
int
testPrevious
MediaItem
Index
=
C
.
INDEX_UNSET
;
int
testPlaybackState
=
STATE_ENDED
;
int
testPlaybackState
=
STATE_ENDED
;
long
testCurrentPosition
=
0
;
long
testCurrentPosition
=
0
;
...
@@ -2196,8 +2196,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -2196,8 +2196,8 @@ public class MediaControllerStateMaskingTest {
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createTimeline
(
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
setCurrentPosition
(
initialCurrentPosition
)
.
setCurrentPosition
(
initialCurrentPosition
)
.
setPlaybackState
(
initialPlaybackState
)
.
setPlaybackState
(
initialPlaybackState
)
.
build
();
.
build
();
...
@@ -2237,9 +2237,9 @@ public class MediaControllerStateMaskingTest {
...
@@ -2237,9 +2237,9 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicLong
newCurrentPositionRef
=
new
AtomicLong
();
AtomicLong
newCurrentPositionRef
=
new
AtomicLong
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
...
@@ -2247,9 +2247,9 @@ public class MediaControllerStateMaskingTest {
...
@@ -2247,9 +2247,9 @@ public class MediaControllerStateMaskingTest {
()
->
{
()
->
{
controller
.
removeMediaItems
(
controller
.
removeMediaItems
(
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
next
WindowIndexRef
.
set
(
controller
.
getNextWindow
Index
());
next
MediaItemIndexRef
.
set
(
controller
.
getNextMediaItem
Index
());
previous
WindowIndexRef
.
set
(
controller
.
getPreviousWindow
Index
());
previous
MediaItemIndexRef
.
set
(
controller
.
getPreviousMediaItem
Index
());
newCurrentPositionRef
.
set
(
controller
.
getCurrentPosition
());
newCurrentPositionRef
.
set
(
controller
.
getCurrentPosition
());
});
});
...
@@ -2265,16 +2265,16 @@ public class MediaControllerStateMaskingTest {
...
@@ -2265,16 +2265,16 @@ public class MediaControllerStateMaskingTest {
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_PLAYBACK_STATE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_PLAYBACK_STATE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
next
WindowIndexRef
.
get
()).
isEqualTo
(
testNextWindow
Index
);
assertThat
(
next
MediaItemIndexRef
.
get
()).
isEqualTo
(
testNextMediaItem
Index
);
assertThat
(
previous
WindowIndexRef
.
get
()).
isEqualTo
(
testPreviousWindow
Index
);
assertThat
(
previous
MediaItemIndexRef
.
get
()).
isEqualTo
(
testPreviousMediaItem
Index
);
assertThat
(
newCurrentPositionRef
.
get
()).
isEqualTo
(
testCurrentPosition
);
assertThat
(
newCurrentPositionRef
.
get
()).
isEqualTo
(
testCurrentPosition
);
}
}
@Test
@Test
public
void
removeMediaItems_removedTailIncludesCurrentItem_callsOnPlaybackStateChanged
()
public
void
removeMediaItems_removedTailIncludesCurrentItem_callsOnPlaybackStateChanged
()
throws
Exception
{
throws
Exception
{
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
int
initialPlaybackState
=
STATE_READY
;
int
initialPlaybackState
=
STATE_READY
;
int
testFromIndex
=
1
;
int
testFromIndex
=
1
;
int
testToIndex
=
3
;
int
testToIndex
=
3
;
...
@@ -2284,8 +2284,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -2284,8 +2284,8 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
setPlaybackState
(
initialPlaybackState
)
.
setPlaybackState
(
initialPlaybackState
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2327,10 +2327,10 @@ public class MediaControllerStateMaskingTest {
...
@@ -2327,10 +2327,10 @@ public class MediaControllerStateMaskingTest {
// Remove from middle to end of the timeline.
// Remove from middle to end of the timeline.
assertRemoveMediaItems
(
assertRemoveMediaItems
(
/* shuffleModeEnabled= */
false
,
/* shuffleModeEnabled= */
false
,
/* initial
Window
Index= */
1
,
/* initial
MediaItem
Index= */
1
,
/* testFromIndex= */
1
,
/* testFromIndex= */
1
,
/* testToIndex= */
4
,
/* testToIndex= */
4
,
/* testCurrent
Window
Index= */
0
,
/* testCurrent
MediaItem
Index= */
0
,
/* testCurrentPeriodIndex= */
0
,
/* testCurrentPeriodIndex= */
0
,
/* testTimeline= */
testTimeline
,
/* testTimeline= */
testTimeline
,
/* testMediaId= */
firstMediaId
);
/* testMediaId= */
firstMediaId
);
...
@@ -2338,10 +2338,10 @@ public class MediaControllerStateMaskingTest {
...
@@ -2338,10 +2338,10 @@ public class MediaControllerStateMaskingTest {
// Remove middle of the timeline.
// Remove middle of the timeline.
assertRemoveMediaItems
(
assertRemoveMediaItems
(
/* shuffleModeEnabled= */
false
,
/* shuffleModeEnabled= */
false
,
/* initial
Window
Index= */
2
,
/* initial
MediaItem
Index= */
2
,
/* testFromIndex= */
1
,
/* testFromIndex= */
1
,
/* testToIndex= */
3
,
/* testToIndex= */
3
,
/* testCurrent
Window
Index= */
1
,
/* testCurrent
MediaItem
Index= */
1
,
/* testCurrentPeriodIndex= */
1
,
/* testCurrentPeriodIndex= */
1
,
/* testTimeline= */
testTimeline
,
/* testTimeline= */
testTimeline
,
/* testMediaId= */
fourthMediaId
);
/* testMediaId= */
fourthMediaId
);
...
@@ -2359,10 +2359,10 @@ public class MediaControllerStateMaskingTest {
...
@@ -2359,10 +2359,10 @@ public class MediaControllerStateMaskingTest {
// timeline.
// timeline.
assertRemoveMediaItems
(
assertRemoveMediaItems
(
/* shuffleModeEnabled= */
true
,
/* shuffleModeEnabled= */
true
,
/* initial
Window
Index= */
0
,
/* initial
MediaItem
Index= */
0
,
/* testFromIndex= */
0
,
/* testFromIndex= */
0
,
/* testToIndex= */
1
,
/* testToIndex= */
1
,
/* testCurrent
Window
Index= */
0
,
/* testCurrent
MediaItem
Index= */
0
,
/* testCurrentPeriodIndex= */
0
,
/* testCurrentPeriodIndex= */
0
,
/* testTimeline= */
new
PlaylistTimeline
(
/* testTimeline= */
new
PlaylistTimeline
(
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
,
fourthMediaId
),
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
,
fourthMediaId
),
...
@@ -2373,10 +2373,10 @@ public class MediaControllerStateMaskingTest {
...
@@ -2373,10 +2373,10 @@ public class MediaControllerStateMaskingTest {
// should subtract size of removed items.
// should subtract size of removed items.
assertRemoveMediaItems
(
assertRemoveMediaItems
(
/* shuffleModeEnabled= */
true
,
/* shuffleModeEnabled= */
true
,
/* initial
Window
Index= */
0
,
/* initial
MediaItem
Index= */
0
,
/* testFromIndex= */
0
,
/* testFromIndex= */
0
,
/* testToIndex= */
1
,
/* testToIndex= */
1
,
/* testCurrent
Window
Index= */
2
,
/* testCurrent
MediaItem
Index= */
2
,
/* testCurrentPeriodIndex= */
2
,
/* testCurrentPeriodIndex= */
2
,
/* testTimeline= */
new
PlaylistTimeline
(
/* testTimeline= */
new
PlaylistTimeline
(
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
,
fourthMediaId
),
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
,
fourthMediaId
),
...
@@ -2387,10 +2387,10 @@ public class MediaControllerStateMaskingTest {
...
@@ -2387,10 +2387,10 @@ public class MediaControllerStateMaskingTest {
// index should not subtract size of removed items.
// index should not subtract size of removed items.
assertRemoveMediaItems
(
assertRemoveMediaItems
(
/* shuffleModeEnabled= */
true
,
/* shuffleModeEnabled= */
true
,
/* initial
Window
Index= */
3
,
/* initial
MediaItem
Index= */
3
,
/* testFromIndex= */
3
,
/* testFromIndex= */
3
,
/* testToIndex= */
4
,
/* testToIndex= */
4
,
/* testCurrent
Window
Index= */
2
,
/* testCurrent
MediaItem
Index= */
2
,
/* testCurrentPeriodIndex= */
2
,
/* testCurrentPeriodIndex= */
2
,
/* testTimeline= */
new
PlaylistTimeline
(
/* testTimeline= */
new
PlaylistTimeline
(
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
,
fourthMediaId
),
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
,
fourthMediaId
),
...
@@ -2400,10 +2400,10 @@ public class MediaControllerStateMaskingTest {
...
@@ -2400,10 +2400,10 @@ public class MediaControllerStateMaskingTest {
private
void
assertRemoveMediaItems
(
private
void
assertRemoveMediaItems
(
boolean
shuffleModeEnabled
,
boolean
shuffleModeEnabled
,
int
initial
Window
Index
,
int
initial
MediaItem
Index
,
int
testFromIndex
,
int
testFromIndex
,
int
testToIndex
,
int
testToIndex
,
int
testCurrent
Window
Index
,
int
testCurrent
MediaItem
Index
,
int
testCurrentPeriodIndex
,
int
testCurrentPeriodIndex
,
Timeline
testTimeline
,
Timeline
testTimeline
,
String
testMediaId
)
String
testMediaId
)
...
@@ -2411,15 +2411,15 @@ public class MediaControllerStateMaskingTest {
...
@@ -2411,15 +2411,15 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
testTimeline
)
.
setTimeline
(
testTimeline
)
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
setShuffleModeEnabled
(
shuffleModeEnabled
)
.
setShuffleModeEnabled
(
shuffleModeEnabled
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicReference
<
MediaItem
>
currentMediaItemRef
=
new
AtomicReference
<>();
AtomicReference
<
MediaItem
>
currentMediaItemRef
=
new
AtomicReference
<>();
threadTestRule
threadTestRule
...
@@ -2428,11 +2428,11 @@ public class MediaControllerStateMaskingTest {
...
@@ -2428,11 +2428,11 @@ public class MediaControllerStateMaskingTest {
()
->
{
()
->
{
controller
.
removeMediaItems
(
controller
.
removeMediaItems
(
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
/* fromIndex= */
testFromIndex
,
/* toIndex= */
testToIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentMediaItemRef
.
set
(
controller
.
getCurrentMediaItem
());
currentMediaItemRef
.
set
(
controller
.
getCurrentMediaItem
());
});
});
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
currentMediaItemRef
.
get
().
mediaId
).
isEqualTo
(
testMediaId
);
assertThat
(
currentMediaItemRef
.
get
().
mediaId
).
isEqualTo
(
testMediaId
);
}
}
...
@@ -2440,7 +2440,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2440,7 +2440,7 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
moveMediaItems_moveAllMediaItems_ignored
()
throws
Exception
{
public
void
moveMediaItems_moveAllMediaItems_ignored
()
throws
Exception
{
int
initialMediaItemCount
=
2
;
int
initialMediaItemCount
=
2
;
int
initial
Window
Index
=
0
;
int
initial
MediaItem
Index
=
0
;
int
testFromIndex
=
0
;
int
testFromIndex
=
0
;
int
testToIndex
=
2
;
int
testToIndex
=
2
;
int
testNewIndex
=
0
;
int
testNewIndex
=
0
;
...
@@ -2448,8 +2448,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -2448,8 +2448,8 @@ public class MediaControllerStateMaskingTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
initialMediaItemCount
))
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
initialMediaItemCount
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2464,13 +2464,13 @@ public class MediaControllerStateMaskingTest {
...
@@ -2464,13 +2464,13 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
});
});
assertThat
(
latch
.
await
(
NO_RESPONSE_TIMEOUT_MS
,
MILLISECONDS
)).
isFalse
();
assertThat
(
latch
.
await
(
NO_RESPONSE_TIMEOUT_MS
,
MILLISECONDS
)).
isFalse
();
...
@@ -2482,24 +2482,24 @@ public class MediaControllerStateMaskingTest {
...
@@ -2482,24 +2482,24 @@ public class MediaControllerStateMaskingTest {
String
firstMediaId
=
"firstMediaId"
;
String
firstMediaId
=
"firstMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
secondMediaId
=
"secondMediaId"
;
String
thirdMediaId
=
"thirdMediaId"
;
String
thirdMediaId
=
"thirdMediaId"
;
int
initial
Window
Index
=
0
;
int
initial
MediaItem
Index
=
0
;
int
testFromIndex
=
1
;
int
testFromIndex
=
1
;
int
testToIndex
=
2
;
int
testToIndex
=
2
;
int
testNewIndex
=
0
;
int
testNewIndex
=
0
;
String
testCurrentMediaId
=
firstMediaId
;
String
testCurrentMediaId
=
firstMediaId
;
String
testPrevMediaId
=
secondMediaId
;
String
testPrevMediaId
=
secondMediaId
;
String
testNextMediaId
=
thirdMediaId
;
String
testNextMediaId
=
thirdMediaId
;
int
testCurrent
Window
Index
=
1
;
int
testCurrent
MediaItem
Index
=
1
;
int
testPrev
Window
Index
=
0
;
int
testPrev
MediaItem
Index
=
0
;
int
testNext
Window
Index
=
2
;
int
testNext
MediaItem
Index
=
2
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
MediaTestUtils
.
createTimeline
(
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
createMediaItems
(
firstMediaId
,
secondMediaId
,
thirdMediaId
)))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2523,37 +2523,43 @@ public class MediaControllerStateMaskingTest {
...
@@ -2523,37 +2523,43 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
});
});
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
initialMediaItemCount
,
initialMediaItemCount
,
testCurrent
Window
Index
,
testCurrent
MediaItem
Index
,
/* testFirstPeriodIndex= */
testCurrent
Window
Index
,
/* testFirstPeriodIndex= */
testCurrent
MediaItem
Index
,
/* testLastPeriodIndex= */
testCurrent
Window
Index
);
/* testLastPeriodIndex= */
testCurrent
MediaItem
Index
);
assertThat
(
assertThat
(
newTimelineRef
.
get
().
getWindow
(
testCurrentWindowIndex
,
new
Window
()).
mediaItem
.
mediaId
)
newTimelineRef
.
get
()
.
getWindow
(
testCurrentMediaItemIndex
,
new
Window
())
.
mediaItem
.
mediaId
)
.
isEqualTo
(
testCurrentMediaId
);
.
isEqualTo
(
testCurrentMediaId
);
assertThat
(
newTimelineRef
.
get
().
getWindow
(
testPrevWindowIndex
,
new
Window
()).
mediaItem
.
mediaId
)
assertThat
(
newTimelineRef
.
get
().
getWindow
(
testPrevMediaItemIndex
,
new
Window
()).
mediaItem
.
mediaId
)
.
isEqualTo
(
testPrevMediaId
);
.
isEqualTo
(
testPrevMediaId
);
assertThat
(
newTimelineRef
.
get
().
getWindow
(
testNextWindowIndex
,
new
Window
()).
mediaItem
.
mediaId
)
assertThat
(
newTimelineRef
.
get
().
getWindow
(
testNextMediaItemIndex
,
new
Window
()).
mediaItem
.
mediaId
)
.
isEqualTo
(
testNextMediaId
);
.
isEqualTo
(
testNextMediaId
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
}
}
@Test
@Test
public
void
moveMediaItems_moveCurrentItemBackOneWindow_whenPreviousWindowHasMultiplePeriods
()
public
void
moveMediaItems_moveCurrentItemBackOneWindow_whenPreviousWindowHasMultiplePeriods
()
throws
Exception
{
throws
Exception
{
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
int
initialPeriodIndex
=
3
;
int
initialPeriodIndex
=
3
;
int
prevWindowPeriodSize
=
2
;
int
prevWindowPeriodSize
=
2
;
...
@@ -2562,7 +2568,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2562,7 +2568,7 @@ public class MediaControllerStateMaskingTest {
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
prevWindowPeriodSize
,
3
,
2
}))
new
int
[]
{
prevWindowPeriodSize
,
3
,
2
}))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2573,8 +2579,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -2573,8 +2579,8 @@ public class MediaControllerStateMaskingTest {
/* initialMediaItemCount= */
3
,
/* initialMediaItemCount= */
3
,
/* testFromIndex= */
1
,
/* testFromIndex= */
1
,
/* testToIndex= */
2
,
/* testToIndex= */
2
,
/* testNewIndex= */
initial
Window
Index
-
1
,
/* testNewIndex= */
initial
MediaItem
Index
-
1
,
/* testCurrent
WindowIndex= */
initialWindow
Index
-
1
,
/* testCurrent
MediaItemIndex= */
initialMediaItem
Index
-
1
,
/* testCurrentWindowFirstPeriodIndex= */
initialWindowFirstPeriodIndex
/* testCurrentWindowFirstPeriodIndex= */
initialWindowFirstPeriodIndex
-
prevWindowPeriodSize
,
-
prevWindowPeriodSize
,
/* testCurrentWindowLastPeriodIndex= */
initialWindowLastPeriodIndex
-
prevWindowPeriodSize
,
/* testCurrentWindowLastPeriodIndex= */
initialWindowLastPeriodIndex
-
prevWindowPeriodSize
,
...
@@ -2584,7 +2590,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2584,7 +2590,7 @@ public class MediaControllerStateMaskingTest {
@Test
@Test
public
void
moveMediaItems_moveCurrentItemForwardOneWindow_whenNextWindowHasMultiplePeriods
()
public
void
moveMediaItems_moveCurrentItemForwardOneWindow_whenNextWindowHasMultiplePeriods
()
throws
Exception
{
throws
Exception
{
int
initial
Window
Index
=
1
;
int
initial
MediaItem
Index
=
1
;
int
initialPeriodIndex
=
3
;
int
initialPeriodIndex
=
3
;
int
nextWindowPeriodSize
=
2
;
int
nextWindowPeriodSize
=
2
;
...
@@ -2593,7 +2599,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2593,7 +2599,7 @@ public class MediaControllerStateMaskingTest {
.
setTimeline
(
.
setTimeline
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
MediaTestUtils
.
createTimelineWithPeriodSizes
(
new
int
[]
{
2
,
3
,
nextWindowPeriodSize
}))
new
int
[]
{
2
,
3
,
nextWindowPeriodSize
}))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
setCurrentPeriodIndex
(
initialPeriodIndex
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
...
@@ -2604,8 +2610,8 @@ public class MediaControllerStateMaskingTest {
...
@@ -2604,8 +2610,8 @@ public class MediaControllerStateMaskingTest {
/* initialMediaItemCount= */
3
,
/* initialMediaItemCount= */
3
,
/* testFromIndex= */
1
,
/* testFromIndex= */
1
,
/* testToIndex= */
2
,
/* testToIndex= */
2
,
/* testNewIndex= */
initial
Window
Index
+
1
,
/* testNewIndex= */
initial
MediaItem
Index
+
1
,
/* testCurrent
WindowIndex= */
initialWindow
Index
+
1
,
/* testCurrent
MediaItemIndex= */
initialMediaItem
Index
+
1
,
/* testCurrentWindowFirstPeriodIndex= */
initialWindowFirstPeriodIndex
/* testCurrentWindowFirstPeriodIndex= */
initialWindowFirstPeriodIndex
+
nextWindowPeriodSize
,
+
nextWindowPeriodSize
,
/* testCurrentWindowLastPeriodIndex= */
initialWindowLastPeriodIndex
+
nextWindowPeriodSize
,
/* testCurrentWindowLastPeriodIndex= */
initialWindowLastPeriodIndex
+
nextWindowPeriodSize
,
...
@@ -2617,7 +2623,7 @@ public class MediaControllerStateMaskingTest {
...
@@ -2617,7 +2623,7 @@ public class MediaControllerStateMaskingTest {
int
testFromIndex
,
int
testFromIndex
,
int
testToIndex
,
int
testToIndex
,
int
testNewIndex
,
int
testNewIndex
,
int
testCurrent
Window
Index
,
int
testCurrent
MediaItem
Index
,
int
testCurrentWindowFirstPeriodIndex
,
int
testCurrentWindowFirstPeriodIndex
,
int
testCurrentWindowLastPeriodIndex
,
int
testCurrentWindowLastPeriodIndex
,
int
testCurrentPeriodIndex
)
int
testCurrentPeriodIndex
)
...
@@ -2642,14 +2648,14 @@ public class MediaControllerStateMaskingTest {
...
@@ -2642,14 +2648,14 @@ public class MediaControllerStateMaskingTest {
};
};
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
addListener
(
listener
));
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
AtomicInteger
currentPeriodIndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
currentPeriodIndexRef
.
set
(
controller
.
getCurrentPeriodIndex
());
});
});
...
@@ -2657,11 +2663,11 @@ public class MediaControllerStateMaskingTest {
...
@@ -2657,11 +2663,11 @@ public class MediaControllerStateMaskingTest {
assertTimeline
(
assertTimeline
(
newTimelineRef
.
get
(),
newTimelineRef
.
get
(),
initialMediaItemCount
,
initialMediaItemCount
,
testCurrent
Window
Index
,
testCurrent
MediaItem
Index
,
/* testFirstPeriodIndex= */
testCurrentWindowFirstPeriodIndex
,
/* testFirstPeriodIndex= */
testCurrentWindowFirstPeriodIndex
,
/* testLastPeriodIndex= */
testCurrentWindowLastPeriodIndex
);
/* testLastPeriodIndex= */
testCurrentWindowLastPeriodIndex
);
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
onEventsRef
.
get
().
contains
(
Player
.
EVENT_TIMELINE_CHANGED
)).
isTrue
();
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
assertThat
(
currentPeriodIndexRef
.
get
()).
isEqualTo
(
testCurrentPeriodIndex
);
}
}
...
@@ -2669,90 +2675,90 @@ public class MediaControllerStateMaskingTest {
...
@@ -2669,90 +2675,90 @@ public class MediaControllerStateMaskingTest {
public
void
moveMediaItems_moveCurrentItemBackOneWindow
()
throws
Exception
{
public
void
moveMediaItems_moveCurrentItemBackOneWindow
()
throws
Exception
{
assertMoveMediaItems
(
assertMoveMediaItems
(
/* initialMediaItemCount= */
5
,
/* initialMediaItemCount= */
5
,
/* initial
Window
Index= */
1
,
/* initial
MediaItem
Index= */
1
,
/* testFromIndex= */
1
,
/* testFromIndex= */
1
,
/* testToIndex= */
2
,
/* testToIndex= */
2
,
/* testNewIndex= */
0
,
/* testNewIndex= */
0
,
/* testCurrent
Window
Index= */
0
,
/* testCurrent
MediaItem
Index= */
0
,
/* testNext
Window
Index= */
1
,
/* testNext
MediaItem
Index= */
1
,
/* testPrevious
Window
Index= */
C
.
INDEX_UNSET
);
/* testPrevious
MediaItem
Index= */
C
.
INDEX_UNSET
);
}
}
@Test
@Test
public
void
moveMediaItems_moveCurrentItemForwardOneWindow
()
throws
Exception
{
public
void
moveMediaItems_moveCurrentItemForwardOneWindow
()
throws
Exception
{
assertMoveMediaItems
(
assertMoveMediaItems
(
/* initialMediaItemCount= */
5
,
/* initialMediaItemCount= */
5
,
/* initial
Window
Index= */
1
,
/* initial
MediaItem
Index= */
1
,
/* testFromIndex= */
1
,
/* testFromIndex= */
1
,
/* testToIndex= */
2
,
/* testToIndex= */
2
,
/* testNewIndex= */
2
,
/* testNewIndex= */
2
,
/* testCurrent
Window
Index= */
2
,
/* testCurrent
MediaItem
Index= */
2
,
/* testNext
Window
Index= */
3
,
/* testNext
MediaItem
Index= */
3
,
/* testPrevious
Window
Index= */
1
);
/* testPrevious
MediaItem
Index= */
1
);
}
}
@Test
@Test
public
void
moveMediaItems_moveNonCurrentItem_fromAfterCurrentItemToBefore
()
throws
Exception
{
public
void
moveMediaItems_moveNonCurrentItem_fromAfterCurrentItemToBefore
()
throws
Exception
{
assertMoveMediaItems
(
assertMoveMediaItems
(
/* initialMediaItemCount= */
5
,
/* initialMediaItemCount= */
5
,
/* initial
Window
Index= */
1
,
/* initial
MediaItem
Index= */
1
,
/* testFromIndex= */
2
,
/* testFromIndex= */
2
,
/* testToIndex= */
4
,
/* testToIndex= */
4
,
/* testNewIndex= */
1
,
/* testNewIndex= */
1
,
/* testCurrent
Window
Index= */
3
,
/* testCurrent
MediaItem
Index= */
3
,
/* testNext
Window
Index= */
4
,
/* testNext
MediaItem
Index= */
4
,
/* testPrevious
Window
Index= */
2
);
/* testPrevious
MediaItem
Index= */
2
);
}
}
@Test
@Test
public
void
moveMediaItems_moveNonCurrentItem_fromBeforeCurrentItemToAfter
()
throws
Exception
{
public
void
moveMediaItems_moveNonCurrentItem_fromBeforeCurrentItemToAfter
()
throws
Exception
{
assertMoveMediaItems
(
assertMoveMediaItems
(
/* initialMediaItemCount= */
5
,
/* initialMediaItemCount= */
5
,
/* initial
Window
Index= */
1
,
/* initial
MediaItem
Index= */
1
,
/* testFromIndex= */
0
,
/* testFromIndex= */
0
,
/* testToIndex= */
1
,
/* testToIndex= */
1
,
/* testNewIndex= */
2
,
/* testNewIndex= */
2
,
/* testCurrent
Window
Index= */
0
,
/* testCurrent
MediaItem
Index= */
0
,
/* testNext
Window
Index= */
1
,
/* testNext
MediaItem
Index= */
1
,
/* testPrevious
Window
Index= */
C
.
INDEX_UNSET
);
/* testPrevious
MediaItem
Index= */
C
.
INDEX_UNSET
);
}
}
private
void
assertMoveMediaItems
(
private
void
assertMoveMediaItems
(
int
initialMediaItemCount
,
int
initialMediaItemCount
,
int
initial
Window
Index
,
int
initial
MediaItem
Index
,
int
testFromIndex
,
int
testFromIndex
,
int
testToIndex
,
int
testToIndex
,
int
testNewIndex
,
int
testNewIndex
,
int
testCurrent
Window
Index
,
int
testCurrent
MediaItem
Index
,
int
testNext
Window
Index
,
int
testNext
MediaItem
Index
,
int
testPrevious
Window
Index
)
int
testPrevious
MediaItem
Index
)
throws
Exception
{
throws
Exception
{
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
initialMediaItemCount
))
.
setTimeline
(
MediaTestUtils
.
createTimeline
(
initialMediaItemCount
))
.
setCurrent
WindowIndex
(
initialWindow
Index
)
.
setCurrent
MediaItemIndex
(
initialMediaItem
Index
)
.
setCurrentPeriodIndex
(
initial
Window
Index
)
.
setCurrentPeriodIndex
(
initial
MediaItem
Index
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
AtomicInteger
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
next
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
previous
MediaItem
IndexRef
=
new
AtomicInteger
();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
.
postAndSync
(
.
postAndSync
(
()
->
{
()
->
{
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
controller
.
moveMediaItems
(
testFromIndex
,
testToIndex
,
testNewIndex
);
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
next
WindowIndexRef
.
set
(
controller
.
getNextWindow
Index
());
next
MediaItemIndexRef
.
set
(
controller
.
getNextMediaItem
Index
());
previous
WindowIndexRef
.
set
(
controller
.
getPreviousWindow
Index
());
previous
MediaItemIndexRef
.
set
(
controller
.
getPreviousMediaItem
Index
());
});
});
assertThat
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
testCurrentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
testCurrentMediaItem
Index
);
assertThat
(
next
WindowIndexRef
.
get
()).
isEqualTo
(
testNextWindow
Index
);
assertThat
(
next
MediaItemIndexRef
.
get
()).
isEqualTo
(
testNextMediaItem
Index
);
assertThat
(
previous
WindowIndexRef
.
get
()).
isEqualTo
(
testPreviousWindow
Index
);
assertThat
(
previous
MediaItemIndexRef
.
get
()).
isEqualTo
(
testPreviousMediaItem
Index
);
}
}
@Test
@Test
...
@@ -2845,17 +2851,17 @@ public class MediaControllerStateMaskingTest {
...
@@ -2845,17 +2851,17 @@ public class MediaControllerStateMaskingTest {
private
void
assertTimeline
(
private
void
assertTimeline
(
Timeline
timeline
,
Timeline
timeline
,
int
testMediaItemCount
,
int
testMediaItemCount
,
int
test
Window
Index
,
int
test
MediaItem
Index
,
int
testFirstPeriodIndex
,
int
testFirstPeriodIndex
,
int
testLastPeriodIndex
)
{
int
testLastPeriodIndex
)
{
assertThat
(
timeline
.
getWindowCount
()).
isEqualTo
(
testMediaItemCount
);
assertThat
(
timeline
.
getWindowCount
()).
isEqualTo
(
testMediaItemCount
);
if
(
testMediaItemCount
>
0
)
{
if
(
testMediaItemCount
>
0
)
{
Window
window
=
timeline
.
getWindow
(
test
Window
Index
,
new
Window
());
Window
window
=
timeline
.
getWindow
(
test
MediaItem
Index
,
new
Window
());
assertThat
(
window
.
firstPeriodIndex
).
isEqualTo
(
testFirstPeriodIndex
);
assertThat
(
window
.
firstPeriodIndex
).
isEqualTo
(
testFirstPeriodIndex
);
assertThat
(
window
.
lastPeriodIndex
).
isEqualTo
(
testLastPeriodIndex
);
assertThat
(
window
.
lastPeriodIndex
).
isEqualTo
(
testLastPeriodIndex
);
Period
period
=
timeline
.
getPeriod
(
testFirstPeriodIndex
,
new
Period
());
Period
period
=
timeline
.
getPeriod
(
testFirstPeriodIndex
,
new
Period
());
assertThat
(
period
.
windowIndex
).
isEqualTo
(
test
Window
Index
);
assertThat
(
period
.
windowIndex
).
isEqualTo
(
test
MediaItem
Index
);
assertThat
(
period
.
windowIndex
).
isEqualTo
(
test
Window
Index
);
assertThat
(
period
.
windowIndex
).
isEqualTo
(
test
MediaItem
Index
);
}
}
}
}
}
}
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerTest.java
View file @
f37e9800
...
@@ -246,9 +246,9 @@ public class MediaControllerTest {
...
@@ -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
current
Window
Index
=
3
;
int
current
MediaItem
Index
=
3
;
MediaItem
currentMediaItem
=
MediaItem
currentMediaItem
=
timeline
.
getWindow
(
current
Window
Index
,
new
Timeline
.
Window
()).
mediaItem
;
timeline
.
getWindow
(
current
MediaItem
Index
,
new
Timeline
.
Window
()).
mediaItem
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
...
@@ -277,7 +277,7 @@ public class MediaControllerTest {
...
@@ -277,7 +277,7 @@ public class MediaControllerTest {
.
setMaxSeekToPreviousPositionMs
(
maxSeekToPreviousPositionMs
)
.
setMaxSeekToPreviousPositionMs
(
maxSeekToPreviousPositionMs
)
.
setTrackSelectionParameters
(
trackSelectionParameters
)
.
setTrackSelectionParameters
(
trackSelectionParameters
)
.
setTimeline
(
timeline
)
.
setTimeline
(
timeline
)
.
setCurrent
WindowIndex
(
currentWindow
Index
)
.
setCurrent
MediaItemIndex
(
currentMediaItem
Index
)
.
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 {
...
@@ -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
current
Window
IndexRef
=
new
AtomicInteger
();
AtomicInteger
current
MediaItem
IndexRef
=
new
AtomicInteger
();
AtomicReference
<
MediaItem
>
currentMediaItemRef
=
new
AtomicReference
<>();
AtomicReference
<
MediaItem
>
currentMediaItemRef
=
new
AtomicReference
<>();
threadTestRule
threadTestRule
.
getHandler
()
.
getHandler
()
...
@@ -341,7 +341,7 @@ public class MediaControllerTest {
...
@@ -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
());
current
WindowIndexRef
.
set
(
controller
.
getCurrentWindow
Index
());
current
MediaItemIndexRef
.
set
(
controller
.
getCurrentMediaItem
Index
());
currentMediaItemRef
.
set
(
controller
.
getCurrentMediaItem
());
currentMediaItemRef
.
set
(
controller
.
getCurrentMediaItem
());
});
});
...
@@ -370,7 +370,7 @@ public class MediaControllerTest {
...
@@ -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
(
current
WindowIndexRef
.
get
()).
isEqualTo
(
currentWindow
Index
);
assertThat
(
current
MediaItemIndexRef
.
get
()).
isEqualTo
(
currentMediaItem
Index
);
assertThat
(
currentMediaItemRef
.
get
()).
isEqualTo
(
currentMediaItem
);
assertThat
(
currentMediaItemRef
.
get
()).
isEqualTo
(
currentMediaItem
);
}
}
...
@@ -509,19 +509,19 @@ public class MediaControllerTest {
...
@@ -509,19 +509,19 @@ public class MediaControllerTest {
}
}
@Test
@Test
public
void
getCurrent
Window
Index
()
throws
Exception
{
public
void
getCurrent
MediaItem
Index
()
throws
Exception
{
int
test
Window
Index
=
1
;
int
test
MediaItem
Index
=
1
;
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setCurrent
WindowIndex
(
testWindow
Index
)
.
setCurrent
MediaItemIndex
(
testMediaItem
Index
)
.
build
();
.
build
();
remoteSession
.
setPlayer
(
playerConfig
);
remoteSession
.
setPlayer
(
playerConfig
);
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
MediaController
controller
=
controllerTestRule
.
createController
(
remoteSession
.
getToken
());
int
current
Window
Index
=
int
current
MediaItem
Index
=
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getCurrent
Window
Index
);
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getCurrent
MediaItem
Index
);
assertThat
(
current
WindowIndex
).
isEqualTo
(
testWindow
Index
);
assertThat
(
current
MediaItemIndex
).
isEqualTo
(
testMediaItem
Index
);
}
}
@Test
@Test
...
@@ -541,83 +541,83 @@ public class MediaControllerTest {
...
@@ -541,83 +541,83 @@ public class MediaControllerTest {
}
}
@Test
@Test
public
void
getPrevious
Window
Index
()
throws
Exception
{
public
void
getPrevious
MediaItem
Index
()
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
)
.
setCurrent
Window
Index
(
1
)
.
setCurrent
MediaItem
Index
(
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
previous
Window
Index
=
int
previous
MediaItem
Index
=
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
Window
Index
);
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
MediaItem
Index
);
assertThat
(
previous
Window
Index
).
isEqualTo
(
0
);
assertThat
(
previous
MediaItem
Index
).
isEqualTo
(
0
);
}
}
@Test
@Test
public
void
getPrevious
Window
Index_withRepeatModeOne
()
throws
Exception
{
public
void
getPrevious
MediaItem
Index_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
)
.
setCurrent
Window
Index
(
1
)
.
setCurrent
MediaItem
Index
(
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
previous
Window
Index
=
int
previous
MediaItem
Index
=
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
Window
Index
);
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
MediaItem
Index
);
assertThat
(
previous
Window
Index
).
isEqualTo
(
0
);
assertThat
(
previous
MediaItem
Index
).
isEqualTo
(
0
);
}
}
@Test
@Test
public
void
getPrevious
WindowIndex_atTheFirstWindow
()
throws
Exception
{
public
void
getPrevious
MediaItemIndex_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
)
.
setCurrent
Window
Index
(
0
)
.
setCurrent
MediaItem
Index
(
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
previous
Window
Index
=
int
previous
MediaItem
Index
=
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
Window
Index
);
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
MediaItem
Index
);
assertThat
(
previous
Window
Index
).
isEqualTo
(
C
.
INDEX_UNSET
);
assertThat
(
previous
MediaItem
Index
).
isEqualTo
(
C
.
INDEX_UNSET
);
}
}
@Test
@Test
public
void
getPrevious
WindowIndex_atTheFirstWindow
WithRepeatModeAll
()
throws
Exception
{
public
void
getPrevious
MediaItemIndex_atTheFirstMediaItem
WithRepeatModeAll
()
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
)
.
setCurrent
Window
Index
(
0
)
.
setCurrent
MediaItem
Index
(
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
previous
Window
Index
=
int
previous
MediaItem
Index
=
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
Window
Index
);
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
MediaItem
Index
);
assertThat
(
previous
Window
Index
).
isEqualTo
(
2
);
assertThat
(
previous
MediaItem
Index
).
isEqualTo
(
2
);
}
}
@Test
@Test
public
void
getPrevious
Window
Index_withShuffleModeEnabled
()
throws
Exception
{
public
void
getPrevious
MediaItem
Index_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 {
...
@@ -625,93 +625,97 @@ public class MediaControllerTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
timeline
)
.
setTimeline
(
timeline
)
.
setCurrent
Window
Index
(
2
)
.
setCurrent
MediaItem
Index
(
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
previous
Window
Index
=
int
previous
MediaItem
Index
=
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
Window
Index
);
threadTestRule
.
getHandler
().
postAndSync
(
controller:
:
getPrevious
MediaItem
Index
);
assertThat
(
previous
Window
Index
).
isEqualTo
(
0
);
assertThat
(
previous
MediaItem
Index
).
isEqualTo
(
0
);
}
}
@Test
@Test
public
void
getNext
Window
Index
()
throws
Exception
{
public
void
getNext
MediaItem
Index
()
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
)
.
setCurrent
Window
Index
(
1
)
.
setCurrent
MediaItem
Index
(
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
(
next
Window
Index
).
isEqualTo
(
2
);
assertThat
(
next
MediaItem
Index
).
isEqualTo
(
2
);
}
}
@Test
@Test
public
void
getNext
Window
Index_withRepeatModeOne
()
throws
Exception
{
public
void
getNext
MediaItem
Index_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
)
.
setCurrent
Window
Index
(
1
)
.
setCurrent
MediaItem
Index
(
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
(
next
Window
Index
).
isEqualTo
(
2
);
assertThat
(
next
MediaItem
Index
).
isEqualTo
(
2
);
}
}
@Test
@Test
public
void
getNext
WindowIndex_atTheLastWindow
()
throws
Exception
{
public
void
getNext
MediaItemIndex_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
)
.
setCurrent
Window
Index
(
2
)
.
setCurrent
MediaItem
Index
(
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
(
next
Window
Index
).
isEqualTo
(
C
.
INDEX_UNSET
);
assertThat
(
next
MediaItem
Index
).
isEqualTo
(
C
.
INDEX_UNSET
);
}
}
@Test
@Test
public
void
getNext
WindowIndex_atTheLastWindow
WithRepeatModeAll
()
throws
Exception
{
public
void
getNext
MediaItemIndex_atTheLastMediaItem
WithRepeatModeAll
()
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
)
.
setCurrent
Window
Index
(
2
)
.
setCurrent
MediaItem
Index
(
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
(
next
Window
Index
).
isEqualTo
(
0
);
assertThat
(
next
MediaItem
Index
).
isEqualTo
(
0
);
}
}
@Test
@Test
public
void
getNext
Window
Index_withShuffleModeEnabled
()
throws
Exception
{
public
void
getNext
MediaItem
Index_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 {
...
@@ -719,16 +723,17 @@ public class MediaControllerTest {
Bundle
playerConfig
=
Bundle
playerConfig
=
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
new
RemoteMediaSession
.
MockPlayerConfigBuilder
()
.
setTimeline
(
timeline
)
.
setTimeline
(
timeline
)
.
setCurrent
Window
Index
(
2
)
.
setCurrent
MediaItem
Index
(
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
(
next
Window
Index
).
isEqualTo
(
1
);
assertThat
(
next
MediaItem
Index
).
isEqualTo
(
1
);
}
}
@Test
@Test
...
@@ -748,7 +753,7 @@ public class MediaControllerTest {
...
@@ -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
window
Index
=
1
;
int
mediaItem
Index
=
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 {
...
@@ -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
(
window
Index
));
threadTestRule
.
getHandler
().
postAndSync
(()
->
controller
.
getMediaItemAt
(
mediaItem
Index
));
assertThat
(
mediaItem
)
assertThat
(
mediaItem
)
.
isEqualTo
(
timeline
.
getWindow
(
window
Index
,
new
Timeline
.
Window
()).
mediaItem
);
.
isEqualTo
(
timeline
.
getWindow
(
mediaItem
Index
,
new
Timeline
.
Window
()).
mediaItem
);
}
}
private
RemoteMediaSession
createRemoteMediaSession
(
String
id
,
Bundle
tokenExtras
)
private
RemoteMediaSession
createRemoteMediaSession
(
String
id
,
Bundle
tokenExtras
)
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionCallbackWithMediaControllerCompatTest.java
View file @
f37e9800
...
@@ -435,8 +435,8 @@ public class MediaSessionCallbackWithMediaControllerCompatTest {
...
@@ -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
.
seekToDefaultPositionWith
Window
IndexCalled
).
isTrue
();
assertThat
(
player
.
seekToDefaultPositionWith
MediaItem
IndexCalled
).
isTrue
();
assertThat
(
player
.
seek
Window
Index
).
isEqualTo
(
targetIndex
);
assertThat
(
player
.
seek
MediaItem
Index
).
isEqualTo
(
targetIndex
);
}
}
@Test
@Test
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionCompatCallbackWithMediaControllerTest.java
View file @
f37e9800
...
@@ -172,8 +172,8 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
...
@@ -172,8 +172,8 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
}
}
@Test
@Test
public
void
seekToDefaultPosition_with
Window
Index
()
throws
Exception
{
public
void
seekToDefaultPosition_with
MediaItem
Index
()
throws
Exception
{
int
test
Window
Index
=
1
;
int
test
MediaItem
Index
=
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 {
...
@@ -182,16 +182,17 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
sessionCallback
.
reset
(
2
);
sessionCallback
.
reset
(
2
);
controller
.
seekToDefaultPosition
(
test
Window
Index
);
controller
.
seekToDefaultPosition
(
test
MediaItem
Index
);
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_withFake
Window
Index_seeksWithPosition
()
throws
Exception
{
public
void
seekToDefaultPosition_withFake
MediaItem
Index_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 {
...
@@ -226,8 +227,8 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
}
}
@Test
@Test
public
void
seekTo_with
Window
Index
()
throws
Exception
{
public
void
seekTo_with
MediaItem
Index
()
throws
Exception
{
int
test
Window
Index
=
1
;
int
test
MediaItem
Index
=
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 {
...
@@ -238,10 +239,11 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
sessionCallback
.
reset
(
2
);
sessionCallback
.
reset
(
2
);
controller
.
seekTo
(
test
Window
Index
,
testPositionMs
);
controller
.
seekTo
(
test
MediaItem
Index
,
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 {
...
@@ -350,21 +352,21 @@ public class MediaSessionCompatCallbackWithMediaControllerTest {
}
}
@Test
@Test
public
void
seekToPrevious
Window
()
throws
Exception
{
public
void
seekToPrevious
MediaItem
()
throws
Exception
{
RemoteMediaController
controller
=
createControllerAndWaitConnection
();
RemoteMediaController
controller
=
createControllerAndWaitConnection
();
sessionCallback
.
reset
(
1
);
sessionCallback
.
reset
(
1
);
controller
.
seekToPrevious
Window
();
controller
.
seekToPrevious
MediaItem
();
assertThat
(
sessionCallback
.
await
(
TIMEOUT_MS
)).
isTrue
();
assertThat
(
sessionCallback
.
await
(
TIMEOUT_MS
)).
isTrue
();
assertThat
(
sessionCallback
.
onSkipToPreviousCalled
).
isTrue
();
assertThat
(
sessionCallback
.
onSkipToPreviousCalled
).
isTrue
();
}
}
@Test
@Test
public
void
seekToNext
Window
()
throws
Exception
{
public
void
seekToNext
MediaItem
()
throws
Exception
{
RemoteMediaController
controller
=
createControllerAndWaitConnection
();
RemoteMediaController
controller
=
createControllerAndWaitConnection
();
sessionCallback
.
reset
(
1
);
sessionCallback
.
reset
(
1
);
controller
.
seekToNext
Window
();
controller
.
seekToNext
MediaItem
();
assertThat
(
sessionCallback
.
await
(
TIMEOUT_MS
)).
isTrue
();
assertThat
(
sessionCallback
.
await
(
TIMEOUT_MS
)).
isTrue
();
assertThat
(
sessionCallback
.
onSkipToNextCalled
).
isTrue
();
assertThat
(
sessionCallback
.
onSkipToNextCalled
).
isTrue
();
}
}
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionPermissionTest.java
View file @
f37e9800
...
@@ -164,14 +164,15 @@ public class MediaSessionPermissionTest {
...
@@ -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
seekToPrevious
Window
()
throws
Exception
{
public
void
seekToPrevious
MediaItem
()
throws
Exception
{
testOnCommandRequest
(
testOnCommandRequest
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
,
RemoteMediaController:
:
seekToPrevious
Window
);
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
,
RemoteMediaController:
:
seekToPrevious
MediaItem
);
}
}
@Test
@Test
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionPlayerTest.java
View file @
f37e9800
...
@@ -138,12 +138,12 @@ public class MediaSessionPlayerTest {
...
@@ -138,12 +138,12 @@ public class MediaSessionPlayerTest {
}
}
@Test
@Test
public
void
seekToDefaultPosition_with
Window
Index
()
throws
Exception
{
public
void
seekToDefaultPosition_with
MediaItem
Index
()
throws
Exception
{
int
window
Index
=
3
;
int
mediaItem
Index
=
3
;
controller
.
seekToDefaultPosition
(
window
Index
);
controller
.
seekToDefaultPosition
(
mediaItem
Index
);
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
seekToDefaultPositionWith
Window
IndexCalled
).
isTrue
();
assertThat
(
player
.
seekToDefaultPositionWith
MediaItem
IndexCalled
).
isTrue
();
assertThat
(
player
.
seek
WindowIndex
).
isEqualTo
(
window
Index
);
assertThat
(
player
.
seek
MediaItemIndex
).
isEqualTo
(
mediaItem
Index
);
}
}
@Test
@Test
...
@@ -156,13 +156,13 @@ public class MediaSessionPlayerTest {
...
@@ -156,13 +156,13 @@ public class MediaSessionPlayerTest {
}
}
@Test
@Test
public
void
seekTo_with
Window
Index
()
throws
Exception
{
public
void
seekTo_with
MediaItem
Index
()
throws
Exception
{
int
window
Index
=
3
;
int
mediaItem
Index
=
3
;
long
seekPositionMs
=
12125L
;
long
seekPositionMs
=
12125L
;
controller
.
seekTo
(
window
Index
,
seekPositionMs
);
controller
.
seekTo
(
mediaItem
Index
,
seekPositionMs
);
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
seekToWith
Window
IndexCalled
).
isTrue
();
assertThat
(
player
.
seekToWith
MediaItem
IndexCalled
).
isTrue
();
assertThat
(
player
.
seek
WindowIndex
).
isEqualTo
(
window
Index
);
assertThat
(
player
.
seek
MediaItemIndex
).
isEqualTo
(
mediaItem
Index
);
assertThat
(
player
.
seekPositionMs
).
isEqualTo
(
seekPositionMs
);
assertThat
(
player
.
seekPositionMs
).
isEqualTo
(
seekPositionMs
);
}
}
...
@@ -260,17 +260,17 @@ public class MediaSessionPlayerTest {
...
@@ -260,17 +260,17 @@ public class MediaSessionPlayerTest {
}
}
@Test
@Test
public
void
setMediaItems_withStart
Window
Index
()
throws
Exception
{
public
void
setMediaItems_withStart
MediaItem
Index
()
throws
Exception
{
List
<
MediaItem
>
items
=
MediaTestUtils
.
createMediaItems
(
/* size= */
2
);
List
<
MediaItem
>
items
=
MediaTestUtils
.
createMediaItems
(
/* size= */
2
);
int
start
Window
Index
=
1
;
int
start
MediaItem
Index
=
1
;
long
startPositionMs
=
1234
;
long
startPositionMs
=
1234
;
controller
.
setMediaItems
(
items
,
start
Window
Index
,
startPositionMs
);
controller
.
setMediaItems
(
items
,
start
MediaItem
Index
,
startPositionMs
);
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
setMediaItemsWithStart
Window
IndexCalled
).
isTrue
();
assertThat
(
player
.
setMediaItemsWithStartIndexCalled
).
isTrue
();
assertThat
(
player
.
mediaItems
).
isEqualTo
(
items
);
assertThat
(
player
.
mediaItems
).
isEqualTo
(
items
);
assertThat
(
player
.
start
WindowIndex
).
isEqualTo
(
startWindow
Index
);
assertThat
(
player
.
start
MediaItemIndex
).
isEqualTo
(
startMediaItem
Index
);
assertThat
(
player
.
startPositionMs
).
isEqualTo
(
startPositionMs
);
assertThat
(
player
.
startPositionMs
).
isEqualTo
(
startPositionMs
);
}
}
...
@@ -426,15 +426,15 @@ public class MediaSessionPlayerTest {
...
@@ -426,15 +426,15 @@ public class MediaSessionPlayerTest {
}
}
@Test
@Test
public
void
seekToPrevious
Window
()
throws
Exception
{
public
void
seekToPrevious
MediaItem
()
throws
Exception
{
controller
.
seekToPrevious
Window
();
controller
.
seekToPrevious
MediaItem
();
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
seekToNext
Window
()
throws
Exception
{
public
void
seekToNext
MediaItem
()
throws
Exception
{
controller
.
seekToNext
Window
();
controller
.
seekToNext
MediaItem
();
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
countDownLatch
.
await
(
TIMEOUT_MS
,
MILLISECONDS
)).
isTrue
();
assertThat
(
player
.
seekToNextMediaItemCalled
).
isTrue
();
assertThat
(
player
.
seekToNextMediaItemCalled
).
isTrue
();
}
}
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaSessionTest.java
View file @
f37e9800
...
@@ -247,7 +247,7 @@ public class MediaSessionTest {
...
@@ -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
.
seekToNext
Window
();
controller
.
seekToNext
MediaItem
();
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 {
...
@@ -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
.
seekToPrevious
Window
();
controller
.
seekToPrevious
MediaItem
();
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
));
}
}
...
...
libraries/test_session_current/src/androidTest/java/androidx/media3/session/MockPlayerTest.java
View file @
f37e9800
...
@@ -166,8 +166,8 @@ public class MockPlayerTest {
...
@@ -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
.
setMediaItemsWithStart
Window
IndexCalled
).
isTrue
();
assertThat
(
player
.
setMediaItemsWithStartIndexCalled
).
isTrue
();
assertThat
(
player
.
start
Window
Index
).
isEqualTo
(
startWindowIndex
);
assertThat
(
player
.
start
MediaItem
Index
).
isEqualTo
(
startWindowIndex
);
assertThat
(
player
.
startPositionMs
).
isEqualTo
(
startPositionMs
);
assertThat
(
player
.
startPositionMs
).
isEqualTo
(
startPositionMs
);
assertThat
(
player
.
mediaItems
).
isSameInstanceAs
(
list
);
assertThat
(
player
.
mediaItems
).
isSameInstanceAs
(
list
);
}
}
...
...
libraries/test_session_current/src/main/java/androidx/media3/session/MediaControllerProviderService.java
View file @
f37e9800
...
@@ -216,12 +216,12 @@ public class MediaControllerProviderService extends Service {
...
@@ -216,12 +216,12 @@ public class MediaControllerProviderService extends Service {
}
}
@Override
@Override
public
void
seekToDefaultPositionWith
WindowIndex
(
String
controllerId
,
int
window
Index
)
public
void
seekToDefaultPositionWith
MediaItemIndex
(
String
controllerId
,
int
mediaItem
Index
)
throws
RemoteException
{
throws
RemoteException
{
runOnHandler
(
runOnHandler
(
()
->
{
()
->
{
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
controller
.
seekToDefaultPosition
(
window
Index
);
controller
.
seekToDefaultPosition
(
mediaItem
Index
);
});
});
}
}
...
@@ -235,12 +235,12 @@ public class MediaControllerProviderService extends Service {
...
@@ -235,12 +235,12 @@ public class MediaControllerProviderService extends Service {
}
}
@Override
@Override
public
void
seekToWith
WindowIndex
(
String
controllerId
,
int
window
Index
,
long
positionMs
)
public
void
seekToWith
MediaItemIndex
(
String
controllerId
,
int
mediaItem
Index
,
long
positionMs
)
throws
RemoteException
{
throws
RemoteException
{
runOnHandler
(
runOnHandler
(
()
->
{
()
->
{
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
controller
.
seekTo
(
window
Index
,
positionMs
);
controller
.
seekTo
(
mediaItem
Index
,
positionMs
);
});
});
}
}
...
@@ -336,18 +336,15 @@ public class MediaControllerProviderService extends Service {
...
@@ -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
),
start
Window
Index
,
startIndex
,
startPositionMs
);
startPositionMs
);
});
});
}
}
...
@@ -478,20 +475,20 @@ public class MediaControllerProviderService extends Service {
...
@@ -478,20 +475,20 @@ public class MediaControllerProviderService extends Service {
}
}
@Override
@Override
public
void
seekToPrevious
Window
(
String
controllerId
)
throws
RemoteException
{
public
void
seekToPrevious
MediaItem
(
String
controllerId
)
throws
RemoteException
{
runOnHandler
(
runOnHandler
(
()
->
{
()
->
{
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
controller
.
seekToPrevious
Window
();
controller
.
seekToPrevious
MediaItem
();
});
});
}
}
@Override
@Override
public
void
seekToNext
Window
(
String
controllerId
)
throws
RemoteException
{
public
void
seekToNext
MediaItem
(
String
controllerId
)
throws
RemoteException
{
runOnHandler
(
runOnHandler
(
()
->
{
()
->
{
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
MediaController
controller
=
mediaControllerMap
.
get
(
controllerId
);
controller
.
seekToNext
Window
();
controller
.
seekToNext
MediaItem
();
});
});
}
}
...
...
libraries/test_session_current/src/main/java/androidx/media3/session/MediaSessionProviderService.java
View file @
f37e9800
...
@@ -26,9 +26,9 @@ import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD
...
@@ -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 {
...
@@ -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 {
...
@@ -749,7 +749,7 @@ public class MediaSessionProviderService extends Service {
}
}
@Override
@Override
public
void
setCurrent
Window
Index
(
String
sessionId
,
int
index
)
throws
RemoteException
{
public
void
setCurrent
MediaItem
Index
(
String
sessionId
,
int
index
)
throws
RemoteException
{
runOnHandler
(
runOnHandler
(
()
->
{
()
->
{
MediaSession
session
=
sessionMap
.
get
(
sessionId
);
MediaSession
session
=
sessionMap
.
get
(
sessionId
);
...
...
libraries/test_session_current/src/main/java/androidx/media3/session/MockPlayer.java
View file @
f37e9800
...
@@ -55,7 +55,7 @@ public class MockPlayer implements Player {
...
@@ -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
seek
Window
Index
;
public
int
seek
MediaItem
Index
;
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 {
...
@@ -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
start
Window
Index
;
public
int
start
MediaItem
Index
;
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 {
...
@@ -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
seekToDefaultPositionWith
Window
IndexCalled
;
public
boolean
seekToDefaultPositionWith
MediaItem
IndexCalled
;
public
boolean
seekToCalled
;
public
boolean
seekToCalled
;
public
boolean
seekToWith
Window
IndexCalled
;
public
boolean
seekToWith
MediaItem
IndexCalled
;
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 {
...
@@ -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
setMediaItemsWithStart
Window
IndexCalled
;
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 {
...
@@ -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
;
seek
Window
Index
=
C
.
INDEX_UNSET
;
seek
MediaItem
Index
=
C
.
INDEX_UNSET
;
mediaMetadata
=
MediaMetadata
.
EMPTY
;
mediaMetadata
=
MediaMetadata
.
EMPTY
;
currentPosition
=
0
;
currentPosition
=
0
;
...
@@ -271,8 +271,8 @@ public class MockPlayer implements Player {
...
@@ -271,8 +271,8 @@ public class MockPlayer implements Player {
@Override
@Override
public
void
seekToDefaultPosition
(
int
mediaItemIndex
)
{
public
void
seekToDefaultPosition
(
int
mediaItemIndex
)
{
seekToDefaultPositionWith
Window
IndexCalled
=
true
;
seekToDefaultPositionWith
MediaItem
IndexCalled
=
true
;
seek
Window
Index
=
mediaItemIndex
;
seek
MediaItem
Index
=
mediaItemIndex
;
countDownLatch
.
countDown
();
countDownLatch
.
countDown
();
}
}
...
@@ -285,8 +285,8 @@ public class MockPlayer implements Player {
...
@@ -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
)
{
seekToWith
Window
IndexCalled
=
true
;
seekToWith
MediaItem
IndexCalled
=
true
;
seek
Window
Index
=
mediaItemIndex
;
seek
MediaItem
Index
=
mediaItemIndex
;
seekPositionMs
=
positionMs
;
seekPositionMs
=
positionMs
;
countDownLatch
.
countDown
();
countDownLatch
.
countDown
();
}
}
...
@@ -666,9 +666,9 @@ public class MockPlayer implements Player {
...
@@ -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
)
{
setMediaItemsWithStart
Window
IndexCalled
=
true
;
setMediaItemsWithStartIndexCalled
=
true
;
this
.
mediaItems
=
mediaItems
;
this
.
mediaItems
=
mediaItems
;
this
.
start
Window
Index
=
startIndex
;
this
.
start
MediaItem
Index
=
startIndex
;
this
.
startPositionMs
=
startPositionMs
;
this
.
startPositionMs
=
startPositionMs
;
countDownLatch
.
countDown
();
countDownLatch
.
countDown
();
}
}
...
...
libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaController.java
View file @
f37e9800
...
@@ -112,16 +112,16 @@ public class RemoteMediaController {
...
@@ -112,16 +112,16 @@ public class RemoteMediaController {
binder
.
seekToDefaultPosition
(
controllerId
);
binder
.
seekToDefaultPosition
(
controllerId
);
}
}
public
void
seekToDefaultPosition
(
int
window
Index
)
throws
RemoteException
{
public
void
seekToDefaultPosition
(
int
mediaItem
Index
)
throws
RemoteException
{
binder
.
seekToDefaultPositionWith
WindowIndex
(
controllerId
,
window
Index
);
binder
.
seekToDefaultPositionWith
MediaItemIndex
(
controllerId
,
mediaItem
Index
);
}
}
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
window
Index
,
long
positionMs
)
throws
RemoteException
{
public
void
seekTo
(
int
mediaItem
Index
,
long
positionMs
)
throws
RemoteException
{
binder
.
seekToWith
WindowIndex
(
controllerId
,
window
Index
,
positionMs
);
binder
.
seekToWith
MediaItemIndex
(
controllerId
,
mediaItem
Index
,
positionMs
);
}
}
public
void
seekBack
()
throws
RemoteException
{
public
void
seekBack
()
throws
RemoteException
{
...
@@ -162,10 +162,10 @@ public class RemoteMediaController {
...
@@ -162,10 +162,10 @@ public class RemoteMediaController {
controllerId
,
BundleableUtil
.
toBundleList
(
mediaItems
),
resetPosition
);
controllerId
,
BundleableUtil
.
toBundleList
(
mediaItems
),
resetPosition
);
}
}
public
void
setMediaItems
(
List
<
MediaItem
>
mediaItems
,
int
start
Window
Index
,
long
startPositionMs
)
public
void
setMediaItems
(
List
<
MediaItem
>
mediaItems
,
int
startIndex
,
long
startPositionMs
)
throws
RemoteException
{
throws
RemoteException
{
binder
.
setMediaItemsWithStart
Window
Index
(
binder
.
setMediaItemsWithStartIndex
(
controllerId
,
BundleableUtil
.
toBundleList
(
mediaItems
),
start
Window
Index
,
startPositionMs
);
controllerId
,
BundleableUtil
.
toBundleList
(
mediaItems
),
startIndex
,
startPositionMs
);
}
}
/**
/**
...
@@ -222,12 +222,12 @@ public class RemoteMediaController {
...
@@ -222,12 +222,12 @@ public class RemoteMediaController {
binder
.
moveMediaItems
(
controllerId
,
fromIndex
,
toIndex
,
newIndex
);
binder
.
moveMediaItems
(
controllerId
,
fromIndex
,
toIndex
,
newIndex
);
}
}
public
void
seekToPrevious
Window
()
throws
RemoteException
{
public
void
seekToPrevious
MediaItem
()
throws
RemoteException
{
binder
.
seekToPrevious
Window
(
controllerId
);
binder
.
seekToPrevious
MediaItem
(
controllerId
);
}
}
public
void
seekToNext
Window
()
throws
RemoteException
{
public
void
seekToNext
MediaItem
()
throws
RemoteException
{
binder
.
seekToNext
Window
(
controllerId
);
binder
.
seekToNext
MediaItem
(
controllerId
);
}
}
public
void
seekToPrevious
()
throws
RemoteException
{
public
void
seekToPrevious
()
throws
RemoteException
{
...
...
libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaSession.java
View file @
f37e9800
...
@@ -26,9 +26,9 @@ import static androidx.media3.test.session.common.CommonConstants.KEY_CURRENT_AD
...
@@ -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 {
...
@@ -343,8 +343,8 @@ public class RemoteMediaSession {
binder
.
setShuffleModeEnabled
(
sessionId
,
shuffleModeEnabled
);
binder
.
setShuffleModeEnabled
(
sessionId
,
shuffleModeEnabled
);
}
}
public
void
setCurrent
Window
Index
(
int
index
)
throws
RemoteException
{
public
void
setCurrent
MediaItem
Index
(
int
index
)
throws
RemoteException
{
binder
.
setCurrent
Window
Index
(
sessionId
,
index
);
binder
.
setCurrent
MediaItem
Index
(
sessionId
,
index
);
}
}
public
void
setTrackSelectionParameters
(
TrackSelectionParameters
parameters
)
public
void
setTrackSelectionParameters
(
TrackSelectionParameters
parameters
)
...
@@ -571,8 +571,8 @@ public class RemoteMediaSession {
...
@@ -571,8 +571,8 @@ public class RemoteMediaSession {
return
this
;
return
this
;
}
}
public
MockPlayerConfigBuilder
setCurrent
Window
Index
(
int
index
)
{
public
MockPlayerConfigBuilder
setCurrent
MediaItem
Index
(
int
index
)
{
bundle
.
putInt
(
KEY_CURRENT_
WINDOW
_INDEX
,
index
);
bundle
.
putInt
(
KEY_CURRENT_
MEDIA_ITEM
_INDEX
,
index
);
return
this
;
return
this
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment