Commit 002ee4de by krocard Committed by bachinger

Deprecate EventListener in favor of Listener

#minor-release

PiperOrigin-RevId: 371348520
parent 762d19b0
Showing with 101 additions and 96 deletions
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
`ExoPlayer`. `ExoPlayer`.
* Add `getMediaMetadata` to `Player` interface. * Add `getMediaMetadata` to `Player` interface.
* Add a `Listener` interface to receive all player events in a single * Add a `Listener` interface to receive all player events in a single
object. Component Listeners have been deprecated in its favor. object. Component Listeners and `EventListener` have been deprecated in
its favor.
* `Player.setPlaybackParameters` no longer accepts null, use * `Player.setPlaybackParameters` no longer accepts null, use
`PlaybackParameters.DEFAULT` instead. `PlaybackParameters.DEFAULT` instead.
* Use an empty string instead of the URI if the media ID is not explicitly * Use an empty string instead of the URI if the media ID is not explicitly
......
...@@ -57,14 +57,14 @@ player.prepare(); ...@@ -57,14 +57,14 @@ player.prepare();
You can retrieve the current manifest by calling `Player.getCurrentManifest`. You can retrieve the current manifest by calling `Player.getCurrentManifest`.
For DASH you should cast the returned object to `DashManifest`. The For DASH you should cast the returned object to `DashManifest`. The
`onTimelineChanged` callback of `Player.EventListener` is also called whenever `onTimelineChanged` callback of `Player.Listener` is also called whenever
the manifest is loaded. This will happen once for a on-demand content, and the manifest is loaded. This will happen once for a on-demand content, and
possibly many times for live content. The code snippet below shows how an app possibly many times for live content. The code snippet below shows how an app
can do something whenever the manifest is loaded. can do something whenever the manifest is loaded.
~~~ ~~~
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onTimelineChanged( public void onTimelineChanged(
Timeline timeline, @Player.TimelineChangeReason int reason) { Timeline timeline, @Player.TimelineChangeReason int reason) {
......
...@@ -60,14 +60,14 @@ player.prepare(); ...@@ -60,14 +60,14 @@ player.prepare();
You can retrieve the current manifest by calling `Player.getCurrentManifest`. You can retrieve the current manifest by calling `Player.getCurrentManifest`.
For HLS you should cast the returned object to `HlsManifest`. The For HLS you should cast the returned object to `HlsManifest`. The
`onTimelineChanged` callback of `Player.EventListener` is also called whenever `onTimelineChanged` callback of `Player.Listener` is also called whenever
the manifest is loaded. This will happen once for a on-demand content, and the manifest is loaded. This will happen once for a on-demand content, and
possibly many times for live content. The code snippet below shows how an app possibly many times for live content. The code snippet below shows how an app
can do something whenever the manifest is loaded. can do something whenever the manifest is loaded.
~~~ ~~~
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onTimelineChanged( public void onTimelineChanged(
Timeline timeline, @Player.TimelineChangeReason int reason) { Timeline timeline, @Player.TimelineChangeReason int reason) {
......
...@@ -5,16 +5,16 @@ title: Player events ...@@ -5,16 +5,16 @@ title: Player events
## Listening to playback events ## ## Listening to playback events ##
Events such as changes in state and playback errors are reported to registered Events such as changes in state and playback errors are reported to registered
[`Player.EventListener`][] instances. Registering a listener to receive such [`Player.Listener`][] instances. Registering a listener to receive such
events is easy: events is easy:
~~~ ~~~
// Add a listener to receive events from the player. // Add a listener to receive events from the player.
player.addListener(eventListener); player.addListener(listener);
~~~ ~~~
{: .language-java} {: .language-java}
`Player.EventListener` has empty default methods, so you only need to implement `Player.Listener` has empty default methods, so you only need to implement
the methods you're interested in. See the [Javadoc][] for a full description of the methods you're interested in. See the [Javadoc][] for a full description of
the methods and when they're called. Some of the most important methods are the methods and when they're called. Some of the most important methods are
described in more detail below. described in more detail below.
...@@ -28,7 +28,7 @@ should be preferred for different use cases. ...@@ -28,7 +28,7 @@ should be preferred for different use cases.
Changes in player state can be received by implementing Changes in player state can be received by implementing
`onPlaybackStateChanged(@State int state)` in a registered `onPlaybackStateChanged(@State int state)` in a registered
`Player.EventListener`. The player can be in one of four playback states: `Player.Listener`. The player can be in one of four playback states:
* `Player.STATE_IDLE`: This is the initial state, the state when the player is * `Player.STATE_IDLE`: This is the initial state, the state when the player is
stopped, and when playback failed. stopped, and when playback failed.
...@@ -68,7 +68,7 @@ public void onIsPlayingChanged(boolean isPlaying) { ...@@ -68,7 +68,7 @@ public void onIsPlayingChanged(boolean isPlaying) {
Errors that cause playback to fail can be received by implementing Errors that cause playback to fail can be received by implementing
`onPlayerError(ExoPlaybackException error)` in a registered `onPlayerError(ExoPlaybackException error)` in a registered
`Player.EventListener`. When a failure occurs, this method will be called `Player.Listener`. When a failure occurs, this method will be called
immediately before the playback state transitions to `Player.STATE_IDLE`. immediately before the playback state transitions to `Player.STATE_IDLE`.
Failed or stopped playbacks can be retried by calling `ExoPlayer.retry`. Failed or stopped playbacks can be retried by calling `ExoPlayer.retry`.
...@@ -107,7 +107,7 @@ public void onPlayerError(ExoPlaybackException error) { ...@@ -107,7 +107,7 @@ public void onPlayerError(ExoPlaybackException error) {
Whenever the player changes to a new media item in the playlist Whenever the player changes to a new media item in the playlist
`onMediaItemTransition(MediaItem mediaItem, `onMediaItemTransition(MediaItem mediaItem,
@MediaItemTransitionReason int reason)` is called on registered @MediaItemTransitionReason int reason)` is called on registered
`Player.EventListener`s. The reason indicates whether this was an automatic `Player.Listener`s. The reason indicates whether this was an automatic
transition, a seek (for example after calling `player.next()`), a repetition of transition, a seek (for example after calling `player.next()`), a repetition of
the same item, or caused by a playlist change (e.g., if the currently playing the same item, or caused by a playlist change (e.g., if the currently playing
item is removed). item is removed).
...@@ -115,7 +115,7 @@ item is removed). ...@@ -115,7 +115,7 @@ item is removed).
### Seeking ### ### Seeking ###
Calling `Player.seekTo` methods results in a series of callbacks to registered Calling `Player.seekTo` methods results in a series of callbacks to registered
`Player.EventListener` instances: `Player.Listener` instances:
1. `onPositionDiscontinuity` with `reason=DISCONTINUITY_REASON_SEEK`. This is 1. `onPositionDiscontinuity` with `reason=DISCONTINUITY_REASON_SEEK`. This is
the direct result of calling `Player.seekTo`. the direct result of calling `Player.seekTo`.
...@@ -232,8 +232,8 @@ player ...@@ -232,8 +232,8 @@ player
~~~ ~~~
{: .language-java } {: .language-java }
[`Player.EventListener`]: {{ site.exo_sdk }}/Player.EventListener.html [`Player.Listener`]: {{ site.exo_sdk }}/Player.Listener.html
[Javadoc]: {{ site.exo_sdk }}/Player.EventListener.html [Javadoc]: {{ site.exo_sdk }}/Player.Listener.html
[`Individual callbacks vs onEvents`]: #individual-callbacks-vs-onevents [`Individual callbacks vs onEvents`]: #individual-callbacks-vs-onevents
[`ExoPlaybackException`]: {{ site.exo_sdk }}/ExoPlaybackException.html [`ExoPlaybackException`]: {{ site.exo_sdk }}/ExoPlaybackException.html
[log output]: event-logger.html [log output]: event-logger.html
......
...@@ -25,7 +25,7 @@ closer to the live edge again. ...@@ -25,7 +25,7 @@ closer to the live edge again.
## Detecting and monitoring live playbacks ## ## Detecting and monitoring live playbacks ##
Every time a live window is updated, registered `Player.EventListener` instances Every time a live window is updated, registered `Player.Listener` instances
will receive an `onTimelineChanged` event. You can retrieve details about the will receive an `onTimelineChanged` event. You can retrieve details about the
current live playback by querying various `Player` and `Timeline.Window` current live playback by querying various `Player` and `Timeline.Window`
methods, as listed below and shown in the following figure. methods, as listed below and shown in the following figure.
...@@ -135,7 +135,7 @@ setting `minPlaybackSpeed` and `maxPlaybackSpeed` to `1.0f`. ...@@ -135,7 +135,7 @@ setting `minPlaybackSpeed` and `maxPlaybackSpeed` to `1.0f`.
The playback position may fall behind the live window, for example if the player The playback position may fall behind the live window, for example if the player
is paused or buffering for a long enough period of time. If this happens then is paused or buffering for a long enough period of time. If this happens then
playback will fail and a `BehindLiveWindowException` will be reported via playback will fail and a `BehindLiveWindowException` will be reported via
`Player.EventListener.onPlayerError`. Application code may wish to handle such `Player.Listener.onPlayerError`. Application code may wish to handle such
errors by resuming playback at the default position. The [PlayerActivity][] of errors by resuming playback at the default position. The [PlayerActivity][] of
the demo app exemplifies this approach. the demo app exemplifies this approach.
......
...@@ -101,7 +101,7 @@ MediaItem mediaItem = ...@@ -101,7 +101,7 @@ MediaItem mediaItem =
## Detecting when playback transitions to another media item ## ## Detecting when playback transitions to another media item ##
When playback transitions to another media item, or starts repeating the same When playback transitions to another media item, or starts repeating the same
media item, `EventListener.onMediaItemTransition(MediaItem, media item, `Listener.onMediaItemTransition(MediaItem,
@MediaItemTransitionReason)` is called. This callback receives the new media @MediaItemTransitionReason)` is called. This callback receives the new media
item, along with a `@MediaItemTransitionReason` indicating why the transition item, along with a `@MediaItemTransitionReason` indicating why the transition
occurred. A common use case for `onMediaItemTransition` is to update the occurred. A common use case for `onMediaItemTransition` is to update the
...@@ -135,7 +135,7 @@ public void onMediaItemTransition( ...@@ -135,7 +135,7 @@ public void onMediaItemTransition(
## Detecting when the playlist changes ## ## Detecting when the playlist changes ##
When a media item is added, removed or moved, When a media item is added, removed or moved,
`EventListener.onTimelineChanged(Timeline, @TimelineChangeReason)` is called `Listener.onTimelineChanged(Timeline, @TimelineChangeReason)` is called
immediately with `TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED`. This callback is immediately with `TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED`. This callback is
called even when the player has not yet been prepared. called even when the player has not yet been prepared.
......
...@@ -59,14 +59,14 @@ player.prepare(); ...@@ -59,14 +59,14 @@ player.prepare();
You can retrieve the current manifest by calling `Player.getCurrentManifest`. You can retrieve the current manifest by calling `Player.getCurrentManifest`.
For SmoothStreaming you should cast the returned object to `SsManifest`. The For SmoothStreaming you should cast the returned object to `SsManifest`. The
`onTimelineChanged` callback of `Player.EventListener` is also called whenever `onTimelineChanged` callback of `Player.Listener` is also called whenever
the manifest is loaded. This will happen once for a on-demand content, and the manifest is loaded. This will happen once for a on-demand content, and
possibly many times for live content. The code snippet below shows how an app possibly many times for live content. The code snippet below shows how an app
can do something whenever the manifest is loaded. can do something whenever the manifest is loaded.
~~~ ~~~
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onTimelineChanged( public void onTimelineChanged(
Timeline timeline, @Player.TimelineChangeReason int reason) { Timeline timeline, @Player.TimelineChangeReason int reason) {
......
...@@ -97,7 +97,7 @@ public class CastPlayerTest { ...@@ -97,7 +97,7 @@ public class CastPlayerTest {
@Mock private CastContext mockCastContext; @Mock private CastContext mockCastContext;
@Mock private SessionManager mockSessionManager; @Mock private SessionManager mockSessionManager;
@Mock private CastSession mockCastSession; @Mock private CastSession mockCastSession;
@Mock private Player.EventListener mockListener; @Mock private Player.Listener mockListener;
@Mock private PendingResult<RemoteMediaClient.MediaChannelResult> mockPendingResult; @Mock private PendingResult<RemoteMediaClient.MediaChannelResult> mockPendingResult;
@Captor @Captor
......
...@@ -89,7 +89,7 @@ public class FlacPlaybackTest { ...@@ -89,7 +89,7 @@ public class FlacPlaybackTest {
"audiosinkdumps/" + fileName + ".audiosink.dump"); "audiosinkdumps/" + fileName + ".audiosink.dump");
} }
private static class TestPlaybackRunnable implements Player.EventListener, Runnable { private static class TestPlaybackRunnable implements Player.Listener, Runnable {
private final Context context; private final Context context;
private final Uri uri; private final Uri uri;
......
...@@ -28,7 +28,6 @@ import com.google.android.exoplayer2.C; ...@@ -28,7 +28,6 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
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.TimelineChangeReason; import com.google.android.exoplayer2.Player.TimelineChangeReason;
import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline.Window; import com.google.android.exoplayer2.Timeline.Window;
...@@ -186,7 +185,7 @@ public final class ImaPlaybackTest { ...@@ -186,7 +185,7 @@ public final class ImaPlaybackTest {
} }
} }
private static final class ImaHostedTest extends ExoHostedTest implements EventListener { private static final class ImaHostedTest extends ExoHostedTest implements Player.Listener {
private final Uri contentUri; private final Uri contentUri;
private final DataSpec adTagDataSpec; private final DataSpec adTagDataSpec;
......
...@@ -76,7 +76,7 @@ import java.util.List; ...@@ -76,7 +76,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** Handles loading and playback of a single ad tag. */ /** Handles loading and playback of a single ad tag. */
/* package */ final class AdTagLoader implements Player.EventListener { /* package */ final class AdTagLoader implements Player.Listener {
private static final String TAG = "AdTagLoader"; private static final String TAG = "AdTagLoader";
......
...@@ -85,7 +85,7 @@ import java.util.Set; ...@@ -85,7 +85,7 @@ import java.util.Set;
* href="https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/omsdk">IMA * href="https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/omsdk">IMA
* SDK Open Measurement documentation</a> for more information. * SDK Open Measurement documentation</a> for more information.
*/ */
public final class ImaAdsLoader implements Player.EventListener, AdsLoader { public final class ImaAdsLoader implements Player.Listener, AdsLoader {
static { static {
ExoPlayerLibraryInfo.registerModule("goog.exo.ima"); ExoPlayerLibraryInfo.registerModule("goog.exo.ima");
...@@ -601,7 +601,7 @@ public final class ImaAdsLoader implements Player.EventListener, AdsLoader { ...@@ -601,7 +601,7 @@ public final class ImaAdsLoader implements Player.EventListener, AdsLoader {
.handlePrepareError(adGroupIndex, adIndexInAdGroup, exception); .handlePrepareError(adGroupIndex, adIndexInAdGroup, exception);
} }
// Player.EventListener implementation. // Player.Listener implementation.
@Override @Override
public void onTimelineChanged(Timeline timeline, @Player.TimelineChangeReason int reason) { public void onTimelineChanged(Timeline timeline, @Player.TimelineChangeReason int reason) {
......
...@@ -27,7 +27,7 @@ import com.google.android.exoplayer2.util.ListenerSet; ...@@ -27,7 +27,7 @@ import com.google.android.exoplayer2.util.ListenerSet;
/** A fake player for testing content/ad playback. */ /** A fake player for testing content/ad playback. */
/* package */ final class FakePlayer extends StubExoPlayer { /* package */ final class FakePlayer extends StubExoPlayer {
private final ListenerSet<EventListener> listeners; private final ListenerSet<Listener> listeners;
private final Timeline.Period period; private final Timeline.Period period;
private final Object windowUid = new Object(); private final Object windowUid = new Object();
private final Object periodUid = new Object(); private final Object periodUid = new Object();
...@@ -185,12 +185,12 @@ import com.google.android.exoplayer2.util.ListenerSet; ...@@ -185,12 +185,12 @@ import com.google.android.exoplayer2.util.ListenerSet;
} }
@Override @Override
public void addListener(Player.EventListener listener) { public void addListener(Player.Listener listener) {
listeners.add(listener); listeners.add(listener);
} }
@Override @Override
public void removeListener(Player.EventListener listener) { public void removeListener(Player.Listener listener) {
listeners.remove(listener); listeners.remove(listener);
} }
......
...@@ -1085,13 +1085,12 @@ public final class MediaSessionConnector { ...@@ -1085,13 +1085,12 @@ public final class MediaSessionConnector {
} }
} }
private class ComponentListener extends MediaSessionCompat.Callback private class ComponentListener extends MediaSessionCompat.Callback implements Player.Listener {
implements Player.EventListener {
private int currentWindowIndex; private int currentWindowIndex;
private int currentWindowCount; private int currentWindowCount;
// Player.EventListener implementation. // Player.Listener implementation.
@Override @Override
public void onEvents(Player player, Player.Events events) { public void onEvents(Player player, Player.Events events) {
......
...@@ -73,7 +73,7 @@ public class OpusPlaybackTest { ...@@ -73,7 +73,7 @@ public class OpusPlaybackTest {
} }
} }
private static class TestPlaybackRunnable implements Player.EventListener, Runnable { private static class TestPlaybackRunnable implements Player.Listener, Runnable {
private final Context context; private final Context context;
private final Uri uri; private final Uri uri;
......
...@@ -101,7 +101,7 @@ public class VpxPlaybackTest { ...@@ -101,7 +101,7 @@ public class VpxPlaybackTest {
} }
} }
private static class TestPlaybackRunnable implements Player.EventListener, Runnable { private static class TestPlaybackRunnable implements Player.Listener, Runnable {
private final Context context; private final Context context;
private final Uri uri; private final Uri uri;
......
...@@ -74,7 +74,10 @@ public interface Player { ...@@ -74,7 +74,10 @@ public interface Player {
* <p>Listeners can choose to implement individual events (e.g. {@link * <p>Listeners can choose to implement individual events (e.g. {@link
* #onIsPlayingChanged(boolean)}) or {@link #onEvents(Player, Events)}, which is called after one * #onIsPlayingChanged(boolean)}) or {@link #onEvents(Player, Events)}, which is called after one
* or more events occurred together. * or more events occurred together.
*
* @deprecated Use {@link Player.Listener}.
*/ */
@Deprecated
interface EventListener { interface EventListener {
/** /**
...@@ -1040,7 +1043,9 @@ public interface Player { ...@@ -1040,7 +1043,9 @@ public interface Player {
* the player does not have a {@link Looper}, then the listener will be called on the main thread. * the player does not have a {@link Looper}, then the listener will be called on the main thread.
* *
* @param listener The listener to register. * @param listener The listener to register.
* @deprecated Use {@link #addListener(Listener)} instead.
*/ */
@Deprecated
void addListener(EventListener listener); void addListener(EventListener listener);
/** /**
...@@ -1055,7 +1060,9 @@ public interface Player { ...@@ -1055,7 +1060,9 @@ public interface Player {
* no longer receive events from the player. * no longer receive events from the player.
* *
* @param listener The listener to unregister. * @param listener The listener to unregister.
* @deprecated Use {@link #addListener(Listener)} instead.
*/ */
@Deprecated
void removeListener(EventListener listener); void removeListener(EventListener listener);
/** /**
......
...@@ -66,7 +66,7 @@ public final class ClippedPlaybackTest { ...@@ -66,7 +66,7 @@ public final class ClippedPlaybackTest {
player player
.get() .get()
.addListener( .addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPlaybackStateChanged(@Player.State int state) { public void onPlaybackStateChanged(@Player.State int state) {
if (state == Player.STATE_ENDED) { if (state == Player.STATE_ENDED) {
...@@ -120,7 +120,7 @@ public final class ClippedPlaybackTest { ...@@ -120,7 +120,7 @@ public final class ClippedPlaybackTest {
player player
.get() .get()
.addListener( .addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPlaybackStateChanged(@Player.State int state) { public void onPlaybackStateChanged(@Player.State int state) {
if (state == Player.STATE_ENDED) { if (state == Player.STATE_ENDED) {
......
...@@ -66,7 +66,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -66,7 +66,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
* Data collector that forwards analytics events to {@link AnalyticsListener AnalyticsListeners}. * Data collector that forwards analytics events to {@link AnalyticsListener AnalyticsListeners}.
*/ */
public class AnalyticsCollector public class AnalyticsCollector
implements Player.EventListener, implements Player.Listener,
AudioRendererEventListener, AudioRendererEventListener,
VideoRendererEventListener, VideoRendererEventListener,
MediaSourceEventListener, MediaSourceEventListener,
......
...@@ -105,10 +105,10 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNull; ...@@ -105,10 +105,10 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
* }</pre> * }</pre>
* *
* If {@code rendererTrackGroups} is null then there aren't any currently mapped tracks, and so * If {@code rendererTrackGroups} is null then there aren't any currently mapped tracks, and so
* setting an override isn't possible. Note that a {@link Player.EventListener} registered on the * setting an override isn't possible. Note that a {@link Player.Listener} registered on the player
* player can be used to determine when the current tracks (and therefore the mapping) changes. If * can be used to determine when the current tracks (and therefore the mapping) changes. If {@code
* {@code rendererTrackGroups} is non-null then an override can be set. The next step is to query * rendererTrackGroups} is non-null then an override can be set. The next step is to query the
* the properties of the available tracks to determine the {@code groupIndex} and the {@code * properties of the available tracks to determine the {@code groupIndex} and the {@code
* trackIndices} within the group it that should be selected. The override can then be specified * trackIndices} within the group it that should be selected. The override can then be specified
* using {@link ParametersBuilder#setSelectionOverride}: * using {@link ParametersBuilder#setSelectionOverride}:
* *
......
...@@ -28,7 +28,7 @@ import java.util.Locale; ...@@ -28,7 +28,7 @@ import java.util.Locale;
* A helper class for periodically updating a {@link TextView} with debug information obtained from * A helper class for periodically updating a {@link TextView} with debug information obtained from
* a {@link SimpleExoPlayer}. * a {@link SimpleExoPlayer}.
*/ */
public class DebugTextViewHelper implements Player.EventListener, Runnable { public class DebugTextViewHelper implements Player.Listener, Runnable {
private static final int REFRESH_INTERVAL_MS = 1000; private static final int REFRESH_INTERVAL_MS = 1000;
...@@ -75,7 +75,7 @@ public class DebugTextViewHelper implements Player.EventListener, Runnable { ...@@ -75,7 +75,7 @@ public class DebugTextViewHelper implements Player.EventListener, Runnable {
textView.removeCallbacks(this); textView.removeCallbacks(this);
} }
// Player.EventListener implementation. // Player.Listener implementation.
@Override @Override
public final void onPlaybackStateChanged(@Player.State int playbackState) { public final void onPlaybackStateChanged(@Player.State int playbackState) {
......
...@@ -1041,7 +1041,7 @@ public final class AnalyticsCollectorTest { ...@@ -1041,7 +1041,7 @@ public final class AnalyticsCollectorTest {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(SimpleExoPlayer player) {
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPositionDiscontinuity( public void onPositionDiscontinuity(
Player.PositionInfo oldPosition, Player.PositionInfo oldPosition,
......
...@@ -58,8 +58,8 @@ public class TestPlayerRunHelper { ...@@ -58,8 +58,8 @@ public class TestPlayerRunHelper {
return; return;
} }
AtomicBoolean receivedExpectedState = new AtomicBoolean(false); AtomicBoolean receivedExpectedState = new AtomicBoolean(false);
Player.EventListener listener = Player.Listener listener =
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPlaybackStateChanged(int state) { public void onPlaybackStateChanged(int state) {
if (state == expectedState) { if (state == expectedState) {
...@@ -88,8 +88,8 @@ public class TestPlayerRunHelper { ...@@ -88,8 +88,8 @@ public class TestPlayerRunHelper {
return; return;
} }
AtomicBoolean receivedExpectedPlayWhenReady = new AtomicBoolean(false); AtomicBoolean receivedExpectedPlayWhenReady = new AtomicBoolean(false);
Player.EventListener listener = Player.Listener listener =
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) { public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
if (playWhenReady == expectedPlayWhenReady) { if (playWhenReady == expectedPlayWhenReady) {
...@@ -118,8 +118,8 @@ public class TestPlayerRunHelper { ...@@ -118,8 +118,8 @@ public class TestPlayerRunHelper {
return; return;
} }
AtomicBoolean receivedExpectedTimeline = new AtomicBoolean(false); AtomicBoolean receivedExpectedTimeline = new AtomicBoolean(false);
Player.EventListener listener = Player.Listener listener =
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onTimelineChanged(Timeline timeline, int reason) { public void onTimelineChanged(Timeline timeline, int reason) {
if (expectedTimeline.equals(timeline)) { if (expectedTimeline.equals(timeline)) {
...@@ -143,8 +143,8 @@ public class TestPlayerRunHelper { ...@@ -143,8 +143,8 @@ public class TestPlayerRunHelper {
public static Timeline runUntilTimelineChanged(Player player) throws TimeoutException { public static Timeline runUntilTimelineChanged(Player player) throws TimeoutException {
verifyMainTestThread(player); verifyMainTestThread(player);
AtomicReference<Timeline> receivedTimeline = new AtomicReference<>(); AtomicReference<Timeline> receivedTimeline = new AtomicReference<>();
Player.EventListener listener = Player.Listener listener =
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onTimelineChanged(Timeline timeline, int reason) { public void onTimelineChanged(Timeline timeline, int reason) {
receivedTimeline.set(timeline); receivedTimeline.set(timeline);
...@@ -158,7 +158,7 @@ public class TestPlayerRunHelper { ...@@ -158,7 +158,7 @@ public class TestPlayerRunHelper {
/** /**
* Runs tasks of the main {@link Looper} until a {@link * Runs tasks of the main {@link Looper} until a {@link
* Player.EventListener#onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)} * Player.Listener#onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)}
* callback with the specified {@link Player.DiscontinuityReason} occurred. * callback with the specified {@link Player.DiscontinuityReason} occurred.
* *
* @param player The {@link Player}. * @param player The {@link Player}.
...@@ -170,8 +170,8 @@ public class TestPlayerRunHelper { ...@@ -170,8 +170,8 @@ public class TestPlayerRunHelper {
Player player, @Player.DiscontinuityReason int expectedReason) throws TimeoutException { Player player, @Player.DiscontinuityReason int expectedReason) throws TimeoutException {
verifyMainTestThread(player); verifyMainTestThread(player);
AtomicBoolean receivedCallback = new AtomicBoolean(false); AtomicBoolean receivedCallback = new AtomicBoolean(false);
Player.EventListener listener = Player.Listener listener =
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPositionDiscontinuity( public void onPositionDiscontinuity(
Player.PositionInfo oldPosition, Player.PositionInfo newPosition, int reason) { Player.PositionInfo oldPosition, Player.PositionInfo newPosition, int reason) {
...@@ -196,8 +196,8 @@ public class TestPlayerRunHelper { ...@@ -196,8 +196,8 @@ public class TestPlayerRunHelper {
public static ExoPlaybackException runUntilError(Player player) throws TimeoutException { public static ExoPlaybackException runUntilError(Player player) throws TimeoutException {
verifyMainTestThread(player); verifyMainTestThread(player);
AtomicReference<ExoPlaybackException> receivedError = new AtomicReference<>(); AtomicReference<ExoPlaybackException> receivedError = new AtomicReference<>();
Player.EventListener listener = Player.Listener listener =
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPlayerError(ExoPlaybackException error) { public void onPlayerError(ExoPlaybackException error) {
receivedError.set(error); receivedError.set(error);
......
...@@ -729,7 +729,7 @@ public abstract class Action { ...@@ -729,7 +729,7 @@ public abstract class Action {
} }
} }
/** Waits for {@link Player.EventListener#onTimelineChanged(Timeline, int)}. */ /** Waits for {@link Player.Listener#onTimelineChanged(Timeline, int)}. */
public static final class WaitForTimelineChanged extends Action { public static final class WaitForTimelineChanged extends Action {
@Nullable private final Timeline expectedTimeline; @Nullable private final Timeline expectedTimeline;
...@@ -776,8 +776,8 @@ public abstract class Action { ...@@ -776,8 +776,8 @@ public abstract class Action {
if (nextAction == null) { if (nextAction == null) {
return; return;
} }
Player.EventListener listener = Player.Listener listener =
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onTimelineChanged( public void onTimelineChanged(
Timeline timeline, @Player.TimelineChangeReason int reason) { Timeline timeline, @Player.TimelineChangeReason int reason) {
...@@ -804,7 +804,7 @@ public abstract class Action { ...@@ -804,7 +804,7 @@ public abstract class Action {
} }
/** /**
* Waits for {@link Player.EventListener#onPositionDiscontinuity(Player.PositionInfo, * Waits for {@link Player.Listener#onPositionDiscontinuity(Player.PositionInfo,
* Player.PositionInfo, int)}. * Player.PositionInfo, int)}.
*/ */
public static final class WaitForPositionDiscontinuity extends Action { public static final class WaitForPositionDiscontinuity extends Action {
...@@ -825,7 +825,7 @@ public abstract class Action { ...@@ -825,7 +825,7 @@ public abstract class Action {
return; return;
} }
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPositionDiscontinuity( public void onPositionDiscontinuity(
Player.PositionInfo oldPosition, Player.PositionInfo oldPosition,
...@@ -846,7 +846,7 @@ public abstract class Action { ...@@ -846,7 +846,7 @@ public abstract class Action {
/** /**
* Waits for a specified playWhenReady value, returning either immediately or after a call to * Waits for a specified playWhenReady value, returning either immediately or after a call to
* {@link Player.EventListener#onPlayWhenReadyChanged(boolean, int)}. * {@link Player.Listener#onPlayWhenReadyChanged(boolean, int)}.
*/ */
public static final class WaitForPlayWhenReady extends Action { public static final class WaitForPlayWhenReady extends Action {
...@@ -875,7 +875,7 @@ public abstract class Action { ...@@ -875,7 +875,7 @@ public abstract class Action {
nextAction.schedule(player, trackSelector, surface, handler); nextAction.schedule(player, trackSelector, surface, handler);
} else { } else {
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPlayWhenReadyChanged( public void onPlayWhenReadyChanged(
boolean playWhenReady, @Player.PlayWhenReadyChangeReason int reason) { boolean playWhenReady, @Player.PlayWhenReadyChangeReason int reason) {
...@@ -897,7 +897,7 @@ public abstract class Action { ...@@ -897,7 +897,7 @@ public abstract class Action {
/** /**
* Waits for a specified playback state, returning either immediately or after a call to {@link * Waits for a specified playback state, returning either immediately or after a call to {@link
* Player.EventListener#onPlaybackStateChanged(int)}. * Player.Listener#onPlaybackStateChanged(int)}.
*/ */
public static final class WaitForPlaybackState extends Action { public static final class WaitForPlaybackState extends Action {
...@@ -926,7 +926,7 @@ public abstract class Action { ...@@ -926,7 +926,7 @@ public abstract class Action {
nextAction.schedule(player, trackSelector, surface, handler); nextAction.schedule(player, trackSelector, surface, handler);
} else { } else {
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onPlaybackStateChanged(@Player.State int playbackState) { public void onPlaybackStateChanged(@Player.State int playbackState) {
if (targetPlaybackState == playbackState) { if (targetPlaybackState == playbackState) {
...@@ -987,7 +987,7 @@ public abstract class Action { ...@@ -987,7 +987,7 @@ public abstract class Action {
/** /**
* Waits for a specified loading state, returning either immediately or after a call to {@link * Waits for a specified loading state, returning either immediately or after a call to {@link
* Player.EventListener#onIsLoadingChanged(boolean)}. * Player.Listener#onIsLoadingChanged(boolean)}.
*/ */
public static final class WaitForIsLoading extends Action { public static final class WaitForIsLoading extends Action {
...@@ -1016,7 +1016,7 @@ public abstract class Action { ...@@ -1016,7 +1016,7 @@ public abstract class Action {
nextAction.schedule(player, trackSelector, surface, handler); nextAction.schedule(player, trackSelector, surface, handler);
} else { } else {
player.addListener( player.addListener(
new Player.EventListener() { new Player.Listener() {
@Override @Override
public void onIsLoadingChanged(boolean isLoading) { public void onIsLoadingChanged(boolean isLoading) {
if (targetIsLoading == isLoading) { if (targetIsLoading == isLoading) {
......
...@@ -50,7 +50,7 @@ import java.util.concurrent.CountDownLatch; ...@@ -50,7 +50,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** Helper class to run an ExoPlayer test. */ /** Helper class to run an ExoPlayer test. */
public final class ExoPlayerTestRunner implements Player.EventListener, ActionSchedule.Callback { public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedule.Callback {
/** A generic video {@link Format} which can be used to set up a {@link FakeMediaSource}. */ /** A generic video {@link Format} which can be used to set up a {@link FakeMediaSource}. */
public static final Format VIDEO_FORMAT = public static final Format VIDEO_FORMAT =
...@@ -82,7 +82,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -82,7 +82,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
private Object manifest; private Object manifest;
private ActionSchedule actionSchedule; private ActionSchedule actionSchedule;
private Surface surface; private Surface surface;
private Player.EventListener eventListener; private Player.Listener playerListener;
private AnalyticsListener analyticsListener; private AnalyticsListener analyticsListener;
private Integer expectedPlayerEndedCount; private Integer expectedPlayerEndedCount;
private boolean pauseAtEndOfMediaItems; private boolean pauseAtEndOfMediaItems;
...@@ -290,14 +290,14 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -290,14 +290,14 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
} }
/** /**
* Sets an {@link Player.EventListener} to be registered to listen to player events. * Sets an {@link Player.Listener} to be registered to listen to player events.
* *
* @param eventListener A {@link Player.EventListener} to be registered by the test runner to * @param playerListener A {@link Player.Listener} to be registered by the test runner to listen
* listen to player events. * to player events.
* @return This builder. * @return This builder.
*/ */
public Builder setEventListener(Player.EventListener eventListener) { public Builder setPlayerListener(Player.Listener playerListener) {
this.eventListener = eventListener; this.playerListener = playerListener;
return this; return this;
} }
...@@ -349,7 +349,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -349,7 +349,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
initialPositionMs, initialPositionMs,
surface, surface,
actionSchedule, actionSchedule,
eventListener, playerListener,
analyticsListener, analyticsListener,
expectedPlayerEndedCount, expectedPlayerEndedCount,
pauseAtEndOfMediaItems); pauseAtEndOfMediaItems);
...@@ -363,7 +363,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -363,7 +363,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
private final long initialPositionMs; private final long initialPositionMs;
@Nullable private final Surface surface; @Nullable private final Surface surface;
@Nullable private final ActionSchedule actionSchedule; @Nullable private final ActionSchedule actionSchedule;
@Nullable private final Player.EventListener eventListener; @Nullable private final Player.Listener playerListener;
@Nullable private final AnalyticsListener analyticsListener; @Nullable private final AnalyticsListener analyticsListener;
private final Clock clock; private final Clock clock;
...@@ -393,7 +393,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -393,7 +393,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
long initialPositionMs, long initialPositionMs,
@Nullable Surface surface, @Nullable Surface surface,
@Nullable ActionSchedule actionSchedule, @Nullable ActionSchedule actionSchedule,
@Nullable Player.EventListener eventListener, @Nullable Player.Listener playerListener,
@Nullable AnalyticsListener analyticsListener, @Nullable AnalyticsListener analyticsListener,
int expectedPlayerEndedCount, int expectedPlayerEndedCount,
boolean pauseAtEndOfMediaItems) { boolean pauseAtEndOfMediaItems) {
...@@ -404,7 +404,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -404,7 +404,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
this.initialPositionMs = initialPositionMs; this.initialPositionMs = initialPositionMs;
this.surface = surface; this.surface = surface;
this.actionSchedule = actionSchedule; this.actionSchedule = actionSchedule;
this.eventListener = eventListener; this.playerListener = playerListener;
this.analyticsListener = analyticsListener; this.analyticsListener = analyticsListener;
this.clock = playerBuilder.getClock(); this.clock = playerBuilder.getClock();
timelines = new ArrayList<>(); timelines = new ArrayList<>();
...@@ -454,8 +454,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -454,8 +454,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
player.setPauseAtEndOfMediaItems(true); player.setPauseAtEndOfMediaItems(true);
} }
player.addListener(ExoPlayerTestRunner.this); player.addListener(ExoPlayerTestRunner.this);
if (eventListener != null) { if (playerListener != null) {
player.addListener(eventListener); player.addListener(playerListener);
} }
if (analyticsListener != null) { if (analyticsListener != null) {
player.addAnalyticsListener(analyticsListener); player.addAnalyticsListener(analyticsListener);
...@@ -530,8 +530,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -530,8 +530,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
// Assertions called on the test thread after test finished. // Assertions called on the test thread after test finished.
/** /**
* Asserts that the timelines reported by {@link Player.EventListener#onTimelineChanged(Timeline, * Asserts that the timelines reported by {@link Player.Listener#onTimelineChanged(Timeline, int)}
* int)} are the same to the provided timelines. This assert differs from testing equality by not * are the same to the provided timelines. This assert differs from testing equality by not
* comparing period ids which may be different due to id mapping of child source period ids. * comparing period ids which may be different due to id mapping of child source period ids.
* *
* @param timelines A list of expected {@link Timeline}s. * @param timelines A list of expected {@link Timeline}s.
...@@ -546,8 +546,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -546,8 +546,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
/** /**
* Asserts that the timeline change reasons reported by {@link * Asserts that the timeline change reasons reported by {@link
* Player.EventListener#onTimelineChanged(Timeline, int)} are equal to the provided timeline * Player.Listener#onTimelineChanged(Timeline, int)} are equal to the provided timeline change
* change reasons. * reasons.
*/ */
public void assertTimelineChangeReasonsEqual(Integer... reasons) { public void assertTimelineChangeReasonsEqual(Integer... reasons) {
assertThat(timelineChangeReasons).containsExactlyElementsIn(Arrays.asList(reasons)).inOrder(); assertThat(timelineChangeReasons).containsExactlyElementsIn(Arrays.asList(reasons)).inOrder();
...@@ -555,7 +555,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -555,7 +555,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
/** /**
* Asserts that the media items reported by {@link * Asserts that the media items reported by {@link
* Player.EventListener#onMediaItemTransition(MediaItem, int)} are the same as the provided media * Player.Listener#onMediaItemTransition(MediaItem, int)} are the same as the provided media
* items. * items.
* *
* @param mediaItems A list of expected {@link MediaItem media items}. * @param mediaItems A list of expected {@link MediaItem media items}.
...@@ -566,8 +566,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -566,8 +566,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
/** /**
* Asserts that the media item transition reasons reported by {@link * Asserts that the media item transition reasons reported by {@link
* Player.EventListener#onMediaItemTransition(MediaItem, int)} are the same as the provided * Player.Listener#onMediaItemTransition(MediaItem, int)} are the same as the provided reasons.
* reasons.
* *
* @param reasons A list of expected transition reasons. * @param reasons A list of expected transition reasons.
*/ */
...@@ -577,7 +576,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -577,7 +576,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
/** /**
* Asserts that the playback states reported by {@link * Asserts that the playback states reported by {@link
* Player.EventListener#onPlaybackStateChanged(int)} are equal to the provided playback states. * Player.Listener#onPlaybackStateChanged(int)} are equal to the provided playback states.
*/ */
public void assertPlaybackStatesEqual(Integer... states) { public void assertPlaybackStatesEqual(Integer... states) {
assertThat(playbackStates).containsExactlyElementsIn(states).inOrder(); assertThat(playbackStates).containsExactlyElementsIn(states).inOrder();
...@@ -585,8 +584,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -585,8 +584,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
/** /**
* Asserts that the last track group array reported by {@link * Asserts that the last track group array reported by {@link
* Player.EventListener#onTracksChanged(TrackGroupArray, TrackSelectionArray)} is equal to the * Player.Listener#onTracksChanged(TrackGroupArray, TrackSelectionArray)} is equal to the provided
* provided track group array. * track group array.
* *
* @param trackGroupArray The expected {@link TrackGroupArray}. * @param trackGroupArray The expected {@link TrackGroupArray}.
*/ */
...@@ -595,7 +594,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -595,7 +594,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
} }
/** /**
* Asserts that {@link Player.EventListener#onPositionDiscontinuity(Player.PositionInfo, * Asserts that {@link Player.Listener#onPositionDiscontinuity(Player.PositionInfo,
* Player.PositionInfo, int)} was not called. * Player.PositionInfo, int)} was not called.
*/ */
public void assertNoPositionDiscontinuities() { public void assertNoPositionDiscontinuities() {
...@@ -604,8 +603,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -604,8 +603,8 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
/** /**
* Asserts that the discontinuity reasons reported by {@link * Asserts that the discontinuity reasons reported by {@link
* Player.EventListener#onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)} * Player.Listener#onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)} are
* are equal to the provided values. * equal to the provided values.
* *
* @param discontinuityReasons The expected discontinuity reasons. * @param discontinuityReasons The expected discontinuity reasons.
*/ */
...@@ -657,7 +656,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc ...@@ -657,7 +656,7 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
} }
} }
// Player.EventListener // Player.Listener
@Override @Override
public void onTimelineChanged(Timeline timeline, @Player.TimelineChangeReason int reason) { public void onTimelineChanged(Timeline timeline, @Player.TimelineChangeReason int reason) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment