Deprecate Player.DefaultEventListener in favor of default no-ops in interface.
The DefaultEventListener was added for selective overrides. Now that Java 8 support is enabled, these selective listener overrides can be implemented more easily and more flexible using default methods. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=201695490
This commit is contained in:
parent
b031c3d6bb
commit
156e2317cc
@ -40,6 +40,8 @@
|
|||||||
`ExoPlayerFactory` ([#4278](https://github.com/google/ExoPlayer/issues/4278)).
|
`ExoPlayerFactory` ([#4278](https://github.com/google/ExoPlayer/issues/4278)).
|
||||||
* Fix a bug where download cancellation was ignored
|
* Fix a bug where download cancellation was ignored
|
||||||
([#4403](https://github.com/google/ExoPlayer/issues/4403)).
|
([#4403](https://github.com/google/ExoPlayer/issues/4403)).
|
||||||
|
* Deprecate `Player.DefaultEventListener` as selective listener overrides can
|
||||||
|
be directly made with the `Player.EventListener` interface.
|
||||||
|
|
||||||
### 2.8.2 ###
|
### 2.8.2 ###
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ import com.google.android.exoplayer2.C;
|
|||||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.Player.DefaultEventListener;
|
|
||||||
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.RenderersFactory;
|
import com.google.android.exoplayer2.RenderersFactory;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
@ -51,11 +51,9 @@ import com.google.android.gms.cast.MediaQueueItem;
|
|||||||
import com.google.android.gms.cast.framework.CastContext;
|
import com.google.android.gms.cast.framework.CastContext;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/** Manages players and an internal media queue for the ExoPlayer/Cast demo app. */
|
||||||
* Manages players and an internal media queue for the ExoPlayer/Cast demo app.
|
/* package */ final class PlayerManager
|
||||||
*/
|
implements EventListener, CastPlayer.SessionAvailabilityListener {
|
||||||
/* package */ final class PlayerManager extends DefaultEventListener
|
|
||||||
implements CastPlayer.SessionAvailabilityListener {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener for changes in the media queue playback position.
|
* Listener for changes in the media queue playback position.
|
||||||
|
@ -655,7 +655,7 @@ public class PlayerActivity extends Activity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerEventListener extends Player.DefaultEventListener {
|
private class PlayerEventListener implements Player.EventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
|
@ -64,8 +64,7 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestPlaybackRunnable extends Player.DefaultEventListener
|
private static class TestPlaybackRunnable implements Player.EventListener, Runnable {
|
||||||
implements Runnable {
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final Uri uri;
|
private final Uri uri;
|
||||||
|
@ -66,11 +66,15 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/** Loads ads using the IMA SDK. All methods are called on the main thread. */
|
||||||
* Loads ads using the IMA SDK. All methods are called on the main thread.
|
public final class ImaAdsLoader
|
||||||
*/
|
implements Player.EventListener,
|
||||||
public final class ImaAdsLoader extends Player.DefaultEventListener implements AdsLoader,
|
AdsLoader,
|
||||||
VideoAdPlayer, ContentProgressProvider, AdErrorListener, AdsLoadedListener, AdEventListener {
|
VideoAdPlayer,
|
||||||
|
ContentProgressProvider,
|
||||||
|
AdErrorListener,
|
||||||
|
AdsLoadedListener,
|
||||||
|
AdEventListener {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ExoPlayerLibraryInfo.registerModule("goog.exo.ima");
|
ExoPlayerLibraryInfo.registerModule("goog.exo.ima");
|
||||||
|
@ -248,8 +248,8 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
|
|||||||
surfaceHolderGlueHost.setSurfaceHolderCallback(null);
|
surfaceHolderGlueHost.setSurfaceHolderCallback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ComponentListener extends Player.DefaultEventListener
|
private final class ComponentListener
|
||||||
implements SurfaceHolder.Callback, VideoListener {
|
implements Player.EventListener, SurfaceHolder.Callback, VideoListener {
|
||||||
|
|
||||||
// SurfaceHolder.Callback implementation.
|
// SurfaceHolder.Callback implementation.
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ public final class MediaSessionConnector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExoPlayerEventListener extends Player.DefaultEventListener {
|
private class ExoPlayerEventListener implements Player.EventListener {
|
||||||
|
|
||||||
private int currentWindowIndex;
|
private int currentWindowIndex;
|
||||||
private int currentWindowCount;
|
private int currentWindowCount;
|
||||||
|
@ -64,8 +64,7 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestPlaybackRunnable extends Player.DefaultEventListener
|
private static class TestPlaybackRunnable implements Player.EventListener, Runnable {
|
||||||
implements Runnable {
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final Uri uri;
|
private final Uri uri;
|
||||||
|
@ -95,8 +95,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestPlaybackRunnable extends Player.DefaultEventListener
|
private static class TestPlaybackRunnable implements Player.EventListener, Runnable {
|
||||||
implements Runnable {
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final Uri uri;
|
private final Uri uri;
|
||||||
|
@ -215,23 +215,25 @@ public interface Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener of changes in player state.
|
* Listener of changes in player state. All methods have no-op default implementations to allow
|
||||||
|
* selective overrides.
|
||||||
*/
|
*/
|
||||||
interface EventListener {
|
interface EventListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the timeline and/or manifest has been refreshed.
|
* Called when the timeline and/or manifest has been refreshed.
|
||||||
* <p>
|
*
|
||||||
* Note that if the timeline has changed then a position discontinuity may also have occurred.
|
* <p>Note that if the timeline has changed then a position discontinuity may also have
|
||||||
* For example, the current period index may have changed as a result of periods being added or
|
* occurred. For example, the current period index may have changed as a result of periods being
|
||||||
* removed from the timeline. This will <em>not</em> be reported via a separate call to
|
* added or removed from the timeline. This will <em>not</em> be reported via a separate call to
|
||||||
* {@link #onPositionDiscontinuity(int)}.
|
* {@link #onPositionDiscontinuity(int)}.
|
||||||
*
|
*
|
||||||
* @param timeline The latest timeline. Never null, but may be empty.
|
* @param timeline The latest timeline. Never null, but may be empty.
|
||||||
* @param manifest The latest manifest. May be null.
|
* @param manifest The latest manifest. May be null.
|
||||||
* @param reason The {@link TimelineChangeReason} responsible for this timeline change.
|
* @param reason The {@link TimelineChangeReason} responsible for this timeline change.
|
||||||
*/
|
*/
|
||||||
void onTimelineChanged(Timeline timeline, Object manifest, @TimelineChangeReason int reason);
|
default void onTimelineChanged(
|
||||||
|
Timeline timeline, Object manifest, @TimelineChangeReason int reason) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the available or selected tracks change.
|
* Called when the available or selected tracks change.
|
||||||
@ -240,46 +242,47 @@ public interface Player {
|
|||||||
* @param trackSelections The track selections for each renderer. Never null and always of
|
* @param trackSelections The track selections for each renderer. Never null and always of
|
||||||
* length {@link #getRendererCount()}, but may contain null elements.
|
* length {@link #getRendererCount()}, but may contain null elements.
|
||||||
*/
|
*/
|
||||||
void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections);
|
default void onTracksChanged(
|
||||||
|
TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player starts or stops loading the source.
|
* Called when the player starts or stops loading the source.
|
||||||
*
|
*
|
||||||
* @param isLoading Whether the source is currently being loaded.
|
* @param isLoading Whether the source is currently being loaded.
|
||||||
*/
|
*/
|
||||||
void onLoadingChanged(boolean isLoading);
|
default void onLoadingChanged(boolean isLoading) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the value returned from either {@link #getPlayWhenReady()} or
|
* Called when the value returned from either {@link #getPlayWhenReady()} or {@link
|
||||||
* {@link #getPlaybackState()} changes.
|
* #getPlaybackState()} changes.
|
||||||
*
|
*
|
||||||
* @param playWhenReady Whether playback will proceed when ready.
|
* @param playWhenReady Whether playback will proceed when ready.
|
||||||
* @param playbackState One of the {@code STATE} constants.
|
* @param playbackState One of the {@code STATE} constants.
|
||||||
*/
|
*/
|
||||||
void onPlayerStateChanged(boolean playWhenReady, int playbackState);
|
default void onPlayerStateChanged(boolean playWhenReady, int playbackState) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the value of {@link #getRepeatMode()} changes.
|
* Called when the value of {@link #getRepeatMode()} changes.
|
||||||
*
|
*
|
||||||
* @param repeatMode The {@link RepeatMode} used for playback.
|
* @param repeatMode The {@link RepeatMode} used for playback.
|
||||||
*/
|
*/
|
||||||
void onRepeatModeChanged(@RepeatMode int repeatMode);
|
default void onRepeatModeChanged(@RepeatMode int repeatMode) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the value of {@link #getShuffleModeEnabled()} changes.
|
* Called when the value of {@link #getShuffleModeEnabled()} changes.
|
||||||
*
|
*
|
||||||
* @param shuffleModeEnabled Whether shuffling of windows is enabled.
|
* @param shuffleModeEnabled Whether shuffling of windows is enabled.
|
||||||
*/
|
*/
|
||||||
void onShuffleModeEnabledChanged(boolean shuffleModeEnabled);
|
default void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an error occurs. The playback state will transition to {@link #STATE_IDLE}
|
* 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
|
* immediately after this method is called. The player instance can still be used, and {@link
|
||||||
* {@link #release()} must still be called on the player should it no longer be required.
|
* #release()} must still be called on the player should it no longer be required.
|
||||||
*
|
*
|
||||||
* @param error The error.
|
* @param error The error.
|
||||||
*/
|
*/
|
||||||
void onPlayerError(ExoPlaybackException error);
|
default void onPlayerError(ExoPlaybackException error) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a position discontinuity occurs without a change to the timeline. A position
|
* Called when a position discontinuity occurs without a change to the timeline. A position
|
||||||
@ -287,14 +290,14 @@ public interface Player {
|
|||||||
* transitioning from one period in the timeline to the next), or when the playback position
|
* transitioning from one period in the timeline to the next), or when the playback position
|
||||||
* jumps within the period currently being played (as a result of a seek being performed, or
|
* jumps within the period currently being played (as a result of a seek being performed, or
|
||||||
* when the source introduces a discontinuity internally).
|
* when the source introduces a discontinuity internally).
|
||||||
* <p>
|
*
|
||||||
* When a position discontinuity occurs as a result of a change to the timeline this method is
|
* <p>When a position discontinuity occurs as a result of a change to the timeline this method
|
||||||
* <em>not</em> called. {@link #onTimelineChanged(Timeline, Object, int)} is called in this
|
* is <em>not</em> called. {@link #onTimelineChanged(Timeline, Object, int)} is called in this
|
||||||
* case.
|
* case.
|
||||||
*
|
*
|
||||||
* @param reason The {@link DiscontinuityReason} responsible for the discontinuity.
|
* @param reason The {@link DiscontinuityReason} responsible for the discontinuity.
|
||||||
*/
|
*/
|
||||||
void onPositionDiscontinuity(@DiscontinuityReason int reason);
|
default void onPositionDiscontinuity(@DiscontinuityReason int reason) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the current playback parameters change. The playback parameters may change due to
|
* Called when the current playback parameters change. The playback parameters may change due to
|
||||||
@ -304,20 +307,21 @@ public interface Player {
|
|||||||
*
|
*
|
||||||
* @param playbackParameters The playback parameters.
|
* @param playbackParameters The playback parameters.
|
||||||
*/
|
*/
|
||||||
void onPlaybackParametersChanged(PlaybackParameters playbackParameters);
|
default void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when all pending seek requests have been processed by the player. This is guaranteed
|
* Called when all pending seek requests have been processed by the player. This is guaranteed
|
||||||
* to happen after any necessary changes to the player state were reported to
|
* to happen after any necessary changes to the player state were reported to {@link
|
||||||
* {@link #onPlayerStateChanged(boolean, int)}.
|
* #onPlayerStateChanged(boolean, int)}.
|
||||||
*/
|
*/
|
||||||
void onSeekProcessed();
|
default void onSeekProcessed() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EventListener} allowing selective overrides. All methods are implemented as no-ops.
|
* @deprecated Use {@link EventListener} interface directly for selective overrides as all methods
|
||||||
|
* are implemented as no-op default methods.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
abstract class DefaultEventListener implements EventListener {
|
abstract class DefaultEventListener implements EventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -327,60 +331,11 @@ public interface Player {
|
|||||||
onTimelineChanged(timeline, manifest);
|
onTimelineChanged(timeline, manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/** @deprecated Use {@link EventListener#onTimelineChanged(Timeline, Object, int)} instead. */
|
||||||
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingChanged(boolean isLoading) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRepeatModeChanged(@RepeatMode int repeatMode) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerError(ExoPlaybackException error) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPositionDiscontinuity(@DiscontinuityReason int reason) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSeekProcessed() {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link DefaultEventListener#onTimelineChanged(Timeline, Object, int)}
|
|
||||||
* instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void onTimelineChanged(Timeline timeline, Object manifest) {
|
public void onTimelineChanged(Timeline timeline, Object manifest) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import com.google.android.exoplayer2.Player.DefaultEventListener;
|
|
||||||
import com.google.android.exoplayer2.Player.EventListener;
|
import com.google.android.exoplayer2.Player.EventListener;
|
||||||
import com.google.android.exoplayer2.Timeline.Window;
|
import com.google.android.exoplayer2.Timeline.Window;
|
||||||
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
|
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
|
||||||
@ -483,7 +482,7 @@ public final class ExoPlayerTest {
|
|||||||
.build();
|
.build();
|
||||||
final List<Integer> playbackStatesWhenSeekProcessed = new ArrayList<>();
|
final List<Integer> playbackStatesWhenSeekProcessed = new ArrayList<>();
|
||||||
EventListener eventListener =
|
EventListener eventListener =
|
||||||
new DefaultEventListener() {
|
new EventListener() {
|
||||||
private int currentPlaybackState = Player.STATE_IDLE;
|
private int currentPlaybackState = Player.STATE_IDLE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -535,7 +534,7 @@ public final class ExoPlayerTest {
|
|||||||
.build();
|
.build();
|
||||||
final boolean[] onSeekProcessedCalled = new boolean[1];
|
final boolean[] onSeekProcessedCalled = new boolean[1];
|
||||||
EventListener listener =
|
EventListener listener =
|
||||||
new DefaultEventListener() {
|
new EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSeekProcessed() {
|
public void onSeekProcessed() {
|
||||||
onSeekProcessedCalled[0] = true;
|
onSeekProcessedCalled[0] = true;
|
||||||
@ -1988,7 +1987,7 @@ public final class ExoPlayerTest {
|
|||||||
final List<Integer> eventListener1States = new ArrayList<>();
|
final List<Integer> eventListener1States = new ArrayList<>();
|
||||||
final List<Integer> eventListener2States = new ArrayList<>();
|
final List<Integer> eventListener2States = new ArrayList<>();
|
||||||
final EventListener eventListener1 =
|
final EventListener eventListener1 =
|
||||||
new DefaultEventListener() {
|
new EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
eventListener1States.add(playbackState);
|
eventListener1States.add(playbackState);
|
||||||
@ -1998,7 +1997,7 @@ public final class ExoPlayerTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
final EventListener eventListener2 =
|
final EventListener eventListener2 =
|
||||||
new DefaultEventListener() {
|
new EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
eventListener2States.add(playbackState);
|
eventListener2States.add(playbackState);
|
||||||
@ -2038,7 +2037,7 @@ public final class ExoPlayerTest {
|
|||||||
final List<Boolean> eventListenerPlayWhenReady = new ArrayList<>();
|
final List<Boolean> eventListenerPlayWhenReady = new ArrayList<>();
|
||||||
final List<Integer> eventListenerStates = new ArrayList<>();
|
final List<Integer> eventListenerStates = new ArrayList<>();
|
||||||
final EventListener eventListener =
|
final EventListener eventListener =
|
||||||
new DefaultEventListener() {
|
new EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTimelineChanged(Timeline timeline, Object manifest, int reason) {
|
public void onTimelineChanged(Timeline timeline, Object manifest, int reason) {
|
||||||
if (timeline.isEmpty()) {
|
if (timeline.isEmpty()) {
|
||||||
|
@ -27,7 +27,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 extends Player.DefaultEventListener implements Runnable {
|
public class DebugTextViewHelper implements Player.EventListener, Runnable {
|
||||||
|
|
||||||
private static final int REFRESH_INTERVAL_MS = 1000;
|
private static final int REFRESH_INTERVAL_MS = 1000;
|
||||||
|
|
||||||
|
@ -1030,8 +1030,8 @@ public class PlayerControlView extends FrameLayout {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ComponentListener extends Player.DefaultEventListener
|
private final class ComponentListener
|
||||||
implements TimeBar.OnScrubListener, OnClickListener {
|
implements Player.EventListener, TimeBar.OnScrubListener, OnClickListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrubStart(TimeBar timeBar, long position) {
|
public void onScrubStart(TimeBar timeBar, long position) {
|
||||||
|
@ -937,7 +937,7 @@ public class PlayerNotificationManager {
|
|||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerListener extends Player.DefaultEventListener {
|
private class PlayerListener implements Player.EventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
|
@ -1179,8 +1179,8 @@ public class PlayerView extends FrameLayout {
|
|||||||
|| keyCode == KeyEvent.KEYCODE_DPAD_CENTER;
|
|| keyCode == KeyEvent.KEYCODE_DPAD_CENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ComponentListener extends Player.DefaultEventListener
|
private final class ComponentListener
|
||||||
implements TextOutput, VideoListener, OnLayoutChangeListener {
|
implements Player.EventListener, TextOutput, VideoListener, OnLayoutChangeListener {
|
||||||
|
|
||||||
// TextOutput implementation
|
// TextOutput implementation
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ public abstract class Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player.EventListener listener =
|
Player.EventListener listener =
|
||||||
new Player.DefaultEventListener() {
|
new Player.EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTimelineChanged(
|
public void onTimelineChanged(
|
||||||
Timeline timeline, Object manifest, @Player.TimelineChangeReason int reason) {
|
Timeline timeline, Object manifest, @Player.TimelineChangeReason int reason) {
|
||||||
@ -618,13 +618,14 @@ public abstract class Action {
|
|||||||
if (nextAction == null) {
|
if (nextAction == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.addListener(new Player.DefaultEventListener() {
|
player.addListener(
|
||||||
@Override
|
new Player.EventListener() {
|
||||||
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
|
@Override
|
||||||
player.removeListener(this);
|
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
|
||||||
nextAction.schedule(player, trackSelector, surface, handler);
|
player.removeListener(this);
|
||||||
}
|
nextAction.schedule(player, trackSelector, surface, handler);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -663,15 +664,16 @@ public abstract class Action {
|
|||||||
if (targetPlaybackState == player.getPlaybackState()) {
|
if (targetPlaybackState == player.getPlaybackState()) {
|
||||||
nextAction.schedule(player, trackSelector, surface, handler);
|
nextAction.schedule(player, trackSelector, surface, handler);
|
||||||
} else {
|
} else {
|
||||||
player.addListener(new Player.DefaultEventListener() {
|
player.addListener(
|
||||||
@Override
|
new Player.EventListener() {
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
@Override
|
||||||
if (targetPlaybackState == playbackState) {
|
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
player.removeListener(this);
|
if (targetPlaybackState == playbackState) {
|
||||||
nextAction.schedule(player, trackSelector, surface, handler);
|
player.removeListener(this);
|
||||||
}
|
nextAction.schedule(player, trackSelector, surface, handler);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,13 +706,14 @@ public abstract class Action {
|
|||||||
if (nextAction == null) {
|
if (nextAction == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.addListener(new Player.DefaultEventListener() {
|
player.addListener(
|
||||||
@Override
|
new Player.EventListener() {
|
||||||
public void onSeekProcessed() {
|
@Override
|
||||||
player.removeListener(this);
|
public void onSeekProcessed() {
|
||||||
nextAction.schedule(player, trackSelector, surface, handler);
|
player.removeListener(this);
|
||||||
}
|
nextAction.schedule(player, trackSelector, surface, handler);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,11 +49,12 @@ import com.google.android.exoplayer2.util.HandlerWrapper;
|
|||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
import com.google.android.exoplayer2.video.VideoRendererEventListener;
|
||||||
|
|
||||||
/**
|
/** A {@link HostedTest} for {@link ExoPlayer} playback tests. */
|
||||||
* A {@link HostedTest} for {@link ExoPlayer} playback tests.
|
public abstract class ExoHostedTest
|
||||||
*/
|
implements Player.EventListener,
|
||||||
public abstract class ExoHostedTest extends Player.DefaultEventListener implements HostedTest,
|
HostedTest,
|
||||||
AudioRendererEventListener, VideoRendererEventListener {
|
AudioRendererEventListener,
|
||||||
|
VideoRendererEventListener {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// DefaultAudioSink is able to work around spurious timestamps reported by the platform (by
|
// DefaultAudioSink is able to work around spurious timestamps reported by the platform (by
|
||||||
|
@ -51,11 +51,8 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
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 extends Player.DefaultEventListener
|
|
||||||
implements ActionSchedule.Callback {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder to set-up a {@link ExoPlayerTestRunner}. Default fake implementations will be used for
|
* Builder to set-up a {@link ExoPlayerTestRunner}. Default fake implementations will be used for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user