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
11becc05
authored
Oct 13, 2021
by
jaewan
Committed by
Oliver Woodman
Oct 13, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Separate command code for prepare() and stop()
PiperOrigin-RevId: 402757305
parent
a18e2812
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
41 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/Player.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/reader/RtpPayloadReader.java
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
View file @
11becc05
...
...
@@ -94,7 +94,8 @@ public final class CastPlayer extends BasePlayer {
new
Commands
.
Builder
()
.
addAll
(
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP
,
COMMAND_PREPARE
,
COMMAND_STOP
,
COMMAND_SEEK_TO_DEFAULT_POSITION
,
COMMAND_SEEK_TO_MEDIA_ITEM
,
COMMAND_SET_REPEAT_MODE
,
...
...
extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastPlayerTest.java
View file @
11becc05
...
...
@@ -25,7 +25,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_GET_TEXT;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_GET_TIMELINE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_GET_VOLUME
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PLAY_PAUSE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PREPARE
_STOP
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PREPARE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_BACK
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_FORWARD
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
;
...
...
@@ -42,6 +42,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_SET_SHUFFLE_MODE;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SET_SPEED_AND_PITCH
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SET_VIDEO_SURFACE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SET_VOLUME
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_STOP
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
DISCONTINUITY_REASON_REMOVE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
...
...
@@ -1315,7 +1316,8 @@ public class CastPlayerTest {
updateTimeLine
(
mediaItems
,
mediaQueueItemIds
,
/* currentItemId= */
1
);
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_PLAY_PAUSE
)).
isTrue
();
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_PREPARE_STOP
)).
isTrue
();
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_PREPARE
)).
isTrue
();
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_STOP
)).
isTrue
();
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_SEEK_TO_DEFAULT_POSITION
)).
isTrue
();
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
)).
isTrue
();
assertThat
(
castPlayer
.
isCommandAvailable
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
)).
isFalse
();
...
...
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
11becc05
...
...
@@ -676,7 +676,8 @@ public interface Player {
@Command
private
static
final
int
[]
SUPPORTED_COMMANDS
=
{
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP
,
COMMAND_PREPARE
,
COMMAND_STOP
,
COMMAND_SEEK_TO_DEFAULT_POSITION
,
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
,
...
...
@@ -1332,7 +1333,7 @@ public interface Player {
/**
* Commands that can be executed on a {@code Player}. One of {@link #COMMAND_PLAY_PAUSE}, {@link
* #COMMAND_PREPARE_STOP}, {@link #COMMAND_SEEK_TO_DEFAULT_POSITION}, {@link
* #COMMAND_PREPARE
}, {@link #COMMAND
_STOP}, {@link #COMMAND_SEEK_TO_DEFAULT_POSITION}, {@link
* #COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM}, {@link #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}, {@link
* #COMMAND_SEEK_TO_PREVIOUS}, {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM}, {@link
* #COMMAND_SEEK_TO_NEXT}, {@link #COMMAND_SEEK_TO_MEDIA_ITEM}, {@link #COMMAND_SEEK_BACK}, {@link
...
...
@@ -1351,7 +1352,8 @@ public interface Player {
@IntDef
({
COMMAND_INVALID
,
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP
,
COMMAND_PREPARE
,
COMMAND_STOP
,
COMMAND_SEEK_TO_DEFAULT_POSITION
,
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
,
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
,
...
...
@@ -1383,70 +1385,72 @@ public interface Player {
@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
=
2
;
/** Command to prepare the player. */
int
COMMAND_PREPARE
=
2
;
/** Command to stop playback or release the player. */
int
COMMAND_STOP
=
3
;
/** Command to seek to the default position of the current {@link MediaItem}. */
int
COMMAND_SEEK_TO_DEFAULT_POSITION
=
3
;
int
COMMAND_SEEK_TO_DEFAULT_POSITION
=
4
;
/** Command to seek anywhere into the current {@link MediaItem}. */
int
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
=
4
;
int
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
=
5
;
/** @deprecated Use {@link #COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM} instead. */
@Deprecated
int
COMMAND_SEEK_IN_CURRENT_WINDOW
=
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
;
/** Command to seek to the default position of the previous {@link MediaItem}. */
int
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
=
5
;
int
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
=
6
;
/** @deprecated Use {@link #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM} instead. */
@Deprecated
int
COMMAND_SEEK_TO_PREVIOUS_WINDOW
=
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
;
/** Command to seek to an earlier position in the current or previous {@link MediaItem}. */
int
COMMAND_SEEK_TO_PREVIOUS
=
6
;
int
COMMAND_SEEK_TO_PREVIOUS
=
7
;
/** Command to seek to the default position of the next {@link MediaItem}. */
int
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
=
7
;
int
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
=
8
;
/** @deprecated Use {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} instead. */
@Deprecated
int
COMMAND_SEEK_TO_NEXT_WINDOW
=
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
;
/** Command to seek to a later position in the current or next {@link MediaItem}. */
int
COMMAND_SEEK_TO_NEXT
=
8
;
int
COMMAND_SEEK_TO_NEXT
=
9
;
/** Command to seek anywhere in any {@link MediaItem}. */
int
COMMAND_SEEK_TO_MEDIA_ITEM
=
9
;
int
COMMAND_SEEK_TO_MEDIA_ITEM
=
10
;
/** @deprecated Use {@link #COMMAND_SEEK_TO_MEDIA_ITEM} instead. */
@Deprecated
int
COMMAND_SEEK_TO_WINDOW
=
COMMAND_SEEK_TO_MEDIA_ITEM
;
/** Command to seek back by a fixed increment into the current {@link MediaItem}. */
int
COMMAND_SEEK_BACK
=
1
0
;
int
COMMAND_SEEK_BACK
=
1
1
;
/** Command to seek forward by a fixed increment into the current {@link MediaItem}. */
int
COMMAND_SEEK_FORWARD
=
1
1
;
int
COMMAND_SEEK_FORWARD
=
1
2
;
/** Command to set the playback speed and pitch. */
int
COMMAND_SET_SPEED_AND_PITCH
=
1
2
;
int
COMMAND_SET_SPEED_AND_PITCH
=
1
3
;
/** Command to enable shuffling. */
int
COMMAND_SET_SHUFFLE_MODE
=
1
3
;
int
COMMAND_SET_SHUFFLE_MODE
=
1
4
;
/** Command to set the repeat mode. */
int
COMMAND_SET_REPEAT_MODE
=
1
4
;
int
COMMAND_SET_REPEAT_MODE
=
1
5
;
/** Command to get the currently playing {@link MediaItem}. */
int
COMMAND_GET_CURRENT_MEDIA_ITEM
=
1
5
;
int
COMMAND_GET_CURRENT_MEDIA_ITEM
=
1
6
;
/** Command to get the information about the current timeline. */
int
COMMAND_GET_TIMELINE
=
1
6
;
int
COMMAND_GET_TIMELINE
=
1
7
;
/** Command to get the {@link MediaItem MediaItems} metadata. */
int
COMMAND_GET_MEDIA_ITEMS_METADATA
=
1
7
;
int
COMMAND_GET_MEDIA_ITEMS_METADATA
=
1
8
;
/** Command to set the {@link MediaItem MediaItems} metadata. */
int
COMMAND_SET_MEDIA_ITEMS_METADATA
=
1
8
;
int
COMMAND_SET_MEDIA_ITEMS_METADATA
=
1
9
;
/** Command to change the {@link MediaItem MediaItems} in the playlist. */
int
COMMAND_CHANGE_MEDIA_ITEMS
=
19
;
int
COMMAND_CHANGE_MEDIA_ITEMS
=
20
;
/** Command to get the player current {@link AudioAttributes}. */
int
COMMAND_GET_AUDIO_ATTRIBUTES
=
2
0
;
int
COMMAND_GET_AUDIO_ATTRIBUTES
=
2
1
;
/** Command to get the player volume. */
int
COMMAND_GET_VOLUME
=
2
1
;
int
COMMAND_GET_VOLUME
=
2
2
;
/** Command to get the device volume and whether it is muted. */
int
COMMAND_GET_DEVICE_VOLUME
=
2
2
;
int
COMMAND_GET_DEVICE_VOLUME
=
2
3
;
/** Command to set the player volume. */
int
COMMAND_SET_VOLUME
=
2
3
;
int
COMMAND_SET_VOLUME
=
2
4
;
/** Command to set the device volume and mute it. */
int
COMMAND_SET_DEVICE_VOLUME
=
2
4
;
int
COMMAND_SET_DEVICE_VOLUME
=
2
5
;
/** Command to increase and decrease the device volume and mute it. */
int
COMMAND_ADJUST_DEVICE_VOLUME
=
2
5
;
int
COMMAND_ADJUST_DEVICE_VOLUME
=
2
6
;
/** Command to set and clear the surface on which to render the video. */
int
COMMAND_SET_VIDEO_SURFACE
=
2
6
;
int
COMMAND_SET_VIDEO_SURFACE
=
2
7
;
/** Command to get the text that should currently be displayed by the player. */
int
COMMAND_GET_TEXT
=
2
7
;
int
COMMAND_GET_TEXT
=
2
8
;
/** Command to set the player's track selection parameters. */
int
COMMAND_SET_TRACK_SELECTION_PARAMETERS
=
2
8
;
int
COMMAND_SET_TRACK_SELECTION_PARAMETERS
=
2
9
;
/** Command to get track infos. */
int
COMMAND_GET_TRACK_INFOS
=
29
;
int
COMMAND_GET_TRACK_INFOS
=
30
;
/** Represents an invalid {@link Command}. */
int
COMMAND_INVALID
=
-
1
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
11becc05
...
...
@@ -207,7 +207,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
new
Commands
.
Builder
()
.
addAll
(
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP
,
COMMAND_PREPARE
,
COMMAND_STOP
,
COMMAND_SET_SPEED_AND_PITCH
,
COMMAND_SET_SHUFFLE_MODE
,
COMMAND_SET_REPEAT_MODE
,
...
...
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
11becc05
...
...
@@ -26,7 +26,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_GET_TIMELINE;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_GET_TRACK_INFOS
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_GET_VOLUME
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PLAY_PAUSE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PREPARE
_STOP
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_PREPARE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_BACK
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_FORWARD
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
;
...
...
@@ -44,6 +44,7 @@ import static com.google.android.exoplayer2.Player.COMMAND_SET_SPEED_AND_PITCH;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SET_TRACK_SELECTION_PARAMETERS
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SET_VIDEO_SURFACE
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_SET_VOLUME
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
COMMAND_STOP
;
import
static
com
.
google
.
android
.
exoplayer2
.
Player
.
STATE_ENDED
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
RobolectricUtil
.
runMainLooperUntil
;
import
static
com
.
google
.
android
.
exoplayer2
.
robolectric
.
TestPlayerRunHelper
.
playUntilPosition
;
...
...
@@ -8318,7 +8319,8 @@ public final class ExoPlayerTest {
player
.
addMediaSources
(
ImmutableList
.
of
(
new
FakeMediaSource
(),
new
FakeMediaSource
()));
assertThat
(
player
.
isCommandAvailable
(
COMMAND_PLAY_PAUSE
)).
isTrue
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_PREPARE_STOP
)).
isTrue
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_PREPARE
)).
isTrue
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_STOP
)).
isTrue
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_SEEK_TO_DEFAULT_POSITION
)).
isTrue
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
)).
isFalse
();
assertThat
(
player
.
isCommandAvailable
(
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
)).
isFalse
();
...
...
@@ -11227,7 +11229,8 @@ public final class ExoPlayerTest {
Player
.
Commands
.
Builder
builder
=
new
Player
.
Commands
.
Builder
();
builder
.
addAll
(
COMMAND_PLAY_PAUSE
,
COMMAND_PREPARE_STOP
,
COMMAND_PREPARE
,
COMMAND_STOP
,
COMMAND_SEEK_TO_DEFAULT_POSITION
,
COMMAND_SEEK_TO_MEDIA_ITEM
,
COMMAND_SET_SPEED_AND_PITCH
,
...
...
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/reader/RtpPayloadReader.java
View file @
11becc05
...
...
@@ -35,8 +35,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @return A {@link RtpPayloadReader} for the packet stream, or {@code null} if the stream
* format is not supported.
*/
@Nullable
RtpPayloadReader
createPayloadReader
(
RtpPayloadFormat
payloadFormat
);
@Nullable
RtpPayloadReader
createPayloadReader
(
RtpPayloadFormat
payloadFormat
);
}
/**
...
...
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