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
e852ff1d
authored
Jul 05, 2019
by
olly
Committed by
Toni
Jul 05, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add Nullable annotations to CastPlayer
PiperOrigin-RevId: 256680382
parent
d66f0c51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
View file @
e852ff1d
...
...
@@ -83,8 +83,6 @@ public final class CastPlayer extends BasePlayer {
private
final
CastTimelineTracker
timelineTracker
;
private
final
Timeline
.
Period
period
;
private
RemoteMediaClient
remoteMediaClient
;
// Result callbacks.
private
final
StatusListener
statusListener
;
private
final
SeekResultCallback
seekResultCallback
;
...
...
@@ -93,9 +91,10 @@ public final class CastPlayer extends BasePlayer {
private
final
CopyOnWriteArrayList
<
ListenerHolder
>
listeners
;
private
final
ArrayList
<
ListenerNotificationTask
>
notificationsBatch
;
private
final
ArrayDeque
<
ListenerNotificationTask
>
ongoingNotificationsTasks
;
private
SessionAvailabilityListener
sessionAvailabilityListener
;
@Nullable
private
SessionAvailabilityListener
sessionAvailabilityListener
;
// Internal state.
@Nullable
private
RemoteMediaClient
remoteMediaClient
;
private
CastTimeline
currentTimeline
;
private
TrackGroupArray
currentTrackGroups
;
private
TrackSelectionArray
currentTrackSelection
;
...
...
@@ -148,6 +147,7 @@ public final class CastPlayer extends BasePlayer {
* starts at position 0.
* @return The Cast {@code PendingResult}, or null if no session is available.
*/
@Nullable
public
PendingResult
<
MediaChannelResult
>
loadItem
(
MediaQueueItem
item
,
long
positionMs
)
{
return
loadItems
(
new
MediaQueueItem
[]
{
item
},
0
,
positionMs
,
REPEAT_MODE_OFF
);
}
...
...
@@ -163,8 +163,9 @@ public final class CastPlayer extends BasePlayer {
* @param repeatMode The repeat mode for the created media queue.
* @return The Cast {@code PendingResult}, or null if no session is available.
*/
public
PendingResult
<
MediaChannelResult
>
loadItems
(
MediaQueueItem
[]
items
,
int
startIndex
,
long
positionMs
,
@RepeatMode
int
repeatMode
)
{
@Nullable
public
PendingResult
<
MediaChannelResult
>
loadItems
(
MediaQueueItem
[]
items
,
int
startIndex
,
long
positionMs
,
@RepeatMode
int
repeatMode
)
{
if
(
remoteMediaClient
!=
null
)
{
positionMs
=
positionMs
!=
C
.
TIME_UNSET
?
positionMs
:
0
;
waitingForInitialTimeline
=
true
;
...
...
@@ -180,6 +181,7 @@ public final class CastPlayer extends BasePlayer {
* @param items The items to append.
* @return The Cast {@code PendingResult}, or null if no media queue exists.
*/
@Nullable
public
PendingResult
<
MediaChannelResult
>
addItems
(
MediaQueueItem
...
items
)
{
return
addItems
(
MediaQueueItem
.
INVALID_ITEM_ID
,
items
);
}
...
...
@@ -194,6 +196,7 @@ public final class CastPlayer extends BasePlayer {
* @return The Cast {@code PendingResult}, or null if no media queue or no period with id {@code
* periodId} exist.
*/
@Nullable
public
PendingResult
<
MediaChannelResult
>
addItems
(
int
periodId
,
MediaQueueItem
...
items
)
{
if
(
getMediaStatus
()
!=
null
&&
(
periodId
==
MediaQueueItem
.
INVALID_ITEM_ID
||
currentTimeline
.
getIndexOfPeriod
(
periodId
)
!=
C
.
INDEX_UNSET
))
{
...
...
@@ -211,6 +214,7 @@ public final class CastPlayer extends BasePlayer {
* @return The Cast {@code PendingResult}, or null if no media queue or no period with id {@code
* periodId} exist.
*/
@Nullable
public
PendingResult
<
MediaChannelResult
>
removeItem
(
int
periodId
)
{
if
(
getMediaStatus
()
!=
null
&&
currentTimeline
.
getIndexOfPeriod
(
periodId
)
!=
C
.
INDEX_UNSET
)
{
return
remoteMediaClient
.
queueRemoveItem
(
periodId
,
null
);
...
...
@@ -229,6 +233,7 @@ public final class CastPlayer extends BasePlayer {
* @return The Cast {@code PendingResult}, or null if no media queue or no period with id {@code
* periodId} exist.
*/
@Nullable
public
PendingResult
<
MediaChannelResult
>
moveItem
(
int
periodId
,
int
newIndex
)
{
Assertions
.
checkArgument
(
newIndex
>=
0
&&
newIndex
<
currentTimeline
.
getPeriodCount
());
if
(
getMediaStatus
()
!=
null
&&
currentTimeline
.
getIndexOfPeriod
(
periodId
)
!=
C
.
INDEX_UNSET
)
{
...
...
@@ -246,6 +251,7 @@ public final class CastPlayer extends BasePlayer {
* @return The item that corresponds to the period with the given id, or null if no media queue or
* period with id {@code periodId} exist.
*/
@Nullable
public
MediaQueueItem
getItem
(
int
periodId
)
{
MediaStatus
mediaStatus
=
getMediaStatus
();
return
mediaStatus
!=
null
&&
currentTimeline
.
getIndexOfPeriod
(
periodId
)
!=
C
.
INDEX_UNSET
...
...
@@ -264,9 +270,9 @@ public final class CastPlayer extends BasePlayer {
/**
* Sets a listener for updates on the cast session availability.
*
* @param listener The {@link SessionAvailabilityListener}.
* @param listener The {@link SessionAvailabilityListener}
, or null to clear the listener
.
*/
public
void
setSessionAvailabilityListener
(
SessionAvailabilityListener
listener
)
{
public
void
setSessionAvailabilityListener
(
@Nullable
SessionAvailabilityListener
listener
)
{
sessionAvailabilityListener
=
listener
;
}
...
...
@@ -323,6 +329,7 @@ public final class CastPlayer extends BasePlayer {
}
@Override
@Nullable
public
ExoPlaybackException
getPlaybackError
()
{
return
null
;
}
...
...
@@ -530,7 +537,7 @@ public final class CastPlayer extends BasePlayer {
// Internal methods.
p
ublic
void
updateInternalState
()
{
p
rivate
void
updateInternalState
()
{
if
(
remoteMediaClient
==
null
)
{
// There is no session. We leave the state of the player as it is now.
return
;
...
...
@@ -676,7 +683,8 @@ public final class CastPlayer extends BasePlayer {
}
}
private
@Nullable
MediaStatus
getMediaStatus
()
{
@Nullable
private
MediaStatus
getMediaStatus
()
{
return
remoteMediaClient
!=
null
?
remoteMediaClient
.
getMediaStatus
()
:
null
;
}
...
...
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