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
d04ecb3c
authored
Feb 08, 2022
by
tonihei
Committed by
Ian Baker
Feb 08, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove deprecated EventListener
PiperOrigin-RevId: 427133817
parent
c381ff25
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
401 additions
and
599 deletions
RELEASENOTES.md
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java
library/common/src/main/java/com/google/android/exoplayer2/Player.java
library/common/src/test/java/com/google/android/exoplayer2/ForwardingPlayerTest.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
RELEASENOTES.md
View file @
d04ecb3c
...
@@ -159,6 +159,7 @@
...
@@ -159,6 +159,7 @@
`DefaultMediaItemConverter`
`DefaultMediaItemConverter`
(
[
#9663
](
https://github.com/google/ExoPlayer/issues/9663
)
).
(
[
#9663
](
https://github.com/google/ExoPlayer/issues/9663
)
).
*
Remove deprecated symbols:
*
Remove deprecated symbols:
*
Remove
`Player.EventLister`
. Use
`Player.Listener`
instead.
*
Remove
`MediaSourceFactory#setDrmSessionManager`
,
*
Remove
`MediaSourceFactory#setDrmSessionManager`
,
`MediaSourceFactory#setDrmHttpDataSourceFactory`
, and
`MediaSourceFactory#setDrmHttpDataSourceFactory`
, and
`MediaSourceFactory#setDrmUserAgent`
. Use
`MediaSourceFactory#setDrmUserAgent`
. Use
...
...
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java
View file @
d04ecb3c
...
@@ -135,7 +135,7 @@ public final class CastPlayer extends BasePlayer {
...
@@ -135,7 +135,7 @@ public final class CastPlayer extends BasePlayer {
private
final
SeekResultCallback
seekResultCallback
;
private
final
SeekResultCallback
seekResultCallback
;
// Listeners and notification.
// Listeners and notification.
private
final
ListenerSet
<
Player
.
Event
Listener
>
listeners
;
private
final
ListenerSet
<
Listener
>
listeners
;
@Nullable
private
SessionAvailabilityListener
sessionAvailabilityListener
;
@Nullable
private
SessionAvailabilityListener
sessionAvailabilityListener
;
// Internal state.
// Internal state.
...
@@ -278,41 +278,11 @@ public final class CastPlayer extends BasePlayer {
...
@@ -278,41 +278,11 @@ public final class CastPlayer extends BasePlayer {
@Override
@Override
public
void
addListener
(
Listener
listener
)
{
public
void
addListener
(
Listener
listener
)
{
EventListener
eventListener
=
listener
;
addListener
(
eventListener
);
}
/**
* Registers a listener to receive events from the player.
*
* <p>The listener's methods will be called on the thread associated with {@link
* #getApplicationLooper()}.
*
* @param listener The listener to register.
* @deprecated Use {@link #addListener(Listener)} and {@link #removeListener(Listener)} instead.
*/
@Deprecated
@SuppressWarnings
(
"deprecation"
)
public
void
addListener
(
EventListener
listener
)
{
listeners
.
add
(
listener
);
listeners
.
add
(
listener
);
}
}
@Override
@Override
public
void
removeListener
(
Listener
listener
)
{
public
void
removeListener
(
Listener
listener
)
{
EventListener
eventListener
=
listener
;
removeListener
(
eventListener
);
}
/**
* Unregister a listener registered through {@link #addListener(EventListener)}. The listener will
* no longer receive events from the player.
*
* @param listener The listener to unregister.
* @deprecated Use {@link #addListener(Listener)} and {@link #removeListener(Listener)} instead.
*/
@Deprecated
@SuppressWarnings
(
"deprecation"
)
public
void
removeListener
(
EventListener
listener
)
{
listeners
.
remove
(
listener
);
listeners
.
remove
(
listener
);
}
}
...
@@ -471,7 +441,7 @@ public final class CastPlayer extends BasePlayer {
...
@@ -471,7 +441,7 @@ public final class CastPlayer extends BasePlayer {
}
}
updateAvailableCommandsAndNotifyIfChanged
();
updateAvailableCommandsAndNotifyIfChanged
();
}
else
if
(
pendingSeekCount
==
0
)
{
}
else
if
(
pendingSeekCount
==
0
)
{
listeners
.
queueEvent
(
/* eventFlag= */
C
.
INDEX_UNSET
,
Event
Listener:
:
onSeekProcessed
);
listeners
.
queueEvent
(
/* eventFlag= */
C
.
INDEX_UNSET
,
Listener:
:
onSeekProcessed
);
}
}
listeners
.
flushEvents
();
listeners
.
flushEvents
();
}
}
...
@@ -1475,7 +1445,7 @@ public final class CastPlayer extends BasePlayer {
...
@@ -1475,7 +1445,7 @@ public final class CastPlayer extends BasePlayer {
currentWindowIndex
=
pendingSeekWindowIndex
;
currentWindowIndex
=
pendingSeekWindowIndex
;
pendingSeekWindowIndex
=
C
.
INDEX_UNSET
;
pendingSeekWindowIndex
=
C
.
INDEX_UNSET
;
pendingSeekPositionMs
=
C
.
TIME_UNSET
;
pendingSeekPositionMs
=
C
.
TIME_UNSET
;
listeners
.
sendEvent
(
/* eventFlag= */
C
.
INDEX_UNSET
,
Event
Listener:
:
onSeekProcessed
);
listeners
.
sendEvent
(
/* eventFlag= */
C
.
INDEX_UNSET
,
Listener:
:
onSeekProcessed
);
}
}
}
}
}
}
...
...
library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java
View file @
d04ecb3c
...
@@ -823,191 +823,159 @@ public class ForwardingPlayer implements Player {
...
@@ -823,191 +823,159 @@ public class ForwardingPlayer implements Player {
return
player
;
return
player
;
}
}
@SuppressWarnings
(
"deprecation"
)
// Use of deprecated type for backwards compatibility.
private
static
final
class
ForwardingListener
implements
Listener
{
private
static
class
ForwardingEventListener
implements
EventListener
{
private
final
ForwardingPlayer
forwardingPlayer
;
private
final
ForwardingPlayer
forwardingPlayer
;
private
final
EventListener
eventL
istener
;
private
final
Listener
l
istener
;
private
ForwardingEventListener
(
public
ForwardingListener
(
ForwardingPlayer
forwardingPlayer
,
Listener
listener
)
{
ForwardingPlayer
forwardingPlayer
,
EventListener
eventListener
)
{
this
.
forwardingPlayer
=
forwardingPlayer
;
this
.
forwardingPlayer
=
forwardingPlayer
;
this
.
eventListener
=
eventListener
;
this
.
listener
=
listener
;
}
@Override
public
void
onEvents
(
Player
player
,
Events
events
)
{
// Replace player with forwarding player.
listener
.
onEvents
(
forwardingPlayer
,
events
);
}
}
@Override
@Override
public
void
onTimelineChanged
(
Timeline
timeline
,
@TimelineChangeReason
int
reason
)
{
public
void
onTimelineChanged
(
Timeline
timeline
,
@TimelineChangeReason
int
reason
)
{
eventL
istener
.
onTimelineChanged
(
timeline
,
reason
);
l
istener
.
onTimelineChanged
(
timeline
,
reason
);
}
}
@Override
@Override
public
void
onMediaItemTransition
(
public
void
onMediaItemTransition
(
@Nullable
MediaItem
mediaItem
,
@MediaItemTransitionReason
int
reason
)
{
@Nullable
MediaItem
mediaItem
,
@MediaItemTransitionReason
int
reason
)
{
eventL
istener
.
onMediaItemTransition
(
mediaItem
,
reason
);
l
istener
.
onMediaItemTransition
(
mediaItem
,
reason
);
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
onTracksChanged
(
TrackGroupArray
trackGroups
,
TrackSelectionArray
trackSelections
)
{
public
void
onTracksChanged
(
TrackGroupArray
trackGroups
,
TrackSelectionArray
trackSelections
)
{
eventL
istener
.
onTracksChanged
(
trackGroups
,
trackSelections
);
l
istener
.
onTracksChanged
(
trackGroups
,
trackSelections
);
}
}
@Override
@Override
public
void
onTracksInfoChanged
(
TracksInfo
tracksInfo
)
{
public
void
onTracksInfoChanged
(
TracksInfo
tracksInfo
)
{
eventL
istener
.
onTracksInfoChanged
(
tracksInfo
);
l
istener
.
onTracksInfoChanged
(
tracksInfo
);
}
}
@Override
@Override
public
void
onMediaMetadataChanged
(
MediaMetadata
mediaMetadata
)
{
public
void
onMediaMetadataChanged
(
MediaMetadata
mediaMetadata
)
{
eventL
istener
.
onMediaMetadataChanged
(
mediaMetadata
);
l
istener
.
onMediaMetadataChanged
(
mediaMetadata
);
}
}
@Override
@Override
public
void
onPlaylistMetadataChanged
(
MediaMetadata
mediaMetadata
)
{
public
void
onPlaylistMetadataChanged
(
MediaMetadata
mediaMetadata
)
{
eventL
istener
.
onPlaylistMetadataChanged
(
mediaMetadata
);
l
istener
.
onPlaylistMetadataChanged
(
mediaMetadata
);
}
}
@Override
@Override
public
void
onIsLoadingChanged
(
boolean
isLoading
)
{
public
void
onIsLoadingChanged
(
boolean
isLoading
)
{
eventL
istener
.
onIsLoadingChanged
(
isLoading
);
l
istener
.
onIsLoadingChanged
(
isLoading
);
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
onLoadingChanged
(
boolean
isLoading
)
{
public
void
onLoadingChanged
(
boolean
isLoading
)
{
eventL
istener
.
onIsLoadingChanged
(
isLoading
);
l
istener
.
onIsLoadingChanged
(
isLoading
);
}
}
@Override
@Override
public
void
onAvailableCommandsChanged
(
Commands
availableCommands
)
{
public
void
onAvailableCommandsChanged
(
Commands
availableCommands
)
{
eventL
istener
.
onAvailableCommandsChanged
(
availableCommands
);
l
istener
.
onAvailableCommandsChanged
(
availableCommands
);
}
}
@Override
@Override
public
void
onTrackSelectionParametersChanged
(
TrackSelectionParameters
parameters
)
{
public
void
onTrackSelectionParametersChanged
(
TrackSelectionParameters
parameters
)
{
eventL
istener
.
onTrackSelectionParametersChanged
(
parameters
);
l
istener
.
onTrackSelectionParametersChanged
(
parameters
);
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
onPlayerStateChanged
(
boolean
playWhenReady
,
@State
int
playbackState
)
{
public
void
onPlayerStateChanged
(
boolean
playWhenReady
,
@State
int
playbackState
)
{
eventL
istener
.
onPlayerStateChanged
(
playWhenReady
,
playbackState
);
l
istener
.
onPlayerStateChanged
(
playWhenReady
,
playbackState
);
}
}
@Override
@Override
public
void
onPlaybackStateChanged
(
@State
int
playbackState
)
{
public
void
onPlaybackStateChanged
(
@State
int
playbackState
)
{
eventL
istener
.
onPlaybackStateChanged
(
playbackState
);
l
istener
.
onPlaybackStateChanged
(
playbackState
);
}
}
@Override
@Override
public
void
onPlayWhenReadyChanged
(
public
void
onPlayWhenReadyChanged
(
boolean
playWhenReady
,
@PlayWhenReadyChangeReason
int
reason
)
{
boolean
playWhenReady
,
@PlayWhenReadyChangeReason
int
reason
)
{
eventL
istener
.
onPlayWhenReadyChanged
(
playWhenReady
,
reason
);
l
istener
.
onPlayWhenReadyChanged
(
playWhenReady
,
reason
);
}
}
@Override
@Override
public
void
onPlaybackSuppressionReasonChanged
(
public
void
onPlaybackSuppressionReasonChanged
(
@PlayWhenReadyChangeReason
int
playbackSuppressionReason
)
{
@PlayWhenReadyChangeReason
int
playbackSuppressionReason
)
{
eventL
istener
.
onPlaybackSuppressionReasonChanged
(
playbackSuppressionReason
);
l
istener
.
onPlaybackSuppressionReasonChanged
(
playbackSuppressionReason
);
}
}
@Override
@Override
public
void
onIsPlayingChanged
(
boolean
isPlaying
)
{
public
void
onIsPlayingChanged
(
boolean
isPlaying
)
{
eventL
istener
.
onIsPlayingChanged
(
isPlaying
);
l
istener
.
onIsPlayingChanged
(
isPlaying
);
}
}
@Override
@Override
public
void
onRepeatModeChanged
(
@RepeatMode
int
repeatMode
)
{
public
void
onRepeatModeChanged
(
@RepeatMode
int
repeatMode
)
{
eventL
istener
.
onRepeatModeChanged
(
repeatMode
);
l
istener
.
onRepeatModeChanged
(
repeatMode
);
}
}
@Override
@Override
public
void
onShuffleModeEnabledChanged
(
boolean
shuffleModeEnabled
)
{
public
void
onShuffleModeEnabledChanged
(
boolean
shuffleModeEnabled
)
{
eventL
istener
.
onShuffleModeEnabledChanged
(
shuffleModeEnabled
);
l
istener
.
onShuffleModeEnabledChanged
(
shuffleModeEnabled
);
}
}
@Override
@Override
public
void
onPlayerError
(
PlaybackException
error
)
{
public
void
onPlayerError
(
PlaybackException
error
)
{
eventL
istener
.
onPlayerError
(
error
);
l
istener
.
onPlayerError
(
error
);
}
}
@Override
@Override
public
void
onPlayerErrorChanged
(
@Nullable
PlaybackException
error
)
{
public
void
onPlayerErrorChanged
(
@Nullable
PlaybackException
error
)
{
eventL
istener
.
onPlayerErrorChanged
(
error
);
l
istener
.
onPlayerErrorChanged
(
error
);
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
onPositionDiscontinuity
(
@DiscontinuityReason
int
reason
)
{
public
void
onPositionDiscontinuity
(
@DiscontinuityReason
int
reason
)
{
eventL
istener
.
onPositionDiscontinuity
(
reason
);
l
istener
.
onPositionDiscontinuity
(
reason
);
}
}
@Override
@Override
public
void
onPositionDiscontinuity
(
public
void
onPositionDiscontinuity
(
PositionInfo
oldPosition
,
PositionInfo
newPosition
,
@DiscontinuityReason
int
reason
)
{
PositionInfo
oldPosition
,
PositionInfo
newPosition
,
@DiscontinuityReason
int
reason
)
{
eventL
istener
.
onPositionDiscontinuity
(
oldPosition
,
newPosition
,
reason
);
l
istener
.
onPositionDiscontinuity
(
oldPosition
,
newPosition
,
reason
);
}
}
@Override
@Override
public
void
onPlaybackParametersChanged
(
PlaybackParameters
playbackParameters
)
{
public
void
onPlaybackParametersChanged
(
PlaybackParameters
playbackParameters
)
{
eventL
istener
.
onPlaybackParametersChanged
(
playbackParameters
);
l
istener
.
onPlaybackParametersChanged
(
playbackParameters
);
}
}
@Override
@Override
public
void
onSeekBackIncrementChanged
(
long
seekBackIncrementMs
)
{
public
void
onSeekBackIncrementChanged
(
long
seekBackIncrementMs
)
{
eventL
istener
.
onSeekBackIncrementChanged
(
seekBackIncrementMs
);
l
istener
.
onSeekBackIncrementChanged
(
seekBackIncrementMs
);
}
}
@Override
@Override
public
void
onSeekForwardIncrementChanged
(
long
seekForwardIncrementMs
)
{
public
void
onSeekForwardIncrementChanged
(
long
seekForwardIncrementMs
)
{
eventL
istener
.
onSeekForwardIncrementChanged
(
seekForwardIncrementMs
);
l
istener
.
onSeekForwardIncrementChanged
(
seekForwardIncrementMs
);
}
}
@Override
@Override
public
void
onMaxSeekToPreviousPositionChanged
(
long
maxSeekToPreviousPositionMs
)
{
public
void
onMaxSeekToPreviousPositionChanged
(
long
maxSeekToPreviousPositionMs
)
{
eventL
istener
.
onMaxSeekToPreviousPositionChanged
(
maxSeekToPreviousPositionMs
);
l
istener
.
onMaxSeekToPreviousPositionChanged
(
maxSeekToPreviousPositionMs
);
}
}
@Override
@Override
@SuppressWarnings
(
"deprecation"
)
public
void
onSeekProcessed
()
{
public
void
onSeekProcessed
()
{
eventListener
.
onSeekProcessed
();
listener
.
onSeekProcessed
();
}
@Override
public
void
onEvents
(
Player
player
,
Events
events
)
{
// Replace player with forwarding player.
eventListener
.
onEvents
(
forwardingPlayer
,
events
);
}
@Override
public
boolean
equals
(
@Nullable
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(!(
o
instanceof
ForwardingEventListener
))
{
return
false
;
}
ForwardingEventListener
that
=
(
ForwardingEventListener
)
o
;
if
(!
forwardingPlayer
.
equals
(
that
.
forwardingPlayer
))
{
return
false
;
}
return
eventListener
.
equals
(
that
.
eventListener
);
}
@Override
public
int
hashCode
()
{
int
result
=
forwardingPlayer
.
hashCode
();
result
=
31
*
result
+
eventListener
.
hashCode
();
return
result
;
}
}
private
static
final
class
ForwardingListener
extends
ForwardingEventListener
implements
Listener
{
private
final
Listener
listener
;
public
ForwardingListener
(
ForwardingPlayer
forwardingPlayer
,
Listener
listener
)
{
super
(
forwardingPlayer
,
listener
);
this
.
listener
=
listener
;
}
}
@Override
@Override
...
@@ -1064,5 +1032,27 @@ public class ForwardingPlayer implements Player {
...
@@ -1064,5 +1032,27 @@ public class ForwardingPlayer implements Player {
public
void
onDeviceVolumeChanged
(
int
volume
,
boolean
muted
)
{
public
void
onDeviceVolumeChanged
(
int
volume
,
boolean
muted
)
{
listener
.
onDeviceVolumeChanged
(
volume
,
muted
);
listener
.
onDeviceVolumeChanged
(
volume
,
muted
);
}
}
@Override
public
boolean
equals
(
@Nullable
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(!(
o
instanceof
ForwardingListener
))
{
return
false
;
}
ForwardingListener
that
=
(
ForwardingListener
)
o
;
if
(!
forwardingPlayer
.
equals
(
that
.
forwardingPlayer
))
{
return
false
;
}
return
listener
.
equals
(
that
.
listener
);
}
@Override
public
int
hashCode
()
{
int
result
=
forwardingPlayer
.
hashCode
();
result
=
31
*
result
+
listener
.
hashCode
();
return
result
;
}
}
}
}
}
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
d04ecb3c
...
@@ -70,341 +70,6 @@ import java.util.List;
...
@@ -70,341 +70,6 @@ import java.util.List;
*/
*/
public
interface
Player
{
public
interface
Player
{
/**
* Listener of changes in player state.
*
* <p>All methods have no-op default implementations to allow selective overrides.
*
* <p>Listeners can choose to implement individual events (e.g. {@link
* #onIsPlayingChanged(boolean)}) or {@link #onEvents(Player, Events)}, which is called after one
* or more events occurred together.
*
* @deprecated Use {@link Player.Listener}.
*/
@Deprecated
interface
EventListener
{
/**
* Called when the timeline has been refreshed.
*
* <p>Note that the current {@link MediaItem} or playback position may change as a result of a
* timeline change. If playback can't continue smoothly because of this timeline change, a
* separate {@link #onPositionDiscontinuity(PositionInfo, PositionInfo, int)} callback will be
* triggered.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param timeline The latest timeline. Never null, but may be empty.
* @param reason The {@link TimelineChangeReason} responsible for this timeline change.
*/
default
void
onTimelineChanged
(
Timeline
timeline
,
@TimelineChangeReason
int
reason
)
{}
/**
* Called when playback transitions to a media item or starts repeating a media item according
* to the current {@link #getRepeatMode() repeat mode}.
*
* <p>Note that this callback is also called when the playlist becomes non-empty or empty as a
* consequence of a playlist change.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param mediaItem The {@link MediaItem}. May be null if the playlist becomes empty.
* @param reason The reason for the transition.
*/
default
void
onMediaItemTransition
(
@Nullable
MediaItem
mediaItem
,
@MediaItemTransitionReason
int
reason
)
{}
/**
* Called when the available or selected tracks change.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param trackGroups The available tracks. Never null, but may be of length zero.
* @param trackSelections The selected tracks. Never null, but may contain null elements. A
* concrete implementation may include null elements if it has a fixed number of renderer
* components, wishes to report a TrackSelection for each of them, and has one or more
* renderer components that is not assigned any selected tracks.
* @deprecated Use {@link #onTracksInfoChanged(TracksInfo)} instead.
*/
@Deprecated
default
void
onTracksChanged
(
TrackGroupArray
trackGroups
,
TrackSelectionArray
trackSelections
)
{}
/**
* Called when the available or selected tracks change.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param tracksInfo The available tracks information. Never null, but may be of length zero.
*/
default
void
onTracksInfoChanged
(
TracksInfo
tracksInfo
)
{}
/**
* Called when the combined {@link MediaMetadata} changes.
*
* <p>The provided {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata}
* and the static and dynamic metadata from the {@link TrackSelection#getFormat(int) track
* selections' formats} and {@link Listener#onMetadata(Metadata)}. If a field is populated in
* the {@link MediaItem#mediaMetadata}, it will be prioritised above the same field coming from
* static or dynamic metadata.
*
* <p>This method may be called multiple times in quick succession.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param mediaMetadata The combined {@link MediaMetadata}.
*/
default
void
onMediaMetadataChanged
(
MediaMetadata
mediaMetadata
)
{}
/** Called when the playlist {@link MediaMetadata} changes. */
default
void
onPlaylistMetadataChanged
(
MediaMetadata
mediaMetadata
)
{}
/**
* Called when the player starts or stops loading the source.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param isLoading Whether the source is currently being loaded.
*/
default
void
onIsLoadingChanged
(
boolean
isLoading
)
{}
/** @deprecated Use {@link #onIsLoadingChanged(boolean)} instead. */
@Deprecated
default
void
onLoadingChanged
(
boolean
isLoading
)
{}
/**
* Called when the value returned from {@link #isCommandAvailable(int)} changes for at least one
* {@link Command}.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param availableCommands The available {@link Commands}.
*/
default
void
onAvailableCommandsChanged
(
Commands
availableCommands
)
{}
/**
* Called when the value returned from {@link #getTrackSelectionParameters()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param parameters The new {@link TrackSelectionParameters}.
*/
default
void
onTrackSelectionParametersChanged
(
TrackSelectionParameters
parameters
)
{}
/**
* @deprecated Use {@link #onPlaybackStateChanged(int)} and {@link
* #onPlayWhenReadyChanged(boolean, int)} instead.
*/
@Deprecated
default
void
onPlayerStateChanged
(
boolean
playWhenReady
,
@State
int
playbackState
)
{}
/**
* Called when the value returned from {@link #getPlaybackState()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playbackState The new playback {@link State state}.
*/
default
void
onPlaybackStateChanged
(
@State
int
playbackState
)
{}
/**
* Called when the value returned from {@link #getPlayWhenReady()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playWhenReady Whether playback will proceed when ready.
* @param reason The {@link PlayWhenReadyChangeReason reason} for the change.
*/
default
void
onPlayWhenReadyChanged
(
boolean
playWhenReady
,
@PlayWhenReadyChangeReason
int
reason
)
{}
/**
* Called when the value returned from {@link #getPlaybackSuppressionReason()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playbackSuppressionReason The current {@link PlaybackSuppressionReason}.
*/
default
void
onPlaybackSuppressionReasonChanged
(
@PlaybackSuppressionReason
int
playbackSuppressionReason
)
{}
/**
* Called when the value of {@link #isPlaying()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param isPlaying Whether the player is playing.
*/
default
void
onIsPlayingChanged
(
boolean
isPlaying
)
{}
/**
* Called when the value of {@link #getRepeatMode()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param repeatMode The {@link RepeatMode} used for playback.
*/
default
void
onRepeatModeChanged
(
@RepeatMode
int
repeatMode
)
{}
/**
* Called when the value of {@link #getShuffleModeEnabled()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param shuffleModeEnabled Whether shuffling of {@link MediaItem media items} is enabled.
*/
default
void
onShuffleModeEnabledChanged
(
boolean
shuffleModeEnabled
)
{}
/**
* Called when an error occurs. The playback state will transition to {@link #STATE_IDLE}
* immediately after this method is called. The player instance can still be used, and {@link
* #release()} must still be called on the player should it no longer be required.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* <p>Implementations of Player may pass an instance of a subclass of {@link PlaybackException}
* to this method in order to include more information about the error.
*
* @param error The error.
*/
default
void
onPlayerError
(
PlaybackException
error
)
{}
/**
* Called when the {@link PlaybackException} returned by {@link #getPlayerError()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* <p>Implementations of Player may pass an instance of a subclass of {@link PlaybackException}
* to this method in order to include more information about the error.
*
* @param error The new error, or null if the error is being cleared.
*/
default
void
onPlayerErrorChanged
(
@Nullable
PlaybackException
error
)
{}
/**
* @deprecated Use {@link #onPositionDiscontinuity(PositionInfo, PositionInfo, int)} instead.
*/
@Deprecated
default
void
onPositionDiscontinuity
(
@DiscontinuityReason
int
reason
)
{}
/**
* Called when a position discontinuity occurs.
*
* <p>A position discontinuity occurs when the playing period changes, the playback position
* jumps within the period currently being played, or when the playing period has been skipped
* or removed.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param oldPosition The position before the discontinuity.
* @param newPosition The position after the discontinuity.
* @param reason The {@link DiscontinuityReason} responsible for the discontinuity.
*/
default
void
onPositionDiscontinuity
(
PositionInfo
oldPosition
,
PositionInfo
newPosition
,
@DiscontinuityReason
int
reason
)
{}
/**
* Called when the current playback parameters change. The playback parameters may change due to
* a call to {@link #setPlaybackParameters(PlaybackParameters)}, or the player itself may change
* them (for example, if audio playback switches to passthrough or offload mode, where speed
* adjustment is no longer possible).
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playbackParameters The playback parameters.
*/
default
void
onPlaybackParametersChanged
(
PlaybackParameters
playbackParameters
)
{}
/**
* Called when the value of {@link #getSeekBackIncrement()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param seekBackIncrementMs The {@link #seekBack()} increment, in milliseconds.
*/
default
void
onSeekBackIncrementChanged
(
long
seekBackIncrementMs
)
{}
/**
* Called when the value of {@link #getSeekForwardIncrement()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param seekForwardIncrementMs The {@link #seekForward()} increment, in milliseconds.
*/
default
void
onSeekForwardIncrementChanged
(
long
seekForwardIncrementMs
)
{}
/**
* Called when the value of {@link #getMaxSeekToPreviousPosition()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param maxSeekToPreviousPositionMs The maximum position for which {@link #seekToPrevious()}
* seeks to the previous position, in milliseconds.
*/
default
void
onMaxSeekToPreviousPositionChanged
(
long
maxSeekToPreviousPositionMs
)
{}
/**
* @deprecated Seeks are processed without delay. Listen to {@link
* #onPositionDiscontinuity(PositionInfo, PositionInfo, int)} with reason {@link
* #DISCONTINUITY_REASON_SEEK} instead.
*/
@Deprecated
default
void
onSeekProcessed
()
{}
/**
* Called when one or more player states changed.
*
* <p>State changes and events that happen within one {@link Looper} message queue iteration are
* reported together and only after all individual callbacks were triggered.
*
* <p>Only state changes represented by {@link Event events} are reported through this method.
*
* <p>Listeners should prefer this method over individual callbacks in the following cases:
*
* <ul>
* <li>They intend to trigger the same logic for multiple events (e.g. when updating a UI for
* both {@link #onPlaybackStateChanged(int)} and {@link #onPlayWhenReadyChanged(boolean,
* int)}).
* <li>They need access to the {@link Player} object to trigger further events (e.g. to call
* {@link Player#seekTo(long)} after a {@link #onMediaItemTransition(MediaItem, int)}).
* <li>They intend to use multiple state values together or in combination with {@link Player}
* getter methods. For example using {@link #getCurrentMediaItemIndex()} with the {@code
* timeline} provided in {@link #onTimelineChanged(Timeline, int)} is only safe from
* within this method.
* <li>They are interested in events that logically happened together (e.g {@link
* #onPlaybackStateChanged(int)} to {@link #STATE_BUFFERING} because of {@link
* #onMediaItemTransition(MediaItem, int)}).
* </ul>
*
* @param player The {@link Player} whose state changed. Use the getters to obtain the latest
* states.
* @param events The {@link Events} that happened in this iteration, indicating which player
* states changed.
*/
default
void
onEvents
(
Player
player
,
Events
events
)
{}
}
/** A set of {@link Event events}. */
/** A set of {@link Event events}. */
final
class
Events
{
final
class
Events
{
...
@@ -937,62 +602,327 @@ public interface Player {
...
@@ -937,62 +602,327 @@ public interface Player {
*
*
* <p>All methods have no-op default implementations to allow selective overrides.
* <p>All methods have no-op default implementations to allow selective overrides.
*/
*/
interface
Listener
extends
EventListener
{
interface
Listener
{
@Override
/**
* Called when one or more player states changed.
*
* <p>State changes and events that happen within one {@link Looper} message queue iteration are
* reported together and only after all individual callbacks were triggered.
*
* <p>Only state changes represented by {@link Event events} are reported through this method.
*
* <p>Listeners should prefer this method over individual callbacks in the following cases:
*
* <ul>
* <li>They intend to trigger the same logic for multiple events (e.g. when updating a UI for
* both {@link #onPlaybackStateChanged(int)} and {@link #onPlayWhenReadyChanged(boolean,
* int)}).
* <li>They need access to the {@link Player} object to trigger further events (e.g. to call
* {@link Player#seekTo(long)} after a {@link #onMediaItemTransition(MediaItem, int)}).
* <li>They intend to use multiple state values together or in combination with {@link Player}
* getter methods. For example using {@link #getCurrentMediaItemIndex()} with the {@code
* timeline} provided in {@link #onTimelineChanged(Timeline, int)} is only safe from
* within this method.
* <li>They are interested in events that logically happened together (e.g {@link
* #onPlaybackStateChanged(int)} to {@link #STATE_BUFFERING} because of {@link
* #onMediaItemTransition(MediaItem, int)}).
* </ul>
*
* @param player The {@link Player} whose state changed. Use the getters to obtain the latest
* states.
* @param events The {@link Events} that happened in this iteration, indicating which player
* states changed.
*/
default
void
onEvents
(
Player
player
,
Events
events
)
{}
/**
* Called when the timeline has been refreshed.
*
* <p>Note that the current {@link MediaItem} or playback position may change as a result of a
* timeline change. If playback can't continue smoothly because of this timeline change, a
* separate {@link #onPositionDiscontinuity(PositionInfo, PositionInfo, int)} callback will be
* triggered.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param timeline The latest timeline. Never null, but may be empty.
* @param reason The {@link TimelineChangeReason} responsible for this timeline change.
*/
default
void
onTimelineChanged
(
Timeline
timeline
,
@TimelineChangeReason
int
reason
)
{}
default
void
onTimelineChanged
(
Timeline
timeline
,
@TimelineChangeReason
int
reason
)
{}
@Override
/**
* Called when playback transitions to a media item or starts repeating a media item according
* to the current {@link #getRepeatMode() repeat mode}.
*
* <p>Note that this callback is also called when the playlist becomes non-empty or empty as a
* consequence of a playlist change.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param mediaItem The {@link MediaItem}. May be null if the playlist becomes empty.
* @param reason The reason for the transition.
*/
default
void
onMediaItemTransition
(
default
void
onMediaItemTransition
(
@Nullable
MediaItem
mediaItem
,
@MediaItemTransitionReason
int
reason
)
{}
@Nullable
MediaItem
mediaItem
,
@MediaItemTransitionReason
int
reason
)
{}
@Override
/**
* Called when the available or selected tracks change.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param trackGroups The available tracks. Never null, but may be of length zero.
* @param trackSelections The selected tracks. Never null, but may contain null elements. A
* concrete implementation may include null elements if it has a fixed number of renderer
* components, wishes to report a TrackSelection for each of them, and has one or more
* renderer components that is not assigned any selected tracks.
* @deprecated Use {@link #onTracksInfoChanged(TracksInfo)} instead.
*/
@Deprecated
default
void
onTracksChanged
(
TrackGroupArray
trackGroups
,
TrackSelectionArray
trackSelections
)
{}
/**
* Called when the available or selected tracks change.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param tracksInfo The available tracks information. Never null, but may be of length zero.
*/
default
void
onTracksInfoChanged
(
TracksInfo
tracksInfo
)
{}
default
void
onTracksInfoChanged
(
TracksInfo
tracksInfo
)
{}
@Override
/**
* Called when the combined {@link MediaMetadata} changes.
*
* <p>The provided {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata}
* and the static and dynamic metadata from the {@link TrackSelection#getFormat(int) track
* selections' formats} and {@link Listener#onMetadata(Metadata)}. If a field is populated in
* the {@link MediaItem#mediaMetadata}, it will be prioritised above the same field coming from
* static or dynamic metadata.
*
* <p>This method may be called multiple times in quick succession.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param mediaMetadata The combined {@link MediaMetadata}.
*/
default
void
onMediaMetadataChanged
(
MediaMetadata
mediaMetadata
)
{}
/** Called when the playlist {@link MediaMetadata} changes. */
default
void
onPlaylistMetadataChanged
(
MediaMetadata
mediaMetadata
)
{}
/**
* Called when the player starts or stops loading the source.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param isLoading Whether the source is currently being loaded.
*/
default
void
onIsLoadingChanged
(
boolean
isLoading
)
{}
default
void
onIsLoadingChanged
(
boolean
isLoading
)
{}
@Override
/** @deprecated Use {@link #onIsLoadingChanged(boolean)} instead. */
@Deprecated
default
void
onLoadingChanged
(
boolean
isLoading
)
{}
/**
* Called when the value returned from {@link #isCommandAvailable(int)} changes for at least one
* {@link Command}.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param availableCommands The available {@link Commands}.
*/
default
void
onAvailableCommandsChanged
(
Commands
availableCommands
)
{}
default
void
onAvailableCommandsChanged
(
Commands
availableCommands
)
{}
@Override
/**
* Called when the value returned from {@link #getTrackSelectionParameters()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param parameters The new {@link TrackSelectionParameters}.
*/
default
void
onTrackSelectionParametersChanged
(
TrackSelectionParameters
parameters
)
{}
/**
* @deprecated Use {@link #onPlaybackStateChanged(int)} and {@link
* #onPlayWhenReadyChanged(boolean, int)} instead.
*/
@Deprecated
default
void
onPlayerStateChanged
(
boolean
playWhenReady
,
@State
int
playbackState
)
{}
/**
* Called when the value returned from {@link #getPlaybackState()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playbackState The new playback {@link State state}.
*/
default
void
onPlaybackStateChanged
(
@State
int
playbackState
)
{}
default
void
onPlaybackStateChanged
(
@State
int
playbackState
)
{}
@Override
/**
* Called when the value returned from {@link #getPlayWhenReady()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playWhenReady Whether playback will proceed when ready.
* @param reason The {@link PlayWhenReadyChangeReason reason} for the change.
*/
default
void
onPlayWhenReadyChanged
(
default
void
onPlayWhenReadyChanged
(
boolean
playWhenReady
,
@PlayWhenReadyChangeReason
int
reason
)
{}
boolean
playWhenReady
,
@PlayWhenReadyChangeReason
int
reason
)
{}
@Override
/**
* Called when the value returned from {@link #getPlaybackSuppressionReason()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playbackSuppressionReason The current {@link PlaybackSuppressionReason}.
*/
default
void
onPlaybackSuppressionReasonChanged
(
default
void
onPlaybackSuppressionReasonChanged
(
@PlaybackSuppressionReason
int
playbackSuppressionReason
)
{}
@PlaybackSuppressionReason
int
playbackSuppressionReason
)
{}
@Override
/**
* Called when the value of {@link #isPlaying()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param isPlaying Whether the player is playing.
*/
default
void
onIsPlayingChanged
(
boolean
isPlaying
)
{}
default
void
onIsPlayingChanged
(
boolean
isPlaying
)
{}
@Override
/**
* Called when the value of {@link #getRepeatMode()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param repeatMode The {@link RepeatMode} used for playback.
*/
default
void
onRepeatModeChanged
(
@RepeatMode
int
repeatMode
)
{}
default
void
onRepeatModeChanged
(
@RepeatMode
int
repeatMode
)
{}
@Override
/**
* Called when the value of {@link #getShuffleModeEnabled()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param shuffleModeEnabled Whether shuffling of {@link MediaItem media items} is enabled.
*/
default
void
onShuffleModeEnabledChanged
(
boolean
shuffleModeEnabled
)
{}
default
void
onShuffleModeEnabledChanged
(
boolean
shuffleModeEnabled
)
{}
@Override
/**
* Called when an error occurs. The playback state will transition to {@link #STATE_IDLE}
* immediately after this method is called. The player instance can still be used, and {@link
* #release()} must still be called on the player should it no longer be required.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* <p>Implementations of Player may pass an instance of a subclass of {@link PlaybackException}
* to this method in order to include more information about the error.
*
* @param error The error.
*/
default
void
onPlayerError
(
PlaybackException
error
)
{}
default
void
onPlayerError
(
PlaybackException
error
)
{}
@Override
/**
* Called when the {@link PlaybackException} returned by {@link #getPlayerError()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* <p>Implementations of Player may pass an instance of a subclass of {@link PlaybackException}
* to this method in order to include more information about the error.
*
* @param error The new error, or null if the error is being cleared.
*/
default
void
onPlayerErrorChanged
(
@Nullable
PlaybackException
error
)
{}
default
void
onPlayerErrorChanged
(
@Nullable
PlaybackException
error
)
{}
@Override
/**
* @deprecated Use {@link #onPositionDiscontinuity(PositionInfo, PositionInfo, int)} instead.
*/
@Deprecated
default
void
onPositionDiscontinuity
(
@DiscontinuityReason
int
reason
)
{}
/**
* Called when a position discontinuity occurs.
*
* <p>A position discontinuity occurs when the playing period changes, the playback position
* jumps within the period currently being played, or when the playing period has been skipped
* or removed.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param oldPosition The position before the discontinuity.
* @param newPosition The position after the discontinuity.
* @param reason The {@link DiscontinuityReason} responsible for the discontinuity.
*/
default
void
onPositionDiscontinuity
(
default
void
onPositionDiscontinuity
(
PositionInfo
oldPosition
,
PositionInfo
newPosition
,
@DiscontinuityReason
int
reason
)
{}
PositionInfo
oldPosition
,
PositionInfo
newPosition
,
@DiscontinuityReason
int
reason
)
{}
@Override
/**
* Called when the current playback parameters change. The playback parameters may change due to
* a call to {@link #setPlaybackParameters(PlaybackParameters)}, or the player itself may change
* them (for example, if audio playback switches to passthrough or offload mode, where speed
* adjustment is no longer possible).
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param playbackParameters The playback parameters.
*/
default
void
onPlaybackParametersChanged
(
PlaybackParameters
playbackParameters
)
{}
default
void
onPlaybackParametersChanged
(
PlaybackParameters
playbackParameters
)
{}
@Override
/**
* Called when the value of {@link #getSeekBackIncrement()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param seekBackIncrementMs The {@link #seekBack()} increment, in milliseconds.
*/
default
void
onSeekBackIncrementChanged
(
long
seekBackIncrementMs
)
{}
/**
* Called when the value of {@link #getSeekForwardIncrement()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param seekForwardIncrementMs The {@link #seekForward()} increment, in milliseconds.
*/
default
void
onSeekForwardIncrementChanged
(
long
seekForwardIncrementMs
)
{}
default
void
onSeekForwardIncrementChanged
(
long
seekForwardIncrementMs
)
{}
@Override
/**
default
void
onSeekBackIncrementChanged
(
long
seekBackIncrementMs
)
{}
* Called when the value of {@link #getMaxSeekToPreviousPosition()} changes.
*
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
* other events that happen in the same {@link Looper} message queue iteration.
*
* @param maxSeekToPreviousPositionMs The maximum position for which {@link #seekToPrevious()}
* seeks to the previous position, in milliseconds.
*/
default
void
onMaxSeekToPreviousPositionChanged
(
long
maxSeekToPreviousPositionMs
)
{}
/**
* @deprecated Seeks are processed without delay. Listen to {@link
* #onPositionDiscontinuity(PositionInfo, PositionInfo, int)} with reason {@link
* #DISCONTINUITY_REASON_SEEK} instead.
*/
@Deprecated
default
void
onSeekProcessed
()
{}
/**
/**
* Called when the audio session ID changes.
* Called when the audio session ID changes.
...
@@ -1028,9 +958,6 @@ public interface Player {
...
@@ -1028,9 +958,6 @@ public interface Player {
/** Called when the device volume or mute state changes. */
/** Called when the device volume or mute state changes. */
default
void
onDeviceVolumeChanged
(
int
volume
,
boolean
muted
)
{}
default
void
onDeviceVolumeChanged
(
int
volume
,
boolean
muted
)
{}
@Override
default
void
onEvents
(
Player
player
,
Events
events
)
{}
/**
/**
* Called each time there's a change in the size of the video being rendered.
* Called each time there's a change in the size of the video being rendered.
*
*
...
@@ -1071,12 +998,6 @@ public interface Player {
...
@@ -1071,12 +998,6 @@ public interface Player {
* @param metadata The metadata.
* @param metadata The metadata.
*/
*/
default
void
onMetadata
(
Metadata
metadata
)
{}
default
void
onMetadata
(
Metadata
metadata
)
{}
@Override
default
void
onMediaMetadataChanged
(
MediaMetadata
mediaMetadata
)
{}
@Override
default
void
onPlaylistMetadataChanged
(
MediaMetadata
mediaMetadata
)
{}
}
}
/**
/**
...
...
library/common/src/test/java/com/google/android/exoplayer2/ForwardingPlayerTest.java
View file @
d04ecb3c
...
@@ -117,21 +117,6 @@ public class ForwardingPlayerTest {
...
@@ -117,21 +117,6 @@ public class ForwardingPlayerTest {
}
}
@Test
@Test
@SuppressWarnings
(
"deprecation"
)
// Testing backwards compatibility with deprecated type.
public
void
forwardingEventListener_overridesAllEventListenerMethods
()
throws
Exception
{
// Check with reflection that ForwardingListener overrides all Listener methods.
Class
<?>
forwardingListenerClass
=
getInnerClass
(
"ForwardingEventListener"
);
List
<
Method
>
methods
=
getPublicMethods
(
Player
.
EventListener
.
class
);
for
(
int
i
=
0
;
i
<
methods
.
size
();
i
++)
{
Method
method
=
methods
.
get
(
i
);
assertThat
(
forwardingListenerClass
.
getDeclaredMethod
(
method
.
getName
(),
method
.
getParameterTypes
()))
.
isNotNull
();
}
}
@Test
public
void
forwardingListener_overridesAllListenerMethods
()
throws
Exception
{
public
void
forwardingListener_overridesAllListenerMethods
()
throws
Exception
{
// Check with reflection that ForwardingListener overrides all Listener methods.
// Check with reflection that ForwardingListener overrides all Listener methods.
Class
<?>
forwardingListenerClass
=
getInnerClass
(
"ForwardingListener"
);
Class
<?>
forwardingListenerClass
=
getInnerClass
(
"ForwardingListener"
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
View file @
d04ecb3c
...
@@ -1042,30 +1042,6 @@ public interface ExoPlayer extends Player {
...
@@ -1042,30 +1042,6 @@ public interface ExoPlayer extends Player {
DeviceComponent
getDeviceComponent
();
DeviceComponent
getDeviceComponent
();
/**
/**
* Registers a listener to receive events from the player.
*
* <p>The listener's methods will be called on the thread associated with {@link
* #getApplicationLooper()}.
*
* @param listener The listener to register.
* @deprecated Use {@link #addListener(Listener)} and {@link #removeListener(Listener)} instead.
*/
@Deprecated
@SuppressWarnings
(
"deprecation"
)
void
addListener
(
EventListener
listener
);
/**
* Unregister a listener registered through {@link #addListener(EventListener)}. The listener will
* no longer receive events from the player.
*
* @param listener The listener to unregister.
* @deprecated Use {@link #addListener(Listener)} and {@link #removeListener(Listener)} instead.
*/
@Deprecated
@SuppressWarnings
(
"deprecation"
)
void
removeListener
(
EventListener
listener
);
/**
* Adds a listener to receive audio offload events.
* Adds a listener to receive audio offload events.
*
*
* @param listener The listener to register.
* @param listener The listener to register.
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
d04ecb3c
...
@@ -97,7 +97,6 @@ import androidx.annotation.RequiresApi;
...
@@ -97,7 +97,6 @@ import androidx.annotation.RequiresApi;
import
com.google.android.exoplayer2.ExoPlayer.AudioOffloadListener
;
import
com.google.android.exoplayer2.ExoPlayer.AudioOffloadListener
;
import
com.google.android.exoplayer2.Player.Commands
;
import
com.google.android.exoplayer2.Player.Commands
;
import
com.google.android.exoplayer2.Player.DiscontinuityReason
;
import
com.google.android.exoplayer2.Player.DiscontinuityReason
;
import
com.google.android.exoplayer2.Player.EventListener
;
import
com.google.android.exoplayer2.Player.Events
;
import
com.google.android.exoplayer2.Player.Events
;
import
com.google.android.exoplayer2.Player.Listener
;
import
com.google.android.exoplayer2.Player.Listener
;
import
com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason
;
import
com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason
;
...
@@ -181,9 +180,9 @@ import java.util.concurrent.TimeoutException;
...
@@ -181,9 +180,9 @@ import java.util.concurrent.TimeoutException;
private
final
ExoPlayerImplInternal
.
PlaybackInfoUpdateListener
playbackInfoUpdateListener
;
private
final
ExoPlayerImplInternal
.
PlaybackInfoUpdateListener
playbackInfoUpdateListener
;
private
final
ExoPlayerImplInternal
internalPlayer
;
private
final
ExoPlayerImplInternal
internalPlayer
;
@SuppressWarnings
(
"deprecation"
)
// TODO(b/187152483): Merge with non-deprecated listeners.
private
final
ListenerSet
<
Listener
>
listeners
;
private
final
ListenerSet
<
Player
.
EventListener
>
eventListeners
;
// TODO(b/187152483): Remove this once all events are dispatched via ListenerSet.
private
final
CopyOnWriteArraySet
<
Listener
>
listenerArraySet
;
private
final
CopyOnWriteArraySet
<
AudioOffloadListener
>
audioOffloadListeners
;
private
final
CopyOnWriteArraySet
<
AudioOffloadListener
>
audioOffloadListeners
;
private
final
Timeline
.
Period
period
;
private
final
Timeline
.
Period
period
;
private
final
Timeline
.
Window
window
;
private
final
Timeline
.
Window
window
;
...
@@ -198,7 +197,6 @@ import java.util.concurrent.TimeoutException;
...
@@ -198,7 +197,6 @@ import java.util.concurrent.TimeoutException;
private
final
Clock
clock
;
private
final
Clock
clock
;
private
final
ComponentListener
componentListener
;
private
final
ComponentListener
componentListener
;
private
final
FrameMetadataListener
frameMetadataListener
;
private
final
FrameMetadataListener
frameMetadataListener
;
private
final
CopyOnWriteArraySet
<
Listener
>
listeners
;
private
final
AudioBecomingNoisyManager
audioBecomingNoisyManager
;
private
final
AudioBecomingNoisyManager
audioBecomingNoisyManager
;
private
final
AudioFocusManager
audioFocusManager
;
private
final
AudioFocusManager
audioFocusManager
;
private
final
StreamVolumeManager
streamVolumeManager
;
private
final
StreamVolumeManager
streamVolumeManager
;
...
@@ -284,7 +282,6 @@ import java.util.concurrent.TimeoutException;
...
@@ -284,7 +282,6 @@ import java.util.concurrent.TimeoutException;
detachSurfaceTimeoutMs
=
builder
.
detachSurfaceTimeoutMs
;
detachSurfaceTimeoutMs
=
builder
.
detachSurfaceTimeoutMs
;
componentListener
=
new
ComponentListener
();
componentListener
=
new
ComponentListener
();
frameMetadataListener
=
new
FrameMetadataListener
();
frameMetadataListener
=
new
FrameMetadataListener
();
listeners
=
new
CopyOnWriteArraySet
<>();
Handler
eventHandler
=
new
Handler
(
builder
.
looper
);
Handler
eventHandler
=
new
Handler
(
builder
.
looper
);
renderers
=
renderers
=
builder
builder
...
@@ -308,11 +305,12 @@ import java.util.concurrent.TimeoutException;
...
@@ -308,11 +305,12 @@ import java.util.concurrent.TimeoutException;
this
.
applicationLooper
=
builder
.
looper
;
this
.
applicationLooper
=
builder
.
looper
;
this
.
clock
=
builder
.
clock
;
this
.
clock
=
builder
.
clock
;
this
.
wrappingPlayer
=
wrappingPlayer
;
this
.
wrappingPlayer
=
wrappingPlayer
;
eventL
isteners
=
l
isteners
=
new
ListenerSet
<>(
new
ListenerSet
<>(
applicationLooper
,
applicationLooper
,
clock
,
clock
,
(
listener
,
flags
)
->
listener
.
onEvents
(
wrappingPlayer
,
new
Events
(
flags
)));
(
listener
,
flags
)
->
listener
.
onEvents
(
wrappingPlayer
,
new
Events
(
flags
)));
listenerArraySet
=
new
CopyOnWriteArraySet
<>();
audioOffloadListeners
=
new
CopyOnWriteArraySet
<>();
audioOffloadListeners
=
new
CopyOnWriteArraySet
<>();
mediaSourceHolderSnapshots
=
new
ArrayList
<>();
mediaSourceHolderSnapshots
=
new
ArrayList
<>();
shuffleOrder
=
new
ShuffleOrder
.
DefaultShuffleOrder
(
/* length= */
0
);
shuffleOrder
=
new
ShuffleOrder
.
DefaultShuffleOrder
(
/* length= */
0
);
...
@@ -400,9 +398,9 @@ import java.util.concurrent.TimeoutException;
...
@@ -400,9 +398,9 @@ import java.util.concurrent.TimeoutException;
currentCues
=
ImmutableList
.
of
();
currentCues
=
ImmutableList
.
of
();
throwsWhenUsingWrongThread
=
true
;
throwsWhenUsingWrongThread
=
true
;
addEventListener
(
analyticsCollector
);
listeners
.
add
(
analyticsCollector
);
bandwidthMeter
.
addEventListener
(
new
Handler
(
applicationLooper
),
analyticsCollector
);
bandwidthMeter
.
addEventListener
(
new
Handler
(
applicationLooper
),
analyticsCollector
);
addEventListener
(
componentListener
);
listeners
.
add
(
componentListener
);
addAudioOffloadListener
(
componentListener
);
addAudioOffloadListener
(
componentListener
);
if
(
builder
.
foregroundModeTimeoutMs
>
0
)
{
if
(
builder
.
foregroundModeTimeoutMs
>
0
)
{
experimentalSetForegroundModeTimeoutMs
(
builder
.
foregroundModeTimeoutMs
);
experimentalSetForegroundModeTimeoutMs
(
builder
.
foregroundModeTimeoutMs
);
...
@@ -478,18 +476,6 @@ import java.util.concurrent.TimeoutException;
...
@@ -478,18 +476,6 @@ import java.util.concurrent.TimeoutException;
return
clock
;
return
clock
;
}
}
@SuppressWarnings
(
"deprecation"
)
// Register deprecated EventListener.
public
void
addEventListener
(
Player
.
EventListener
eventListener
)
{
// Don't verify application thread. We allow calls to this method from any thread.
eventListeners
.
add
(
eventListener
);
}
@SuppressWarnings
(
"deprecation"
)
// Deregister deprecated EventListener.
public
void
removeEventListener
(
Player
.
EventListener
eventListener
)
{
// Don't verify application thread. We allow calls to this method from any thread.
eventListeners
.
remove
(
eventListener
);
}
public
void
addAudioOffloadListener
(
AudioOffloadListener
listener
)
{
public
void
addAudioOffloadListener
(
AudioOffloadListener
listener
)
{
// Don't verify application thread. We allow calls to this method from any thread.
// Don't verify application thread. We allow calls to this method from any thread.
audioOffloadListeners
.
add
(
listener
);
audioOffloadListeners
.
add
(
listener
);
...
@@ -795,10 +781,10 @@ import java.util.concurrent.TimeoutException;
...
@@ -795,10 +781,10 @@ import java.util.concurrent.TimeoutException;
if
(
this
.
repeatMode
!=
repeatMode
)
{
if
(
this
.
repeatMode
!=
repeatMode
)
{
this
.
repeatMode
=
repeatMode
;
this
.
repeatMode
=
repeatMode
;
internalPlayer
.
setRepeatMode
(
repeatMode
);
internalPlayer
.
setRepeatMode
(
repeatMode
);
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_REPEAT_MODE_CHANGED
,
listener
->
listener
.
onRepeatModeChanged
(
repeatMode
));
Player
.
EVENT_REPEAT_MODE_CHANGED
,
listener
->
listener
.
onRepeatModeChanged
(
repeatMode
));
updateAvailableCommands
();
updateAvailableCommands
();
eventL
isteners
.
flushEvents
();
l
isteners
.
flushEvents
();
}
}
}
}
...
@@ -812,11 +798,11 @@ import java.util.concurrent.TimeoutException;
...
@@ -812,11 +798,11 @@ import java.util.concurrent.TimeoutException;
if
(
this
.
shuffleModeEnabled
!=
shuffleModeEnabled
)
{
if
(
this
.
shuffleModeEnabled
!=
shuffleModeEnabled
)
{
this
.
shuffleModeEnabled
=
shuffleModeEnabled
;
this
.
shuffleModeEnabled
=
shuffleModeEnabled
;
internalPlayer
.
setShuffleModeEnabled
(
shuffleModeEnabled
);
internalPlayer
.
setShuffleModeEnabled
(
shuffleModeEnabled
);
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
,
Player
.
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
,
listener
->
listener
.
onShuffleModeEnabledChanged
(
shuffleModeEnabled
));
listener
->
listener
.
onShuffleModeEnabledChanged
(
shuffleModeEnabled
));
updateAvailableCommands
();
updateAvailableCommands
();
eventL
isteners
.
flushEvents
();
l
isteners
.
flushEvents
();
}
}
}
}
...
@@ -1018,7 +1004,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1018,7 +1004,7 @@ import java.util.concurrent.TimeoutException;
audioFocusManager
.
release
();
audioFocusManager
.
release
();
if
(!
internalPlayer
.
release
())
{
if
(!
internalPlayer
.
release
())
{
// One of the renderers timed out releasing its resources.
// One of the renderers timed out releasing its resources.
eventL
isteners
.
sendEvent
(
l
isteners
.
sendEvent
(
Player
.
EVENT_PLAYER_ERROR
,
Player
.
EVENT_PLAYER_ERROR
,
listener
->
listener
->
listener
.
onPlayerError
(
listener
.
onPlayerError
(
...
@@ -1026,7 +1012,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1026,7 +1012,7 @@ import java.util.concurrent.TimeoutException;
new
ExoTimeoutException
(
ExoTimeoutException
.
TIMEOUT_OPERATION_RELEASE
),
new
ExoTimeoutException
(
ExoTimeoutException
.
TIMEOUT_OPERATION_RELEASE
),
PlaybackException
.
ERROR_CODE_TIMEOUT
)));
PlaybackException
.
ERROR_CODE_TIMEOUT
)));
}
}
eventL
isteners
.
release
();
l
isteners
.
release
();
playbackInfoUpdateHandler
.
removeCallbacksAndMessages
(
null
);
playbackInfoUpdateHandler
.
removeCallbacksAndMessages
(
null
);
bandwidthMeter
.
removeEventListener
(
analyticsCollector
);
bandwidthMeter
.
removeEventListener
(
analyticsCollector
);
playbackInfo
=
playbackInfo
.
copyWithPlaybackState
(
Player
.
STATE_IDLE
);
playbackInfo
=
playbackInfo
.
copyWithPlaybackState
(
Player
.
STATE_IDLE
);
...
@@ -1206,7 +1192,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1206,7 +1192,7 @@ import java.util.concurrent.TimeoutException;
return
;
return
;
}
}
trackSelector
.
setParameters
(
parameters
);
trackSelector
.
setParameters
(
parameters
);
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
EVENT_TRACK_SELECTION_PARAMETERS_CHANGED
,
EVENT_TRACK_SELECTION_PARAMETERS_CHANGED
,
listener
->
listener
.
onTrackSelectionParametersChanged
(
parameters
));
listener
->
listener
.
onTrackSelectionParametersChanged
(
parameters
));
}
}
...
@@ -1226,7 +1212,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1226,7 +1212,7 @@ import java.util.concurrent.TimeoutException;
return
;
return
;
}
}
mediaMetadata
=
newMediaMetadata
;
mediaMetadata
=
newMediaMetadata
;
eventL
isteners
.
sendEvent
(
l
isteners
.
sendEvent
(
EVENT_MEDIA_METADATA_CHANGED
,
listener
->
listener
.
onMediaMetadataChanged
(
mediaMetadata
));
EVENT_MEDIA_METADATA_CHANGED
,
listener
->
listener
.
onMediaMetadataChanged
(
mediaMetadata
));
}
}
...
@@ -1242,7 +1228,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1242,7 +1228,7 @@ import java.util.concurrent.TimeoutException;
return
;
return
;
}
}
this
.
playlistMetadata
=
playlistMetadata
;
this
.
playlistMetadata
=
playlistMetadata
;
eventL
isteners
.
sendEvent
(
l
isteners
.
sendEvent
(
EVENT_PLAYLIST_METADATA_CHANGED
,
EVENT_PLAYLIST_METADATA_CHANGED
,
listener
->
listener
.
onPlaylistMetadataChanged
(
this
.
playlistMetadata
));
listener
->
listener
.
onPlaylistMetadataChanged
(
this
.
playlistMetadata
));
}
}
...
@@ -1399,7 +1385,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1399,7 +1385,7 @@ import java.util.concurrent.TimeoutException;
streamVolumeManager
.
setStreamType
(
Util
.
getStreamTypeForAudioUsage
(
audioAttributes
.
usage
));
streamVolumeManager
.
setStreamType
(
Util
.
getStreamTypeForAudioUsage
(
audioAttributes
.
usage
));
analyticsCollector
.
onAudioAttributesChanged
(
audioAttributes
);
analyticsCollector
.
onAudioAttributesChanged
(
audioAttributes
);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onAudioAttributesChanged
(
audioAttributes
);
listener
.
onAudioAttributesChanged
(
audioAttributes
);
}
}
}
}
...
@@ -1437,7 +1423,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1437,7 +1423,7 @@ import java.util.concurrent.TimeoutException;
sendRendererMessage
(
TRACK_TYPE_VIDEO
,
MSG_SET_AUDIO_SESSION_ID
,
audioSessionId
);
sendRendererMessage
(
TRACK_TYPE_VIDEO
,
MSG_SET_AUDIO_SESSION_ID
,
audioSessionId
);
analyticsCollector
.
onAudioSessionIdChanged
(
audioSessionId
);
analyticsCollector
.
onAudioSessionIdChanged
(
audioSessionId
);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onAudioSessionIdChanged
(
audioSessionId
);
listener
.
onAudioSessionIdChanged
(
audioSessionId
);
}
}
}
}
...
@@ -1465,7 +1451,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1465,7 +1451,7 @@ import java.util.concurrent.TimeoutException;
sendVolumeToRenderers
();
sendVolumeToRenderers
();
analyticsCollector
.
onVolumeChanged
(
volume
);
analyticsCollector
.
onVolumeChanged
(
volume
);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onVolumeChanged
(
volume
);
listener
.
onVolumeChanged
(
volume
);
}
}
}
}
...
@@ -1597,14 +1583,14 @@ import java.util.concurrent.TimeoutException;
...
@@ -1597,14 +1583,14 @@ import java.util.concurrent.TimeoutException;
// Don't verify application thread. We allow calls to this method from any thread.
// Don't verify application thread. We allow calls to this method from any thread.
checkNotNull
(
listener
);
checkNotNull
(
listener
);
listeners
.
add
(
listener
);
listeners
.
add
(
listener
);
addEventListener
(
listener
);
listenerArraySet
.
add
(
listener
);
}
}
public
void
removeListener
(
Listener
listener
)
{
public
void
removeListener
(
Listener
listener
)
{
// Don't verify application thread. We allow calls to this method from any thread.
// Don't verify application thread. We allow calls to this method from any thread.
checkNotNull
(
listener
);
checkNotNull
(
listener
);
listeners
.
remove
(
listener
);
listeners
.
remove
(
listener
);
removeEventListener
(
listener
);
listenerArraySet
.
remove
(
listener
);
}
}
public
void
setHandleWakeLock
(
boolean
handleWakeLock
)
{
public
void
setHandleWakeLock
(
boolean
handleWakeLock
)
{
...
@@ -1805,7 +1791,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1805,7 +1791,7 @@ import java.util.concurrent.TimeoutException;
mediaMetadata
=
newMediaMetadata
;
mediaMetadata
=
newMediaMetadata
;
if
(!
previousPlaybackInfo
.
timeline
.
equals
(
newPlaybackInfo
.
timeline
))
{
if
(!
previousPlaybackInfo
.
timeline
.
equals
(
newPlaybackInfo
.
timeline
))
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_TIMELINE_CHANGED
,
Player
.
EVENT_TIMELINE_CHANGED
,
listener
->
listener
.
onTimelineChanged
(
newPlaybackInfo
.
timeline
,
timelineChangeReason
));
listener
->
listener
.
onTimelineChanged
(
newPlaybackInfo
.
timeline
,
timelineChangeReason
));
}
}
...
@@ -1814,7 +1800,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -1814,7 +1800,7 @@ import java.util.concurrent.TimeoutException;
getPreviousPositionInfo
(
getPreviousPositionInfo
(
positionDiscontinuityReason
,
previousPlaybackInfo
,
oldMaskingMediaItemIndex
);
positionDiscontinuityReason
,
previousPlaybackInfo
,
oldMaskingMediaItemIndex
);
PositionInfo
positionInfo
=
getPositionInfo
(
discontinuityWindowStartPositionUs
);
PositionInfo
positionInfo
=
getPositionInfo
(
discontinuityWindowStartPositionUs
);
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_POSITION_DISCONTINUITY
,
Player
.
EVENT_POSITION_DISCONTINUITY
,
listener
->
{
listener
->
{
listener
.
onPositionDiscontinuity
(
positionDiscontinuityReason
);
listener
.
onPositionDiscontinuity
(
positionDiscontinuityReason
);
...
@@ -1824,16 +1810,16 @@ import java.util.concurrent.TimeoutException;
...
@@ -1824,16 +1810,16 @@ import java.util.concurrent.TimeoutException;
}
}
if
(
mediaItemTransitioned
)
{
if
(
mediaItemTransitioned
)
{
@Nullable
final
MediaItem
finalMediaItem
=
mediaItem
;
@Nullable
final
MediaItem
finalMediaItem
=
mediaItem
;
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_MEDIA_ITEM_TRANSITION
,
Player
.
EVENT_MEDIA_ITEM_TRANSITION
,
listener
->
listener
.
onMediaItemTransition
(
finalMediaItem
,
mediaItemTransitionReason
));
listener
->
listener
.
onMediaItemTransition
(
finalMediaItem
,
mediaItemTransitionReason
));
}
}
if
(
previousPlaybackInfo
.
playbackError
!=
newPlaybackInfo
.
playbackError
)
{
if
(
previousPlaybackInfo
.
playbackError
!=
newPlaybackInfo
.
playbackError
)
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_PLAYER_ERROR
,
Player
.
EVENT_PLAYER_ERROR
,
listener
->
listener
.
onPlayerErrorChanged
(
newPlaybackInfo
.
playbackError
));
listener
->
listener
.
onPlayerErrorChanged
(
newPlaybackInfo
.
playbackError
));
if
(
newPlaybackInfo
.
playbackError
!=
null
)
{
if
(
newPlaybackInfo
.
playbackError
!=
null
)
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_PLAYER_ERROR
,
Player
.
EVENT_PLAYER_ERROR
,
listener
->
listener
.
onPlayerError
(
newPlaybackInfo
.
playbackError
));
listener
->
listener
.
onPlayerError
(
newPlaybackInfo
.
playbackError
));
}
}
...
@@ -1842,21 +1828,21 @@ import java.util.concurrent.TimeoutException;
...
@@ -1842,21 +1828,21 @@ import java.util.concurrent.TimeoutException;
trackSelector
.
onSelectionActivated
(
newPlaybackInfo
.
trackSelectorResult
.
info
);
trackSelector
.
onSelectionActivated
(
newPlaybackInfo
.
trackSelectorResult
.
info
);
TrackSelectionArray
newSelection
=
TrackSelectionArray
newSelection
=
new
TrackSelectionArray
(
newPlaybackInfo
.
trackSelectorResult
.
selections
);
new
TrackSelectionArray
(
newPlaybackInfo
.
trackSelectorResult
.
selections
);
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_TRACKS_CHANGED
,
Player
.
EVENT_TRACKS_CHANGED
,
listener
->
listener
.
onTracksChanged
(
newPlaybackInfo
.
trackGroups
,
newSelection
));
listener
->
listener
.
onTracksChanged
(
newPlaybackInfo
.
trackGroups
,
newSelection
));
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_TRACKS_CHANGED
,
Player
.
EVENT_TRACKS_CHANGED
,
listener
->
listener
.
onTracksInfoChanged
(
newPlaybackInfo
.
trackSelectorResult
.
tracksInfo
));
listener
->
listener
.
onTracksInfoChanged
(
newPlaybackInfo
.
trackSelectorResult
.
tracksInfo
));
}
}
if
(
metadataChanged
)
{
if
(
metadataChanged
)
{
final
MediaMetadata
finalMediaMetadata
=
mediaMetadata
;
final
MediaMetadata
finalMediaMetadata
=
mediaMetadata
;
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
EVENT_MEDIA_METADATA_CHANGED
,
EVENT_MEDIA_METADATA_CHANGED
,
listener
->
listener
.
onMediaMetadataChanged
(
finalMediaMetadata
));
listener
->
listener
.
onMediaMetadataChanged
(
finalMediaMetadata
));
}
}
if
(
previousPlaybackInfo
.
isLoading
!=
newPlaybackInfo
.
isLoading
)
{
if
(
previousPlaybackInfo
.
isLoading
!=
newPlaybackInfo
.
isLoading
)
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_IS_LOADING_CHANGED
,
Player
.
EVENT_IS_LOADING_CHANGED
,
listener
->
{
listener
->
{
listener
.
onLoadingChanged
(
newPlaybackInfo
.
isLoading
);
listener
.
onLoadingChanged
(
newPlaybackInfo
.
isLoading
);
...
@@ -1865,19 +1851,19 @@ import java.util.concurrent.TimeoutException;
...
@@ -1865,19 +1851,19 @@ import java.util.concurrent.TimeoutException;
}
}
if
(
previousPlaybackInfo
.
playbackState
!=
newPlaybackInfo
.
playbackState
if
(
previousPlaybackInfo
.
playbackState
!=
newPlaybackInfo
.
playbackState
||
previousPlaybackInfo
.
playWhenReady
!=
newPlaybackInfo
.
playWhenReady
)
{
||
previousPlaybackInfo
.
playWhenReady
!=
newPlaybackInfo
.
playWhenReady
)
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
/* eventFlag= */
C
.
INDEX_UNSET
,
/* eventFlag= */
C
.
INDEX_UNSET
,
listener
->
listener
->
listener
.
onPlayerStateChanged
(
listener
.
onPlayerStateChanged
(
newPlaybackInfo
.
playWhenReady
,
newPlaybackInfo
.
playbackState
));
newPlaybackInfo
.
playWhenReady
,
newPlaybackInfo
.
playbackState
));
}
}
if
(
previousPlaybackInfo
.
playbackState
!=
newPlaybackInfo
.
playbackState
)
{
if
(
previousPlaybackInfo
.
playbackState
!=
newPlaybackInfo
.
playbackState
)
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_PLAYBACK_STATE_CHANGED
,
Player
.
EVENT_PLAYBACK_STATE_CHANGED
,
listener
->
listener
.
onPlaybackStateChanged
(
newPlaybackInfo
.
playbackState
));
listener
->
listener
.
onPlaybackStateChanged
(
newPlaybackInfo
.
playbackState
));
}
}
if
(
previousPlaybackInfo
.
playWhenReady
!=
newPlaybackInfo
.
playWhenReady
)
{
if
(
previousPlaybackInfo
.
playWhenReady
!=
newPlaybackInfo
.
playWhenReady
)
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_PLAY_WHEN_READY_CHANGED
,
Player
.
EVENT_PLAY_WHEN_READY_CHANGED
,
listener
->
listener
->
listener
.
onPlayWhenReadyChanged
(
listener
.
onPlayWhenReadyChanged
(
...
@@ -1885,27 +1871,27 @@ import java.util.concurrent.TimeoutException;
...
@@ -1885,27 +1871,27 @@ import java.util.concurrent.TimeoutException;
}
}
if
(
previousPlaybackInfo
.
playbackSuppressionReason
if
(
previousPlaybackInfo
.
playbackSuppressionReason
!=
newPlaybackInfo
.
playbackSuppressionReason
)
{
!=
newPlaybackInfo
.
playbackSuppressionReason
)
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED
,
Player
.
EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED
,
listener
->
listener
->
listener
.
onPlaybackSuppressionReasonChanged
(
listener
.
onPlaybackSuppressionReasonChanged
(
newPlaybackInfo
.
playbackSuppressionReason
));
newPlaybackInfo
.
playbackSuppressionReason
));
}
}
if
(
isPlaying
(
previousPlaybackInfo
)
!=
isPlaying
(
newPlaybackInfo
))
{
if
(
isPlaying
(
previousPlaybackInfo
)
!=
isPlaying
(
newPlaybackInfo
))
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_IS_PLAYING_CHANGED
,
Player
.
EVENT_IS_PLAYING_CHANGED
,
listener
->
listener
.
onIsPlayingChanged
(
isPlaying
(
newPlaybackInfo
)));
listener
->
listener
.
onIsPlayingChanged
(
isPlaying
(
newPlaybackInfo
)));
}
}
if
(!
previousPlaybackInfo
.
playbackParameters
.
equals
(
newPlaybackInfo
.
playbackParameters
))
{
if
(!
previousPlaybackInfo
.
playbackParameters
.
equals
(
newPlaybackInfo
.
playbackParameters
))
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_PLAYBACK_PARAMETERS_CHANGED
,
Player
.
EVENT_PLAYBACK_PARAMETERS_CHANGED
,
listener
->
listener
.
onPlaybackParametersChanged
(
newPlaybackInfo
.
playbackParameters
));
listener
->
listener
.
onPlaybackParametersChanged
(
newPlaybackInfo
.
playbackParameters
));
}
}
if
(
seekProcessed
)
{
if
(
seekProcessed
)
{
eventListeners
.
queueEvent
(
/* eventFlag= */
C
.
INDEX_UNSET
,
Event
Listener:
:
onSeekProcessed
);
listeners
.
queueEvent
(
/* eventFlag= */
C
.
INDEX_UNSET
,
Listener:
:
onSeekProcessed
);
}
}
updateAvailableCommands
();
updateAvailableCommands
();
eventL
isteners
.
flushEvents
();
l
isteners
.
flushEvents
();
if
(
previousPlaybackInfo
.
offloadSchedulingEnabled
!=
newPlaybackInfo
.
offloadSchedulingEnabled
)
{
if
(
previousPlaybackInfo
.
offloadSchedulingEnabled
!=
newPlaybackInfo
.
offloadSchedulingEnabled
)
{
for
(
AudioOffloadListener
listener
:
audioOffloadListeners
)
{
for
(
AudioOffloadListener
listener
:
audioOffloadListeners
)
{
...
@@ -2062,7 +2048,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2062,7 +2048,7 @@ import java.util.concurrent.TimeoutException;
Commands
previousAvailableCommands
=
availableCommands
;
Commands
previousAvailableCommands
=
availableCommands
;
availableCommands
=
Util
.
getAvailableCommands
(
wrappingPlayer
,
permanentAvailableCommands
);
availableCommands
=
Util
.
getAvailableCommands
(
wrappingPlayer
,
permanentAvailableCommands
);
if
(!
availableCommands
.
equals
(
previousAvailableCommands
))
{
if
(!
availableCommands
.
equals
(
previousAvailableCommands
))
{
eventL
isteners
.
queueEvent
(
l
isteners
.
queueEvent
(
Player
.
EVENT_AVAILABLE_COMMANDS_CHANGED
,
Player
.
EVENT_AVAILABLE_COMMANDS_CHANGED
,
listener
->
listener
.
onAvailableCommandsChanged
(
availableCommands
));
listener
->
listener
.
onAvailableCommandsChanged
(
availableCommands
));
}
}
...
@@ -2482,7 +2468,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2482,7 +2468,7 @@ import java.util.concurrent.TimeoutException;
surfaceHeight
=
height
;
surfaceHeight
=
height
;
analyticsCollector
.
onSurfaceSizeChanged
(
width
,
height
);
analyticsCollector
.
onSurfaceSizeChanged
(
width
,
height
);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onSurfaceSizeChanged
(
width
,
height
);
listener
.
onSurfaceSizeChanged
(
width
,
height
);
}
}
}
}
...
@@ -2496,7 +2482,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2496,7 +2482,7 @@ import java.util.concurrent.TimeoutException;
private
void
notifySkipSilenceEnabledChanged
()
{
private
void
notifySkipSilenceEnabledChanged
()
{
analyticsCollector
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
analyticsCollector
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
listener
.
onSkipSilenceEnabledChanged
(
skipSilenceEnabled
);
}
}
}
}
...
@@ -2638,10 +2624,9 @@ import java.util.concurrent.TimeoutException;
...
@@ -2638,10 +2624,9 @@ import java.util.concurrent.TimeoutException;
}
}
}
}
// TODO(b/204189802): Remove self-listening to deprecated EventListener.
@SuppressWarnings
(
"deprecation"
)
private
final
class
ComponentListener
private
final
class
ComponentListener
implements
VideoRendererEventListener
,
implements
Player
.
Listener
,
VideoRendererEventListener
,
AudioRendererEventListener
,
AudioRendererEventListener
,
TextOutput
,
TextOutput
,
MetadataOutput
,
MetadataOutput
,
...
@@ -2651,7 +2636,6 @@ import java.util.concurrent.TimeoutException;
...
@@ -2651,7 +2636,6 @@ import java.util.concurrent.TimeoutException;
AudioFocusManager
.
PlayerControl
,
AudioFocusManager
.
PlayerControl
,
AudioBecomingNoisyManager
.
EventListener
,
AudioBecomingNoisyManager
.
EventListener
,
StreamVolumeManager
.
Listener
,
StreamVolumeManager
.
Listener
,
Player
.
EventListener
,
AudioOffloadListener
{
AudioOffloadListener
{
// VideoRendererEventListener implementation
// VideoRendererEventListener implementation
...
@@ -2686,7 +2670,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2686,7 +2670,7 @@ import java.util.concurrent.TimeoutException;
ExoPlayerImpl
.
this
.
videoSize
=
videoSize
;
ExoPlayerImpl
.
this
.
videoSize
=
videoSize
;
analyticsCollector
.
onVideoSizeChanged
(
videoSize
);
analyticsCollector
.
onVideoSizeChanged
(
videoSize
);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onVideoSizeChanged
(
videoSize
);
listener
.
onVideoSizeChanged
(
videoSize
);
}
}
}
}
...
@@ -2696,7 +2680,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2696,7 +2680,7 @@ import java.util.concurrent.TimeoutException;
analyticsCollector
.
onRenderedFirstFrame
(
output
,
renderTimeMs
);
analyticsCollector
.
onRenderedFirstFrame
(
output
,
renderTimeMs
);
if
(
videoOutput
==
output
)
{
if
(
videoOutput
==
output
)
{
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onRenderedFirstFrame
();
listener
.
onRenderedFirstFrame
();
}
}
}
}
...
@@ -2793,7 +2777,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2793,7 +2777,7 @@ import java.util.concurrent.TimeoutException;
public
void
onCues
(
List
<
Cue
>
cues
)
{
public
void
onCues
(
List
<
Cue
>
cues
)
{
currentCues
=
cues
;
currentCues
=
cues
;
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listeners
:
listener
s
)
{
for
(
Listener
listeners
:
listener
ArraySet
)
{
listeners
.
onCues
(
cues
);
listeners
.
onCues
(
cues
);
}
}
}
}
...
@@ -2805,7 +2789,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2805,7 +2789,7 @@ import java.util.concurrent.TimeoutException;
analyticsCollector
.
onMetadata
(
metadata
);
analyticsCollector
.
onMetadata
(
metadata
);
ExoPlayerImpl
.
this
.
onMetadata
(
metadata
);
ExoPlayerImpl
.
this
.
onMetadata
(
metadata
);
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onMetadata
(
metadata
);
listener
.
onMetadata
(
metadata
);
}
}
}
}
...
@@ -2901,7 +2885,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -2901,7 +2885,7 @@ import java.util.concurrent.TimeoutException;
if
(!
deviceInfo
.
equals
(
ExoPlayerImpl
.
this
.
deviceInfo
))
{
if
(!
deviceInfo
.
equals
(
ExoPlayerImpl
.
this
.
deviceInfo
))
{
ExoPlayerImpl
.
this
.
deviceInfo
=
deviceInfo
;
ExoPlayerImpl
.
this
.
deviceInfo
=
deviceInfo
;
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onDeviceInfoChanged
(
deviceInfo
);
listener
.
onDeviceInfoChanged
(
deviceInfo
);
}
}
}
}
...
@@ -2910,12 +2894,12 @@ import java.util.concurrent.TimeoutException;
...
@@ -2910,12 +2894,12 @@ import java.util.concurrent.TimeoutException;
@Override
@Override
public
void
onStreamVolumeChanged
(
int
streamVolume
,
boolean
streamMuted
)
{
public
void
onStreamVolumeChanged
(
int
streamVolume
,
boolean
streamMuted
)
{
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
for
(
Listener
listener
:
listener
s
)
{
for
(
Listener
listener
:
listener
ArraySet
)
{
listener
.
onDeviceVolumeChanged
(
streamVolume
,
streamMuted
);
listener
.
onDeviceVolumeChanged
(
streamVolume
,
streamMuted
);
}
}
}
}
// Player.
Event
Listener implementation.
// Player.Listener implementation.
@Override
@Override
public
void
onIsLoadingChanged
(
boolean
isLoading
)
{
public
void
onIsLoadingChanged
(
boolean
isLoading
)
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
View file @
d04ecb3c
...
@@ -661,26 +661,12 @@ public class SimpleExoPlayer extends BasePlayer
...
@@ -661,26 +661,12 @@ public class SimpleExoPlayer extends BasePlayer
player
.
addListener
(
listener
);
player
.
addListener
(
listener
);
}
}
@Deprecated
@Override
public
void
addListener
(
Player
.
EventListener
listener
)
{
blockUntilConstructorFinished
();
player
.
addEventListener
(
listener
);
}
@Override
@Override
public
void
removeListener
(
Listener
listener
)
{
public
void
removeListener
(
Listener
listener
)
{
blockUntilConstructorFinished
();
blockUntilConstructorFinished
();
player
.
removeListener
(
listener
);
player
.
removeListener
(
listener
);
}
}
@Deprecated
@Override
public
void
removeListener
(
Player
.
EventListener
listener
)
{
blockUntilConstructorFinished
();
player
.
removeEventListener
(
listener
);
}
@Override
@Override
public
@State
int
getPlaybackState
()
{
public
@State
int
getPlaybackState
()
{
blockUntilConstructorFinished
();
blockUntilConstructorFinished
();
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
View file @
d04ecb3c
...
@@ -20,7 +20,6 @@ import androidx.annotation.Nullable;
...
@@ -20,7 +20,6 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.ExoPlaybackException
;
import
com.google.android.exoplayer2.ExoPlaybackException
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.PlayerMessage
;
import
com.google.android.exoplayer2.PlayerMessage
;
import
com.google.android.exoplayer2.Renderer
;
import
com.google.android.exoplayer2.Renderer
;
import
com.google.android.exoplayer2.SeekParameters
;
import
com.google.android.exoplayer2.SeekParameters
;
...
@@ -79,16 +78,6 @@ public class StubExoPlayer extends StubPlayer implements ExoPlayer {
...
@@ -79,16 +78,6 @@ public class StubExoPlayer extends StubPlayer implements ExoPlayer {
}
}
@Override
@Override
public
void
addListener
(
Player
.
EventListener
listener
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
removeListener
(
Player
.
EventListener
listener
)
{
throw
new
UnsupportedOperationException
();
}
@Override
public
void
addAudioOffloadListener
(
AudioOffloadListener
listener
)
{
public
void
addAudioOffloadListener
(
AudioOffloadListener
listener
)
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
...
...
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