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
9d2d3340
authored
Mar 11, 2021
by
kimvde
Committed by
Ian Baker
Mar 12, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add available commands to prepare/play/pause/stop/release.
PiperOrigin-RevId: 362292208
parent
c7bcacde
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
17 deletions
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java
library/common/src/main/java/com/google/android/exoplayer2/BasePlayer.java
library/common/src/main/java/com/google/android/exoplayer2/Player.java
library/common/src/main/java/com/google/android/exoplayer2/util/ExoFlags.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
View file @
9d2d3340
...
@@ -140,14 +140,13 @@ public final class CastPlayer extends BasePlayer {
...
@@ -140,14 +140,13 @@ public final class CastPlayer extends BasePlayer {
Looper
.
getMainLooper
(),
Looper
.
getMainLooper
(),
Clock
.
DEFAULT
,
Clock
.
DEFAULT
,
(
listener
,
flags
)
->
listener
.
onEvents
(
/* player= */
this
,
new
Events
(
flags
)));
(
listener
,
flags
)
->
listener
.
onEvents
(
/* player= */
this
,
new
Events
(
flags
)));
playWhenReady
=
new
StateHolder
<>(
false
);
playWhenReady
=
new
StateHolder
<>(
false
);
repeatMode
=
new
StateHolder
<>(
REPEAT_MODE_OFF
);
repeatMode
=
new
StateHolder
<>(
REPEAT_MODE_OFF
);
playbackState
=
STATE_IDLE
;
playbackState
=
STATE_IDLE
;
currentTimeline
=
CastTimeline
.
EMPTY_CAST_TIMELINE
;
currentTimeline
=
CastTimeline
.
EMPTY_CAST_TIMELINE
;
currentTrackGroups
=
TrackGroupArray
.
EMPTY
;
currentTrackGroups
=
TrackGroupArray
.
EMPTY
;
currentTrackSelection
=
EMPTY_TRACK_SELECTION_ARRAY
;
currentTrackSelection
=
EMPTY_TRACK_SELECTION_ARRAY
;
availableCommands
=
Commands
.
EMPTY
;
availableCommands
=
new
Commands
.
Builder
().
addAll
(
PERMANENT_AVAILABLE_COMMANDS
).
build
()
;
pendingSeekWindowIndex
=
C
.
INDEX_UNSET
;
pendingSeekWindowIndex
=
C
.
INDEX_UNSET
;
pendingSeekPositionMs
=
C
.
TIME_UNSET
;
pendingSeekPositionMs
=
C
.
TIME_UNSET
;
...
...
extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java
View file @
9d2d3340
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
ext
.
cast
;
package
com
.
google
.
android
.
exoplayer2
.
ext
.
cast
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PLAY_PAUSE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PREPARE_STOP_RELEASE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
...
@@ -593,6 +595,12 @@ public class CastPlayerTest {
...
@@ -593,6 +595,12 @@ public class CastPlayerTest {
}
}
@Test
@Test
public
void
isCommandAvailable_containsPermanentCommands
()
{
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_PLAY_PAUSE
)).
isTrue
();
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_PREPARE_STOP_RELEASE
)).
isTrue
();
}
@Test
public
void
seekTo_nextWindow_notifiesAvailableCommandsChanged
()
{
public
void
seekTo_nextWindow_notifiesAvailableCommandsChanged
()
{
when
(
mockRemoteMediaClient
.
queueJumpToItem
(
anyInt
(),
anyLong
(),
eq
(
null
)))
when
(
mockRemoteMediaClient
.
queueJumpToItem
(
anyInt
(),
anyLong
(),
eq
(
null
)))
.
thenReturn
(
mockPendingResult
);
.
thenReturn
(
mockPendingResult
);
...
@@ -728,6 +736,7 @@ public class CastPlayerTest {
...
@@ -728,6 +736,7 @@ public class CastPlayerTest {
@Test
@Test
public
void
removeMediaItem_atTheEnd_notifiesAvailableCommandsChanged
()
{
public
void
removeMediaItem_atTheEnd_notifiesAvailableCommandsChanged
()
{
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithoutSeek
=
createCommands
();
MediaItem
mediaItem1
=
createMediaItem
(
/* mediaQueueItemId= */
1
);
MediaItem
mediaItem1
=
createMediaItem
(
/* mediaQueueItemId= */
1
);
MediaItem
mediaItem2
=
createMediaItem
(
/* mediaQueueItemId= */
2
);
MediaItem
mediaItem2
=
createMediaItem
(
/* mediaQueueItemId= */
2
);
MediaItem
mediaItem3
=
createMediaItem
(
/* mediaQueueItemId= */
3
);
MediaItem
mediaItem3
=
createMediaItem
(
/* mediaQueueItemId= */
3
);
...
@@ -752,7 +761,7 @@ public class CastPlayerTest {
...
@@ -752,7 +761,7 @@ public class CastPlayerTest {
ImmutableList
.
of
(
mediaItem1
),
ImmutableList
.
of
(
mediaItem1
),
/* mediaQueueItemIds= */
new
int
[]
{
1
},
/* mediaQueueItemIds= */
new
int
[]
{
1
},
/* currentItemId= */
1
);
/* currentItemId= */
1
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
Player
.
Commands
.
EMPTY
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
commandsWithoutSeek
);
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
castPlayer
.
removeMediaItem
(
/* index= */
0
);
castPlayer
.
removeMediaItem
(
/* index= */
0
);
...
@@ -769,6 +778,7 @@ public class CastPlayerTest {
...
@@ -769,6 +778,7 @@ public class CastPlayerTest {
.
thenReturn
(
mockPendingResult
);
.
thenReturn
(
mockPendingResult
);
Player
.
Commands
commandsWithSeekToPrevious
=
Player
.
Commands
commandsWithSeekToPrevious
=
createCommands
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
);
createCommands
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
);
Player
.
Commands
commandsWithoutSeek
=
createCommands
();
MediaItem
mediaItem1
=
createMediaItem
(
/* mediaQueueItemId= */
1
);
MediaItem
mediaItem1
=
createMediaItem
(
/* mediaQueueItemId= */
1
);
MediaItem
mediaItem2
=
createMediaItem
(
/* mediaQueueItemId= */
2
);
MediaItem
mediaItem2
=
createMediaItem
(
/* mediaQueueItemId= */
2
);
MediaItem
mediaItem3
=
createMediaItem
(
/* mediaQueueItemId= */
3
);
MediaItem
mediaItem3
=
createMediaItem
(
/* mediaQueueItemId= */
3
);
...
@@ -793,7 +803,7 @@ public class CastPlayerTest {
...
@@ -793,7 +803,7 @@ public class CastPlayerTest {
ImmutableList
.
of
(
mediaItem3
),
ImmutableList
.
of
(
mediaItem3
),
/* mediaQueueItemIds= */
new
int
[]
{
3
},
/* mediaQueueItemIds= */
new
int
[]
{
3
},
/* currentItemId= */
3
);
/* currentItemId= */
3
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
Player
.
Commands
.
EMPTY
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
commandsWithoutSeek
);
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
castPlayer
.
removeMediaItem
(
/* index= */
0
);
castPlayer
.
removeMediaItem
(
/* index= */
0
);
...
@@ -807,6 +817,7 @@ public class CastPlayerTest {
...
@@ -807,6 +817,7 @@ public class CastPlayerTest {
@Test
@Test
public
void
removeMediaItem_current_notifiesAvailableCommandsChanged
()
{
public
void
removeMediaItem_current_notifiesAvailableCommandsChanged
()
{
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithoutSeek
=
createCommands
();
MediaItem
mediaItem1
=
createMediaItem
(
/* mediaQueueItemId= */
1
);
MediaItem
mediaItem1
=
createMediaItem
(
/* mediaQueueItemId= */
1
);
MediaItem
mediaItem2
=
createMediaItem
(
/* mediaQueueItemId= */
2
);
MediaItem
mediaItem2
=
createMediaItem
(
/* mediaQueueItemId= */
2
);
...
@@ -823,7 +834,7 @@ public class CastPlayerTest {
...
@@ -823,7 +834,7 @@ public class CastPlayerTest {
ImmutableList
.
of
(
mediaItem2
),
ImmutableList
.
of
(
mediaItem2
),
/* mediaQueueItemIds= */
new
int
[]
{
2
},
/* mediaQueueItemIds= */
new
int
[]
{
2
},
/* currentItemId= */
2
);
/* currentItemId= */
2
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
Player
.
Commands
.
EMPTY
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
commandsWithoutSeek
);
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
}
}
...
@@ -912,6 +923,7 @@ public class CastPlayerTest {
...
@@ -912,6 +923,7 @@ public class CastPlayerTest {
private
static
Player
.
Commands
createCommands
(
@Player
.
Command
int
...
commands
)
{
private
static
Player
.
Commands
createCommands
(
@Player
.
Command
int
...
commands
)
{
Player
.
Commands
.
Builder
builder
=
new
Player
.
Commands
.
Builder
();
Player
.
Commands
.
Builder
builder
=
new
Player
.
Commands
.
Builder
();
builder
.
addAll
(
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP_RELEASE
);
for
(
int
command
:
commands
)
{
for
(
int
command
:
commands
)
{
builder
.
add
(
command
);
builder
.
add
(
command
);
}
}
...
...
library/common/src/main/java/com/google/android/exoplayer2/BasePlayer.java
View file @
9d2d3340
...
@@ -24,6 +24,9 @@ import java.util.List;
...
@@ -24,6 +24,9 @@ import java.util.List;
/** Abstract base {@link Player} which implements common implementation independent methods. */
/** Abstract base {@link Player} which implements common implementation independent methods. */
public
abstract
class
BasePlayer
implements
Player
{
public
abstract
class
BasePlayer
implements
Player
{
protected
static
final
int
[]
PERMANENT_AVAILABLE_COMMANDS
=
new
int
[]
{
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP_RELEASE
};
protected
final
Timeline
.
Window
window
;
protected
final
Timeline
.
Window
window
;
public
BasePlayer
()
{
public
BasePlayer
()
{
...
@@ -322,6 +325,7 @@ public abstract class BasePlayer implements Player {
...
@@ -322,6 +325,7 @@ public abstract class BasePlayer implements Player {
protected
Commands
getAvailableCommands
()
{
protected
Commands
getAvailableCommands
()
{
return
new
Commands
.
Builder
()
return
new
Commands
.
Builder
()
.
addAll
(
PERMANENT_AVAILABLE_COMMANDS
)
.
addIf
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
,
hasNext
()
&&
!
isPlayingAd
())
.
addIf
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
,
hasNext
()
&&
!
isPlayingAd
())
.
addIf
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
,
hasPrevious
()
&&
!
isPlayingAd
())
.
addIf
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
,
hasPrevious
()
&&
!
isPlayingAd
())
.
build
();
.
build
();
...
...
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
9d2d3340
...
@@ -758,6 +758,18 @@ public interface Player {
...
@@ -758,6 +758,18 @@ public interface Player {
}
}
/**
/**
* Adds {@link Command commands}.
*
* @param commands The {@link Command commands} to add.
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
public
Builder
addAll
(
@Command
int
...
commands
)
{
flagsBuilder
.
addAll
(
commands
);
return
this
;
}
/**
* Builds a {@link Commands} instance.
* Builds a {@link Commands} instance.
*
*
* @throws IllegalStateException If this method has already been called.
* @throws IllegalStateException If this method has already been called.
...
@@ -767,9 +779,6 @@ public interface Player {
...
@@ -767,9 +779,6 @@ public interface Player {
}
}
}
}
/** An empty set of commands. */
public
static
final
Commands
EMPTY
=
new
Builder
().
build
();
private
final
ExoFlags
flags
;
private
final
ExoFlags
flags
;
private
Commands
(
ExoFlags
flags
)
{
private
Commands
(
ExoFlags
flags
)
{
...
@@ -1037,17 +1046,27 @@ public interface Player {
...
@@ -1037,17 +1046,27 @@ public interface Player {
int
EVENT_AVAILABLE_COMMANDS_CHANGED
=
14
;
int
EVENT_AVAILABLE_COMMANDS_CHANGED
=
14
;
/**
/**
* Commands that can be executed on a {@code Player}. One of {@link
* Commands that can be executed on a {@code Player}. One of {@link #COMMAND_PLAY_PAUSE}, {@link
* #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} or {@link #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}.
* #COMMAND_PREPARE_STOP_RELEASE}, {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} or {@link
* #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}.
*/
*/
@Documented
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
})
@IntDef
({
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP_RELEASE
,
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
})
@interface
Command
{}
@interface
Command
{}
/** Command to start, pause or resume playback. */
int
COMMAND_PLAY_PAUSE
=
1
;
/** Command to prepare the player, stop playback or release the player. */
int
COMMAND_PREPARE_STOP_RELEASE
=
2
;
/** Command to seek to the next {@link MediaItem} in the playlist. */
/** Command to seek to the next {@link MediaItem} in the playlist. */
int
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
=
0
;
int
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
=
3
;
/** Command to seek to the previous {@link MediaItem} in the playlist. */
/** Command to seek to the previous {@link MediaItem} in the playlist. */
int
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
=
1
;
int
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
=
4
;
/** Returns the component of this player for audio output, or null if audio is not supported. */
/** Returns the component of this player for audio output, or null if audio is not supported. */
@Nullable
@Nullable
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/ExoFlags.java
View file @
9d2d3340
...
@@ -71,6 +71,20 @@ public final class ExoFlags {
...
@@ -71,6 +71,20 @@ public final class ExoFlags {
}
}
/**
/**
* Adds flags.
*
* @param flags The flags to add.
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
public
Builder
addAll
(
int
...
flags
)
{
for
(
int
flag
:
flags
)
{
add
(
flag
);
}
return
this
;
}
/**
* Builds an {@link ExoFlags} instance.
* Builds an {@link ExoFlags} instance.
*
*
* @throws IllegalStateException If this method has already been called.
* @throws IllegalStateException If this method has already been called.
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
9d2d3340
...
@@ -174,7 +174,7 @@ import java.util.List;
...
@@ -174,7 +174,7 @@ import java.util.List;
new
ExoTrackSelection
[
renderers
.
length
],
new
ExoTrackSelection
[
renderers
.
length
],
/* info= */
null
);
/* info= */
null
);
period
=
new
Timeline
.
Period
();
period
=
new
Timeline
.
Period
();
availableCommands
=
Commands
.
EMPTY
;
availableCommands
=
new
Commands
.
Builder
().
addAll
(
PERMANENT_AVAILABLE_COMMANDS
).
build
()
;
maskingWindowIndex
=
C
.
INDEX_UNSET
;
maskingWindowIndex
=
C
.
INDEX_UNSET
;
playbackInfoUpdateHandler
=
clock
.
createHandler
(
applicationLooper
,
/* callback= */
null
);
playbackInfoUpdateHandler
=
clock
.
createHandler
(
applicationLooper
,
/* callback= */
null
);
playbackInfoUpdateListener
=
playbackInfoUpdateListener
=
...
...
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
9d2d3340
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
;
package
com
.
google
.
android
.
exoplayer2
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PLAY_PAUSE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PREPARE_STOP_RELEASE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
RobolectricUtil
.
runMainLooperUntil
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
RobolectricUtil
.
runMainLooperUntil
;
...
@@ -8081,6 +8083,14 @@ public final class ExoPlayerTest {
...
@@ -8081,6 +8083,14 @@ public final class ExoPlayerTest {
}
}
@Test
@Test
public
void
isCommandAvailable_containsPermanentCommands
()
{
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_PLAY_PAUSE
)).
isTrue
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_PREPARE_STOP_RELEASE
)).
isTrue
();
}
@Test
public
void
isCommandAvailable_whenPlayingAd_isFalseForSeekCommands
()
throws
Exception
{
public
void
isCommandAvailable_whenPlayingAd_isFalseForSeekCommands
()
throws
Exception
{
AdPlaybackState
adPlaybackState
=
AdPlaybackState
adPlaybackState
=
new
AdPlaybackState
(
/* adsId= */
new
Object
(),
/* adGroupTimesUs...= */
0
)
new
AdPlaybackState
(
/* adsId= */
new
Object
(),
/* adGroupTimesUs...= */
0
)
...
@@ -8262,6 +8272,7 @@ public final class ExoPlayerTest {
...
@@ -8262,6 +8272,7 @@ public final class ExoPlayerTest {
@Test
@Test
public
void
removeMediaItem_atTheEnd_notifiesAvailableCommandsChanged
()
{
public
void
removeMediaItem_atTheEnd_notifiesAvailableCommandsChanged
()
{
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithoutSeek
=
createCommands
();
Player
.
EventListener
mockListener
=
mock
(
Player
.
EventListener
.
class
);
Player
.
EventListener
mockListener
=
mock
(
Player
.
EventListener
.
class
);
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
addListener
(
mockListener
);
player
.
addListener
(
mockListener
);
...
@@ -8275,7 +8286,7 @@ public final class ExoPlayerTest {
...
@@ -8275,7 +8286,7 @@ public final class ExoPlayerTest {
verify
(
mockListener
).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
).
onAvailableCommandsChanged
(
any
());
player
.
removeMediaItem
(
/* index= */
1
);
player
.
removeMediaItem
(
/* index= */
1
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
Player
.
Commands
.
EMPTY
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
commandsWithoutSeek
);
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
player
.
removeMediaItem
(
/* index= */
0
);
player
.
removeMediaItem
(
/* index= */
0
);
...
@@ -8286,6 +8297,7 @@ public final class ExoPlayerTest {
...
@@ -8286,6 +8297,7 @@ public final class ExoPlayerTest {
public
void
removeMediaItem_atTheStart_notifiesAvailableCommandsChanged
()
{
public
void
removeMediaItem_atTheStart_notifiesAvailableCommandsChanged
()
{
Player
.
Commands
commandsWithSeekToPrevious
=
Player
.
Commands
commandsWithSeekToPrevious
=
createCommands
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
);
createCommands
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
);
Player
.
Commands
commandsWithoutSeek
=
createCommands
();
Player
.
EventListener
mockListener
=
mock
(
Player
.
EventListener
.
class
);
Player
.
EventListener
mockListener
=
mock
(
Player
.
EventListener
.
class
);
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
addListener
(
mockListener
);
player
.
addListener
(
mockListener
);
...
@@ -8300,7 +8312,7 @@ public final class ExoPlayerTest {
...
@@ -8300,7 +8312,7 @@ public final class ExoPlayerTest {
verify
(
mockListener
).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
).
onAvailableCommandsChanged
(
any
());
player
.
removeMediaItem
(
/* index= */
0
);
player
.
removeMediaItem
(
/* index= */
0
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
Player
.
Commands
.
EMPTY
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
commandsWithoutSeek
);
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
player
.
removeMediaItem
(
/* index= */
0
);
player
.
removeMediaItem
(
/* index= */
0
);
...
@@ -8310,6 +8322,7 @@ public final class ExoPlayerTest {
...
@@ -8310,6 +8322,7 @@ public final class ExoPlayerTest {
@Test
@Test
public
void
removeMediaItem_current_notifiesAvailableCommandsChanged
()
{
public
void
removeMediaItem_current_notifiesAvailableCommandsChanged
()
{
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithSeekToNext
=
createCommands
(
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
);
Player
.
Commands
commandsWithoutSeek
=
createCommands
();
Player
.
EventListener
mockListener
=
mock
(
Player
.
EventListener
.
class
);
Player
.
EventListener
mockListener
=
mock
(
Player
.
EventListener
.
class
);
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
addListener
(
mockListener
);
player
.
addListener
(
mockListener
);
...
@@ -8319,7 +8332,7 @@ public final class ExoPlayerTest {
...
@@ -8319,7 +8332,7 @@ public final class ExoPlayerTest {
verify
(
mockListener
).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
).
onAvailableCommandsChanged
(
any
());
player
.
removeMediaItem
(
/* index= */
0
);
player
.
removeMediaItem
(
/* index= */
0
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
Player
.
Commands
.
EMPTY
);
verify
(
mockListener
).
onAvailableCommandsChanged
(
commandsWithoutSeek
);
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
verify
(
mockListener
,
times
(
2
)).
onAvailableCommandsChanged
(
any
());
}
}
...
@@ -9313,6 +9326,7 @@ public final class ExoPlayerTest {
...
@@ -9313,6 +9326,7 @@ public final class ExoPlayerTest {
private
static
Player
.
Commands
createCommands
(
@Player
.
Command
int
...
commands
)
{
private
static
Player
.
Commands
createCommands
(
@Player
.
Command
int
...
commands
)
{
Player
.
Commands
.
Builder
builder
=
new
Player
.
Commands
.
Builder
();
Player
.
Commands
.
Builder
builder
=
new
Player
.
Commands
.
Builder
();
builder
.
addAll
(
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP_RELEASE
);
for
(
int
command
:
commands
)
{
for
(
int
command
:
commands
)
{
builder
.
add
(
command
);
builder
.
add
(
command
);
}
}
...
...
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