Migrate library usages of SimpleExoPlayer to ExoPlayer.

PiperOrigin-RevId: 402853522
This commit is contained in:
samrobinson 2021-10-13 17:37:08 +01:00 committed by Oliver Woodman
parent 3b8eba2dea
commit 3c19850ed3
59 changed files with 377 additions and 416 deletions

View File

@ -37,8 +37,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder; import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.ui.PlayerControlView; import com.google.android.exoplayer2.ui.PlayerControlView;
import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
@ -48,8 +48,8 @@ import com.google.android.gms.cast.framework.CastContext;
import com.google.android.gms.dynamite.DynamiteModule; import com.google.android.gms.dynamite.DynamiteModule;
/** /**
* An activity that plays video using {@link SimpleExoPlayer} and supports casting using ExoPlayer's * An activity that plays video using {@link ExoPlayer} and supports casting using ExoPlayer's Cast
* Cast extension. * extension.
*/ */
public class MainActivity extends AppCompatActivity public class MainActivity extends AppCompatActivity
implements OnClickListener, PlayerManager.Listener { implements OnClickListener, PlayerManager.Listener {

View File

@ -25,7 +25,6 @@ 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.TimelineChangeReason; import com.google.android.exoplayer2.Player.TimelineChangeReason;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.TracksInfo; import com.google.android.exoplayer2.TracksInfo;
import com.google.android.exoplayer2.ext.cast.CastPlayer; import com.google.android.exoplayer2.ext.cast.CastPlayer;
@ -64,7 +63,7 @@ import java.util.ArrayList;
private Player currentPlayer; private Player currentPlayer;
/** /**
* Creates a new manager for {@link SimpleExoPlayer} and {@link CastPlayer}. * Creates a new manager for {@link ExoPlayer} and {@link CastPlayer}.
* *
* @param listener A {@link Listener} for queue position changes. * @param listener A {@link Listener} for queue position changes.
* @param localPlayerView The {@link PlayerView} for local playback. * @param localPlayerView The {@link PlayerView} for local playback.

View File

@ -27,7 +27,6 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaDrm; import com.google.android.exoplayer2.drm.FrameworkMediaDrm;
@ -65,7 +64,7 @@ public final class MainActivity extends Activity {
@Nullable private PlayerView playerView; @Nullable private PlayerView playerView;
@Nullable private VideoProcessingGLSurfaceView videoProcessingGLSurfaceView; @Nullable private VideoProcessingGLSurfaceView videoProcessingGLSurfaceView;
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -173,7 +172,7 @@ public final class MainActivity extends Activity {
throw new IllegalStateException(); throw new IllegalStateException();
} }
SimpleExoPlayer player = new ExoPlayer.Builder(getApplicationContext()).build(); ExoPlayer player = new ExoPlayer.Builder(getApplicationContext()).build();
player.setRepeatMode(Player.REPEAT_MODE_ALL); player.setRepeatMode(Player.REPEAT_MODE_ALL);
player.setMediaSource(mediaSource); player.setMediaSource(mediaSource);
player.prepare(); player.prepare();

View File

@ -37,7 +37,6 @@ import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.TracksInfo; import com.google.android.exoplayer2.TracksInfo;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.drm.FrameworkMediaDrm; import com.google.android.exoplayer2.drm.FrameworkMediaDrm;
@ -61,7 +60,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** An activity that plays media using {@link SimpleExoPlayer}. */ /** An activity that plays media using {@link ExoPlayer}. */
public class PlayerActivity extends AppCompatActivity public class PlayerActivity extends AppCompatActivity
implements OnClickListener, StyledPlayerControlView.VisibilityListener { implements OnClickListener, StyledPlayerControlView.VisibilityListener {
@ -75,7 +74,7 @@ public class PlayerActivity extends AppCompatActivity
protected StyledPlayerView playerView; protected StyledPlayerView playerView;
protected LinearLayout debugRootView; protected LinearLayout debugRootView;
protected TextView debugTextView; protected TextView debugTextView;
protected @Nullable SimpleExoPlayer player; protected @Nullable ExoPlayer player;
private boolean isShowingTrackSelectionDialog; private boolean isShowingTrackSelectionDialog;
private Button selectTracksButton; private Button selectTracksButton;

View File

@ -31,7 +31,6 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaDrm; import com.google.android.exoplayer2.drm.FrameworkMediaDrm;
@ -67,7 +66,7 @@ public final class MainActivity extends Activity {
@Nullable private SurfaceView nonFullScreenView; @Nullable private SurfaceView nonFullScreenView;
@Nullable private SurfaceView currentOutputView; @Nullable private SurfaceView currentOutputView;
@Nullable private static SimpleExoPlayer player; @Nullable private static ExoPlayer player;
@Nullable private static SurfaceControl surfaceControl; @Nullable private static SurfaceControl surfaceControl;
@Nullable private static Surface videoSurface; @Nullable private static Surface videoSurface;
@ -217,7 +216,7 @@ public final class MainActivity extends Activity {
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
SimpleExoPlayer player = new ExoPlayer.Builder(getApplicationContext()).build(); ExoPlayer player = new ExoPlayer.Builder(getApplicationContext()).build();
player.setMediaSource(mediaSource); player.setMediaSource(mediaSource);
player.prepare(); player.prepare();
player.play(); player.play();

View File

@ -53,7 +53,7 @@ MediaSourceFactory mediaSourceFactory =
new DefaultMediaSourceFactory(context) new DefaultMediaSourceFactory(context)
.setAdsLoaderProvider(adsLoaderProvider) .setAdsLoaderProvider(adsLoaderProvider)
.setAdViewProvider(playerView); .setAdViewProvider(playerView);
SimpleExoPlayer player = new ExoPlayer.Builder(context) ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(mediaSourceFactory) .setMediaSourceFactory(mediaSourceFactory)
.build(); .build();
~~~ ~~~
@ -209,7 +209,7 @@ events to an ad SDK or ad server. For example, the media stream may include
timed events that need to be reported by the client (see [supported formats][] timed events that need to be reported by the client (see [supported formats][]
for information on what timed metadata formats are supported by ExoPlayer). Apps for information on what timed metadata formats are supported by ExoPlayer). Apps
can listen for timed metadata events from the player, e.g., via can listen for timed metadata events from the player, e.g., via
`SimpleExoPlayer.addMetadataOutput`. `ExoPlayer.addMetadataOutput`.
The IMA extension currently only handles client-side ad insertion. It does not The IMA extension currently only handles client-side ad insertion. It does not
provide any integration with the DAI part of the IMA SDK. provide any integration with the DAI part of the IMA SDK.

View File

@ -44,7 +44,7 @@ implementations. You can easily add your own listener and override only the
methods you are interested in: methods you are interested in:
~~~ ~~~
simpleExoPlayer.addAnalyticsListener(new AnalyticsListener() { exoPlayer.addAnalyticsListener(new AnalyticsListener() {
@Override @Override
public void onPlaybackStateChanged( public void onPlaybackStateChanged(
EventTime eventTime, @Player.State int state) { EventTime eventTime, @Player.State int state) {
@ -98,7 +98,7 @@ current playback session at any time using
`PlaybackStatsListener.getPlaybackStats()`. `PlaybackStatsListener.getPlaybackStats()`.
~~~ ~~~
simpleExoPlayer.addAnalyticsListener( exoPlayer.addAnalyticsListener(
new PlaybackStatsListener( new PlaybackStatsListener(
/* keepHistory= */ true, (eventTime, playbackStats) -> { /* keepHistory= */ true, (eventTime, playbackStats) -> {
// Analytics data for the session started at `eventTime` is ready. // Analytics data for the session started at `eventTime` is ready.
@ -246,7 +246,7 @@ class ExtendedCollector extends AnalyticsCollector {
} }
// Usage - Setup and listener registration. // Usage - Setup and listener registration.
SimpleExoPlayer player = new ExoPlayer.Builder(context) ExoPlayer player = new ExoPlayer.Builder(context)
.setAnalyticsCollector(new ExtendedCollector()) .setAnalyticsCollector(new ExtendedCollector())
.build(); .build();
player.addAnalyticsListener(new ExtendedListener() { player.addAnalyticsListener(new ExtendedListener() {

View File

@ -4,13 +4,13 @@ title: Customization
At the core of the ExoPlayer library is the `Player` interface. A `Player` At the core of the ExoPlayer library is the `Player` interface. A `Player`
exposes traditional high-level media player functionality such as the ability to exposes traditional high-level media player functionality such as the ability to
buffer media, play, pause and seek. The default implementations `ExoPlayer` and buffer media, play, pause and seek. The default implementation `ExoPlayer` is
`SimpleExoPlayer` are designed to make few assumptions about (and hence impose designed to make few assumptions about (and hence impose few restrictions on)
few restrictions on) the type of media being played, how and where it is stored, the type of media being played, how and where it is stored, and how it is
and how it is rendered. Rather than implementing the loading and rendering of rendered. Rather than implementing the loading and rendering of media directly,
media directly, `ExoPlayer` implementations delegate this work to components `ExoPlayer` implementations delegate this work to components that are injected
that are injected when a player is created or when new media sources are passed when a player is created or when new media sources are passed to the player.
to the player. Components common to all `ExoPlayer` implementations are: Components common to all `ExoPlayer` implementations are:
* `MediaSource` instances that define media to be played, load the media, and * `MediaSource` instances that define media to be played, load the media, and
from which the loaded media can be read. `MediaSource` instances are created from which the loaded media can be read. `MediaSource` instances are created
@ -59,7 +59,7 @@ DefaultDataSource.Factory dataSourceFactory =
new DefaultDataSource.Factory(context, httpDataSourceFactory); new DefaultDataSource.Factory(context, httpDataSourceFactory);
// Inject the DefaultDataSourceFactory when creating the player. // Inject the DefaultDataSourceFactory when creating the player.
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context) new ExoPlayer.Builder(context)
.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory)) .setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory))
.build(); .build();
@ -82,7 +82,7 @@ DataSource.Factory cacheDataSourceFactory =
.setCache(simpleCache) .setCache(simpleCache)
.setUpstreamDataSourceFactory(httpDataSourceFactory); .setUpstreamDataSourceFactory(httpDataSourceFactory);
SimpleExoPlayer player = new ExoPlayer.Builder(context) ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory( .setMediaSourceFactory(
new DefaultMediaSourceFactory(cacheDataSourceFactory)) new DefaultMediaSourceFactory(cacheDataSourceFactory))
.build(); .build();
@ -107,7 +107,7 @@ DataSource.Factory dataSourceFactory = () -> {
return dataSource; return dataSource;
}; };
SimpleExoPlayer player = new ExoPlayer.Builder(context) ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory)) .setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory))
.build(); .build();
~~~ ~~~
@ -157,7 +157,7 @@ LoadErrorHandlingPolicy loadErrorHandlingPolicy =
} }
}; };
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context) new ExoPlayer.Builder(context)
.setMediaSourceFactory( .setMediaSourceFactory(
new DefaultMediaSourceFactory(context) new DefaultMediaSourceFactory(context)
@ -181,7 +181,7 @@ DefaultExtractorsFactory extractorsFactory =
new DefaultExtractorsFactory() new DefaultExtractorsFactory()
.setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING); .setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING);
SimpleExoPlayer player = new ExoPlayer.Builder(context) ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory( .setMediaSourceFactory(
new DefaultMediaSourceFactory(context, extractorsFactory)) new DefaultMediaSourceFactory(context, extractorsFactory))
.build(); .build();

View File

@ -17,7 +17,7 @@ You can then create a `MediaItem` for a DASH MPD URI and pass it to the player.
~~~ ~~~
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played. // Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(dashUri)); player.setMediaItem(MediaItem.fromUri(dashUri));
// Prepare the player. // Prepare the player.
@ -45,7 +45,7 @@ MediaSource mediaSource =
new DashMediaSource.Factory(dataSourceFactory) new DashMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(dashUri)); .createMediaSource(MediaItem.fromUri(dashUri));
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played. // Set the media source to be played.
player.setMediaSource(mediaSource); player.setMediaSource(mediaSource);
// Prepare the player. // Prepare the player.

View File

@ -6,7 +6,7 @@ By default ExoPlayer only logs errors. To log player events, the `EventLogger`
class can be used. The additional logging it provides can be helpful for class can be used. The additional logging it provides can be helpful for
understanding what the player is doing, as well as for debugging playback understanding what the player is doing, as well as for debugging playback
issues. `EventLogger` implements `AnalyticsListener`, so registering an instance issues. `EventLogger` implements `AnalyticsListener`, so registering an instance
with a `SimpleExoPlayer` is easy: with an `ExoPlayer` is easy:
``` ```
player.addAnalyticsListener(new EventLogger(trackSelector)); player.addAnalyticsListener(new EventLogger(trackSelector));

View File

@ -322,7 +322,7 @@ DataSource.Factory cacheDataSourceFactory =
.setUpstreamDataSourceFactory(httpDataSourceFactory) .setUpstreamDataSourceFactory(httpDataSourceFactory)
.setCacheWriteDataSinkFactory(null); // Disable writing. .setCacheWriteDataSinkFactory(null); // Disable writing.
SimpleExoPlayer player = new ExoPlayer.Builder(context) ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory( .setMediaSourceFactory(
new DefaultMediaSourceFactory(cacheDataSourceFactory)) new DefaultMediaSourceFactory(cacheDataSourceFactory))
.build(); .build();

View File

@ -14,7 +14,7 @@ For simple use cases, getting started with `ExoPlayer` consists of implementing
the following steps: the following steps:
1. Add ExoPlayer as a dependency to your project. 1. Add ExoPlayer as a dependency to your project.
1. Create a `SimpleExoPlayer` instance. 1. Create an `ExoPlayer` instance.
1. Attach the player to a view (for video output and user input). 1. Attach the player to a view (for video output and user input).
1. Prepare the player with a `MediaItem` to play. 1. Prepare the player with a `MediaItem` to play.
1. Release the player when done. 1. Release the player when done.
@ -97,7 +97,7 @@ a range of customization options. The code below is the simplest example of
creating an instance. creating an instance.
~~~ ~~~
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
~~~ ~~~
{: .language-java} {: .language-java}
@ -117,12 +117,12 @@ which the player must be accessed can be queried using
`Player.getApplicationLooper`. `Player.getApplicationLooper`.
If you see `IllegalStateException` being thrown with the message "Player is If you see `IllegalStateException` being thrown with the message "Player is
accessed on the wrong thread", then some code in your app is accessing a accessed on the wrong thread", then some code in your app is accessing an
`SimpleExoPlayer` instance on the wrong thread (the exception's stack trace `ExoPlayer` instance on the wrong thread (the exception's stack trace shows you
shows you where). You can temporarily opt out from these exceptions being thrown where). You can temporarily opt out from these exceptions being thrown by
by calling `SimpleExoPlayer.setThrowsWhenUsingWrongThread(false)`, in which case calling `ExoPlayer.setThrowsWhenUsingWrongThread(false)`, in which case the
the issue will be logged as a warning instead. Using this opt out is not safe issue will be logged as a warning instead. Using this opt out is not safe and
and may result in unexpected or obscure errors. It will be removed in ExoPlayer may result in unexpected or obscure errors. It will be removed in ExoPlayer
2.16. 2.16.
{:.info} {:.info}
@ -148,10 +148,10 @@ useful for audio only use cases.
Use of ExoPlayer's pre-built UI components is optional. For video applications Use of ExoPlayer's pre-built UI components is optional. For video applications
that implement their own UI, the target `SurfaceView`, `TextureView`, that implement their own UI, the target `SurfaceView`, `TextureView`,
`SurfaceHolder` or `Surface` can be set using `SimpleExoPlayer`'s `SurfaceHolder` or `Surface` can be set using `ExoPlayer`'s
`setVideoSurfaceView`, `setVideoTextureView`, `setVideoSurfaceHolder` and `setVideoSurfaceView`, `setVideoTextureView`, `setVideoSurfaceHolder` and
`setVideoSurface` methods respectively. `SimpleExoPlayer`'s `addTextOutput` `setVideoSurface` methods respectively. `ExoPlayer`'s `addTextOutput` method can
method can be used to receive captions that should be rendered during playback. be used to receive captions that should be rendered during playback.
## Populating the playlist and preparing the player ## ## Populating the playlist and preparing the player ##

View File

@ -18,7 +18,7 @@ player.
~~~ ~~~
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played. // Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(hlsUri)); player.setMediaItem(MediaItem.fromUri(hlsUri));
// Prepare the player. // Prepare the player.
@ -48,7 +48,7 @@ HlsMediaSource hlsMediaSource =
new HlsMediaSource.Factory(dataSourceFactory) new HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(hlsUri)); .createMediaSource(MediaItem.fromUri(hlsUri));
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played. // Set the media source to be played.
player.setMediaSource(hlsMediaSource); player.setMediaSource(hlsMediaSource);
// Prepare the player. // Prepare the player.

View File

@ -180,15 +180,15 @@ together in `onEvents`.
## Using AnalyticsListener ## ## Using AnalyticsListener ##
When using `SimpleExoPlayer`, an `AnalyticsListener` can be registered with the When using `ExoPlayer`, an `AnalyticsListener` can be registered with the player
player by calling `addAnalyticsListener`. `AnalyticsListener` implementations by calling `addAnalyticsListener`. `AnalyticsListener` implementations are able
are able to listen to detailed events that may be useful for analytics and to listen to detailed events that may be useful for analytics and logging
logging purposes. Please refer to the [analytics page][] for more details. purposes. Please refer to the [analytics page][] for more details.
### Using EventLogger ### ### Using EventLogger ###
`EventLogger` is an `AnalyticsListener` provided directly by the library for `EventLogger` is an `AnalyticsListener` provided directly by the library for
logging purposes. It can be added to a `SimpleExoPlayer` to enable useful logging purposes. It can be added to an `ExoPlayer` to enable useful
additional logging with a single line. additional logging with a single line.
``` ```

View File

@ -96,7 +96,7 @@ values will override parameters defined by the media.
~~~ ~~~
// Global settings. // Global settings.
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context) new ExoPlayer.Builder(context)
.setMediaSourceFactory( .setMediaSourceFactory(
new DefaultMediaSourceFactory(context).setLiveTargetOffsetMs(5000)) new DefaultMediaSourceFactory(context).setLiveTargetOffsetMs(5000))
@ -166,7 +166,7 @@ implementation, which is `DefaultLivePlaybackSpeedControl`. In both cases an
instance can be set when building the player: instance can be set when building the player:
~~~ ~~~
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context) new ExoPlayer.Builder(context)
.setLivePlaybackSpeedControl( .setLivePlaybackSpeedControl(
new DefaultLivePlaybackSpeedControl.Builder() new DefaultLivePlaybackSpeedControl.Builder()

View File

@ -37,7 +37,7 @@ MediaSourceFactory mediaSourceFactory =
new DefaultMediaSourceFactory(cacheDataSourceFactory) new DefaultMediaSourceFactory(cacheDataSourceFactory)
.setAdsLoaderProvider(adsLoaderProvider) .setAdsLoaderProvider(adsLoaderProvider)
.setAdViewProvider(playerView); .setAdViewProvider(playerView);
SimpleExoPlayer player = new ExoPlayer.Builder(context) ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(mediaSourceFactory) .setMediaSourceFactory(mediaSourceFactory)
.build(); .build();
~~~ ~~~

View File

@ -32,8 +32,8 @@ where `PreferredHttpDataSource.Factory` is the factory corresponding to your
preferred network stack. The `DefaultDataSourceFactory` layer adds in support preferred network stack. The `DefaultDataSourceFactory` layer adds in support
for non-http(s) sources such as local files. for non-http(s) sources such as local files.
The example below shows how to build a `SimpleExoPlayer` that will use The example below shows how to build an `ExoPlayer` that will use the Cronet
the Cronet network stack and also support playback of non-http(s) content. network stack and also support playback of non-http(s) content.
~~~ ~~~
// Given a CronetEngine and Executor, build a CronetDataSource.Factory. // Given a CronetEngine and Executor, build a CronetDataSource.Factory.
@ -49,7 +49,7 @@ DefaultDataSource.Factory dataSourceFactory =
/* baseDataSourceFactory= */ cronetDataSourceFactory); /* baseDataSourceFactory= */ cronetDataSourceFactory);
// Inject the DefaultDataSourceFactory when creating the player. // Inject the DefaultDataSourceFactory when creating the player.
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context) new ExoPlayer.Builder(context)
.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory)) .setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory))
.build(); .build();

View File

@ -166,9 +166,9 @@ This can be customized by providing a custom shuffle order implementation:
~~~ ~~~
// Set the custom shuffle order. // Set the custom shuffle order.
simpleExoPlayer.setShuffleOrder(shuffleOrder); exoPlayer.setShuffleOrder(shuffleOrder);
// Enable shuffle mode. // Enable shuffle mode.
simpleExoPlayer.setShuffleModeEnabled(/* shuffleModeEnabled= */ true); exoPlayer.setShuffleModeEnabled(/* shuffleModeEnabled= */ true);
~~~ ~~~
{: .language-java} {: .language-java}

View File

@ -11,7 +11,7 @@ it to the player.
~~~ ~~~
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played. // Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(progressiveUri)); player.setMediaItem(MediaItem.fromUri(progressiveUri));
// Prepare the player. // Prepare the player.
@ -31,7 +31,7 @@ DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory) MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(progressiveUri)); .createMediaSource(MediaItem.fromUri(progressiveUri));
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played. // Set the media source to be played.
player.setMediaSource(mediaSource); player.setMediaSource(mediaSource);
// Prepare the player. // Prepare the player.

View File

@ -17,7 +17,7 @@ You can then create a `MediaItem` for an RTSP URI and pass it to the player.
~~~ ~~~
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played. // Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(rtspUri)); player.setMediaItem(MediaItem.fromUri(rtspUri));
// Prepare the player. // Prepare the player.
@ -43,7 +43,7 @@ MediaSource mediaSource =
new RtspMediaSource.Factory() new RtspMediaSource.Factory()
.createMediaSource(MediaItem.fromUri(rtspUri)); .createMediaSource(MediaItem.fromUri(rtspUri));
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played. // Set the media source to be played.
player.setMediaSource(mediaSource); player.setMediaSource(mediaSource);
// Prepare the player. // Prepare the player.

View File

@ -49,7 +49,7 @@ By default, the player's renderers will be created using
none of them will be removed by code shrinking. If you know that your app only none of them will be removed by code shrinking. If you know that your app only
needs a subset of renderers, you can specify your own `RenderersFactory` needs a subset of renderers, you can specify your own `RenderersFactory`
instead. For example, an app that only plays audio can define a factory like instead. For example, an app that only plays audio can define a factory like
this when instantiating `SimpleExoPlayer` instances: this when instantiating `ExoPlayer` instances:
~~~ ~~~
RenderersFactory audioOnlyRenderersFactory = RenderersFactory audioOnlyRenderersFactory =
@ -58,7 +58,7 @@ RenderersFactory audioOnlyRenderersFactory =
new MediaCodecAudioRenderer( new MediaCodecAudioRenderer(
context, MediaCodecSelector.DEFAULT, handler, audioListener) context, MediaCodecSelector.DEFAULT, handler, audioListener)
}; };
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, audioOnlyRenderersFactory).build(); new ExoPlayer.Builder(context, audioOnlyRenderersFactory).build();
~~~ ~~~
{: .language-java} {: .language-java}
@ -80,7 +80,7 @@ an app that only needs to play mp4 files can provide a factory like:
~~~ ~~~
ExtractorsFactory mp4ExtractorFactory = ExtractorsFactory mp4ExtractorFactory =
() -> new Extractor[] {new Mp4Extractor()}; () -> new Extractor[] {new Mp4Extractor()};
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, mp4ExtractorFactory).build(); new ExoPlayer.Builder(context, mp4ExtractorFactory).build();
~~~ ~~~
{: .language-java} {: .language-java}
@ -98,18 +98,18 @@ constructor, if your app is doing one of the following:
~~~ ~~~
// Only playing DASH, HLS or SmoothStreaming. // Only playing DASH, HLS or SmoothStreaming.
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY).build(); new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY).build();
// Providing a customized `DefaultMediaSourceFactory` // Providing a customized `DefaultMediaSourceFactory`
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY) new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY)
.setMediaSourceFactory( .setMediaSourceFactory(
new DefaultMediaSourceFactory(context, customExtractorsFactory)) new DefaultMediaSourceFactory(context, customExtractorsFactory))
.build(); .build();
// Using a MediaSource directly. // Using a MediaSource directly.
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY).build(); new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY).build();
ProgressiveMediaSource mediaSource = ProgressiveMediaSource mediaSource =
new ProgressiveMediaSource.Factory( new ProgressiveMediaSource.Factory(

View File

@ -19,7 +19,7 @@ to the player.
~~~ ~~~
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played. // Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(ssUri)); player.setMediaItem(MediaItem.fromUri(ssUri));
// Prepare the player. // Prepare the player.
@ -47,7 +47,7 @@ MediaSource mediaSource =
new SsMediaSource.Factory(dataSourceFactory) new SsMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(ssUri)); .createMediaSource(MediaItem.fromUri(ssUri));
// Create a player instance. // Create a player instance.
SimpleExoPlayer player = new ExoPlayer.Builder(context).build(); ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played. // Set the media source to be played.
player.setMediaSource(mediaSource); player.setMediaSource(mediaSource);
// Prepare the player. // Prepare the player.

View File

@ -8,7 +8,7 @@ of which can be provided whenever an `ExoPlayer` is built.
~~~ ~~~
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context); DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context) new ExoPlayer.Builder(context)
.setTrackSelector(trackSelector) .setTrackSelector(trackSelector)
.build(); .build();

View File

@ -230,7 +230,7 @@ audio when your app is in the background:
from killing your process to free up resources. from killing your process to free up resources.
1. You need to hold a [`WifiLock`][] and a [`WakeLock`][]. These ensure that the 1. You need to hold a [`WifiLock`][] and a [`WakeLock`][]. These ensure that the
system keeps the WiFi radio and CPU awake. This can be easily done if using system keeps the WiFi radio and CPU awake. This can be easily done if using
[`SimpleExoPlayer`][] by calling [`setWakeMode`][], which will automatically [`ExoPlayer`][] by calling [`setWakeMode`][], which will automatically
acquire and release the required locks at the correct times. acquire and release the required locks at the correct times.
It's important that you release the locks (if not using `setWakeMode`) and stop It's important that you release the locks (if not using `setWakeMode`) and stop
@ -335,8 +335,8 @@ is the official way to play YouTube videos on Android.
[foreground service]: https://developer.android.com/guide/components/services.html#Foreground [foreground service]: https://developer.android.com/guide/components/services.html#Foreground
[`WifiLock`]: {{ site.android_sdk }}/android/net/wifi/WifiManager.WifiLock.html [`WifiLock`]: {{ site.android_sdk }}/android/net/wifi/WifiManager.WifiLock.html
[`WakeLock`]: {{ site.android_sdk }}/android/os/PowerManager.WakeLock.html [`WakeLock`]: {{ site.android_sdk }}/android/os/PowerManager.WakeLock.html
[`SimpleExoPlayer`]: {{ site.exo_sdk }}/SimpleExoPlayer.html [`ExoPlayer`]: {{ site.exo_sdk }}/ExoPlayer.html
[`setWakeMode`]: {{ site.exo_sdk }}/SimpleExoPlayer.html#setWakeMode(int) [`setWakeMode`]: {{ site.exo_sdk }}/ExoPlayer.html#setWakeMode(int)
[A note on threading]: {{ site.base_url }}/hello-world.html#a-note-on-threading [A note on threading]: {{ site.base_url }}/hello-world.html#a-note-on-threading
[OkHttp extension]: {{ site.release_v2 }}/extensions/okhttp [OkHttp extension]: {{ site.release_v2 }}/extensions/okhttp
[CORS enabled]: https://www.w3.org/wiki/CORS_Enabled [CORS enabled]: https://www.w3.org/wiki/CORS_Enabled

View File

@ -29,7 +29,6 @@ import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.audio.AudioProcessor; import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioSink; import com.google.android.exoplayer2.audio.AudioSink;
import com.google.android.exoplayer2.audio.DefaultAudioSink; import com.google.android.exoplayer2.audio.DefaultAudioSink;
@ -96,7 +95,7 @@ public class FlacPlaybackTest {
private final Uri uri; private final Uri uri;
private final AudioSink audioSink; private final AudioSink audioSink;
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
@Nullable private PlaybackException playbackException; @Nullable private PlaybackException playbackException;
public TestPlaybackRunnable(Uri uri, Context context, AudioSink audioSink) { public TestPlaybackRunnable(Uri uri, Context context, AudioSink audioSink) {

View File

@ -25,11 +25,11 @@ import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule; import androidx.test.rule.ActivityTestRule;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
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.TimelineChangeReason; import com.google.android.exoplayer2.Player.TimelineChangeReason;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline.Window; import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
@ -192,7 +192,7 @@ public final class ImaPlaybackTest {
private final List<AdId> expectedAdIds; private final List<AdId> expectedAdIds;
private final List<AdId> seenAdIds; private final List<AdId> seenAdIds;
private @MonotonicNonNull ImaAdsLoader imaAdsLoader; private @MonotonicNonNull ImaAdsLoader imaAdsLoader;
private @MonotonicNonNull SimpleExoPlayer player; private @MonotonicNonNull ExoPlayer player;
private ImaHostedTest(Uri contentUri, String adsResponse, AdId... expectedAdIds) { private ImaHostedTest(Uri contentUri, String adsResponse, AdId... expectedAdIds) {
// fullPlaybackNoSeeking is false as the playback lasts longer than the content source // fullPlaybackNoSeeking is false as the playback lasts longer than the content source
@ -207,7 +207,7 @@ public final class ImaPlaybackTest {
} }
@Override @Override
protected SimpleExoPlayer buildExoPlayer( protected ExoPlayer buildExoPlayer(
HostActivity host, Surface surface, MappingTrackSelector trackSelector) { HostActivity host, Surface surface, MappingTrackSelector trackSelector) {
player = super.buildExoPlayer(host, surface, trackSelector); player = super.buildExoPlayer(host, surface, trackSelector);
player.addAnalyticsListener( player.addAnalyticsListener(

View File

@ -29,7 +29,6 @@ import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource; import com.google.android.exoplayer2.source.ProgressiveMediaSource;
@ -79,7 +78,7 @@ public class OpusPlaybackTest {
private final Context context; private final Context context;
private final Uri uri; private final Uri uri;
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
@Nullable private PlaybackException playbackException; @Nullable private PlaybackException playbackException;
public TestPlaybackRunnable(Uri uri, Context context) { public TestPlaybackRunnable(Uri uri, Context context) {

View File

@ -30,7 +30,6 @@ import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource; import com.google.android.exoplayer2.source.ProgressiveMediaSource;
@ -107,7 +106,7 @@ public class VpxPlaybackTest {
private final Context context; private final Context context;
private final Uri uri; private final Uri uri;
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
@Nullable private PlaybackException playbackException; @Nullable private PlaybackException playbackException;
public TestPlaybackRunnable(Uri uri, Context context) { public TestPlaybackRunnable(Uri uri, Context context) {

View File

@ -54,7 +54,7 @@ public final class ClippedPlaybackTest {
// Expect the clipping to affect both subtitles and video. // Expect the clipping to affect both subtitles and video.
.setClipEndPositionMs(1000) .setClipEndPositionMs(1000)
.build(); .build();
AtomicReference<SimpleExoPlayer> player = new AtomicReference<>(); AtomicReference<ExoPlayer> player = new AtomicReference<>();
TextCapturingPlaybackListener textCapturer = new TextCapturingPlaybackListener(); TextCapturingPlaybackListener textCapturer = new TextCapturingPlaybackListener();
getInstrumentation() getInstrumentation()
.runOnMainSync( .runOnMainSync(
@ -96,7 +96,7 @@ public final class ClippedPlaybackTest {
// subtitle content (3.5s). // subtitle content (3.5s).
.setClipEndPositionMs(4_000) .setClipEndPositionMs(4_000)
.build()); .build());
AtomicReference<SimpleExoPlayer> player = new AtomicReference<>(); AtomicReference<ExoPlayer> player = new AtomicReference<>();
TextCapturingPlaybackListener textCapturer = new TextCapturingPlaybackListener(); TextCapturingPlaybackListener textCapturer = new TextCapturingPlaybackListener();
getInstrumentation() getInstrumentation()
.runOnMainSync( .runOnMainSync(

View File

@ -24,7 +24,6 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.util.ConditionVariable; import com.google.android.exoplayer2.util.ConditionVariable;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockResponse;
@ -64,7 +63,7 @@ public final class DrmPlaybackTest {
.setLicenseUri(mockWebServer.url("license").toString()) .setLicenseUri(mockWebServer.url("license").toString())
.build()) .build())
.build(); .build();
AtomicReference<SimpleExoPlayer> player = new AtomicReference<>(); AtomicReference<ExoPlayer> player = new AtomicReference<>();
ConditionVariable playbackComplete = new ConditionVariable(); ConditionVariable playbackComplete = new ConditionVariable();
AtomicReference<PlaybackException> playbackException = new AtomicReference<>(); AtomicReference<PlaybackException> playbackException = new AtomicReference<>();
getInstrumentation() getInstrumentation()

View File

@ -21,11 +21,11 @@ import com.google.android.exoplayer2.metadata.MetadataOutput;
import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.text.TextOutput;
import com.google.android.exoplayer2.video.VideoRendererEventListener; import com.google.android.exoplayer2.video.VideoRendererEventListener;
/** Builds {@link Renderer} instances for use by a {@link SimpleExoPlayer}. */ /** Builds {@link Renderer} instances for use by an {@link ExoPlayer}. */
public interface RenderersFactory { public interface RenderersFactory {
/** /**
* Builds the {@link Renderer} instances for a {@link SimpleExoPlayer}. * Builds the {@link Renderer} instances for an {@link ExoPlayer}.
* *
* @param eventHandler A handler to use when invoking event listeners and outputs. * @param eventHandler A handler to use when invoking event listeners and outputs.
* @param videoRendererEventListener An event listener for video renderers. * @param videoRendererEventListener An event listener for video renderers.

View File

@ -18,32 +18,32 @@ package com.google.android.exoplayer2.util;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Looper; import android.os.Looper;
import android.widget.TextView; import android.widget.TextView;
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.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
import java.util.Locale; 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}. * an {@link ExoPlayer}.
*/ */
public class DebugTextViewHelper implements Player.Listener, Runnable { public class DebugTextViewHelper implements Player.Listener, Runnable {
private static final int REFRESH_INTERVAL_MS = 1000; private static final int REFRESH_INTERVAL_MS = 1000;
private final SimpleExoPlayer player; private final ExoPlayer player;
private final TextView textView; private final TextView textView;
private boolean started; private boolean started;
/** /**
* @param player The {@link SimpleExoPlayer} from which debug information should be obtained. Only * @param player The {@link ExoPlayer} from which debug information should be obtained. Only
* players which are accessed on the main thread are supported ({@code * players which are accessed on the main thread are supported ({@code
* player.getApplicationLooper() == Looper.getMainLooper()}). * player.getApplicationLooper() == Looper.getMainLooper()}).
* @param textView The {@link TextView} that should be updated to display the information. * @param textView The {@link TextView} that should be updated to display the information.
*/ */
public DebugTextViewHelper(SimpleExoPlayer player, TextView textView) { public DebugTextViewHelper(ExoPlayer player, TextView textView) {
Assertions.checkArgument(player.getApplicationLooper() == Looper.getMainLooper()); Assertions.checkArgument(player.getApplicationLooper() == Looper.getMainLooper());
this.player = player; this.player = player;
this.textView = textView; this.textView = textView;

View File

@ -81,7 +81,6 @@ import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Window; import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.TracksInfo; import com.google.android.exoplayer2.TracksInfo;
@ -1048,7 +1047,7 @@ public final class AnalyticsCollectorTest {
.executeRunnable( .executeRunnable(
new PlayerRunnable() { new PlayerRunnable() {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(ExoPlayer player) {
player.addListener( player.addListener(
new Player.Listener() { new Player.Listener() {
@Override @Override
@ -1422,7 +1421,7 @@ public final class AnalyticsCollectorTest {
.executeRunnable( .executeRunnable(
new PlayerRunnable() { new PlayerRunnable() {
@Override @Override
public void run(SimpleExoPlayer player) { public void run(ExoPlayer player) {
player.getAnalyticsCollector().notifySeekStarted(); player.getAnalyticsCollector().notifySeekStarted();
} }
}) })
@ -1653,7 +1652,7 @@ public final class AnalyticsCollectorTest {
@Test @Test
public void onEvents_isReportedWithCorrectEventTimes() throws Exception { public void onEvents_isReportedWithCorrectEventTimes() throws Exception {
SimpleExoPlayer player = ExoPlayer player =
new TestExoPlayerBuilder(ApplicationProvider.getApplicationContext()).build(); new TestExoPlayerBuilder(ApplicationProvider.getApplicationContext()).build();
Surface surface = new Surface(new SurfaceTexture(/* texName= */ 0)); Surface surface = new Surface(new SurfaceTexture(/* texName= */ 0));
player.setVideoSurface(surface); player.setVideoSurface(surface);
@ -1987,7 +1986,7 @@ public final class AnalyticsCollectorTest {
public void release_withCallbacksArrivingAfterRelease_onPlayerReleasedForwardedLast() public void release_withCallbacksArrivingAfterRelease_onPlayerReleasedForwardedLast()
throws Exception { throws Exception {
FakeClock fakeClock = new FakeClock(/* initialTimeMs= */ 0, /* isAutoAdvancing= */ true); FakeClock fakeClock = new FakeClock(/* initialTimeMs= */ 0, /* isAutoAdvancing= */ true);
SimpleExoPlayer simpleExoPlayer = ExoPlayer exoPlayer =
new TestExoPlayerBuilder(ApplicationProvider.getApplicationContext()) new TestExoPlayerBuilder(ApplicationProvider.getApplicationContext())
.setClock(fakeClock) .setClock(fakeClock)
.build(); .build();
@ -2001,16 +2000,16 @@ public final class AnalyticsCollectorTest {
fakeClock.advanceTime(1); fakeClock.advanceTime(1);
} }
}); });
simpleExoPlayer.addAnalyticsListener(analyticsListener); exoPlayer.addAnalyticsListener(analyticsListener);
// Prepare with media to ensure video renderer is enabled. // Prepare with media to ensure video renderer is enabled.
simpleExoPlayer.setMediaSource( exoPlayer.setMediaSource(
new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT)); new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT));
simpleExoPlayer.prepare(); exoPlayer.prepare();
TestPlayerRunHelper.runUntilPlaybackState(simpleExoPlayer, Player.STATE_READY); TestPlayerRunHelper.runUntilPlaybackState(exoPlayer, Player.STATE_READY);
// Release and add delay on releasing thread to verify timestamps of events. // Release and add delay on releasing thread to verify timestamps of events.
simpleExoPlayer.release(); exoPlayer.release();
long releaseTimeMs = fakeClock.currentTimeMillis(); long releaseTimeMs = fakeClock.currentTimeMillis();
fakeClock.advanceTime(1); fakeClock.advanceTime(1);
ShadowLooper.idleMainLooper(); ShadowLooper.idleMainLooper();
@ -2024,11 +2023,11 @@ public final class AnalyticsCollectorTest {
inOrder.verify(analyticsListener).onVideoDisabled(videoDisabledEventTime.capture(), any()); inOrder.verify(analyticsListener).onVideoDisabled(videoDisabledEventTime.capture(), any());
inOrder inOrder
.verify(analyticsListener) .verify(analyticsListener)
.onEvents(same(simpleExoPlayer), argThat(events -> events.contains(EVENT_VIDEO_DISABLED))); .onEvents(same(exoPlayer), argThat(events -> events.contains(EVENT_VIDEO_DISABLED)));
inOrder.verify(analyticsListener).onPlayerReleased(releasedEventTime.capture()); inOrder.verify(analyticsListener).onPlayerReleased(releasedEventTime.capture());
inOrder inOrder
.verify(analyticsListener) .verify(analyticsListener)
.onEvents(same(simpleExoPlayer), argThat(events -> events.contains(EVENT_PLAYER_RELEASED))); .onEvents(same(exoPlayer), argThat(events -> events.contains(EVENT_PLAYER_RELEASED)));
// Verify order of timestamps of these events. // Verify order of timestamps of these events.
// This verification is needed as a regression test against [internal ref: b/195396384]. The // This verification is needed as a regression test against [internal ref: b/195396384]. The

View File

@ -27,10 +27,10 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.testutil.FakeMediaSource; import com.google.android.exoplayer2.testutil.FakeMediaSource;
@ -49,7 +49,7 @@ import org.robolectric.shadows.ShadowLooper;
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class PlaybackStatsListenerTest { public final class PlaybackStatsListenerTest {
private SimpleExoPlayer player; private ExoPlayer player;
@Before @Before
public void setUp() { public void setUp() {

View File

@ -26,7 +26,6 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import com.google.android.exoplayer2.robolectric.RandomizedMp3Decoder; import com.google.android.exoplayer2.robolectric.RandomizedMp3Decoder;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -87,7 +86,7 @@ public class EndToEndGaplessTest {
@Test @Test
public void testPlayback_twoIdenticalMp3Files() throws Exception { public void testPlayback_twoIdenticalMp3Files() throws Exception {
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()) new ExoPlayer.Builder(ApplicationProvider.getApplicationContext())
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -64,7 +63,7 @@ public class FlacPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -55,7 +54,7 @@ public final class FlvPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -57,7 +56,7 @@ public final class MkaPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -23,7 +23,6 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -63,7 +62,7 @@ public final class MkvPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -60,7 +59,7 @@ public final class Mp3PlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -77,7 +76,7 @@ public class Mp4PlaybackTest {
public void test() throws Exception { public void test() throws Exception {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(applicationContext); CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, renderersFactory) new ExoPlayer.Builder(applicationContext, renderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -58,7 +57,7 @@ public final class OggPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -21,7 +21,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -45,7 +44,7 @@ public final class PlaylistPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();
@ -67,7 +66,7 @@ public final class PlaylistPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -45,7 +44,7 @@ public final class SilencePlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();
@ -66,7 +65,7 @@ public final class SilencePlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -81,7 +80,7 @@ public class TsPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -59,7 +58,7 @@ public final class Vp9PlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -52,7 +51,7 @@ public final class WavPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -38,7 +38,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
@ -143,7 +142,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
public void playbackWithPredefinedAds_playsSuccessfulWithoutRendererResets() throws Exception { public void playbackWithPredefinedAds_playsSuccessfulWithoutRendererResets() throws Exception {
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(context); CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(context);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, renderersFactory) new ExoPlayer.Builder(context, renderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();
@ -202,7 +201,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
public void playbackWithNewlyInsertedAds_playsSuccessfulWithoutRendererResets() throws Exception { public void playbackWithNewlyInsertedAds_playsSuccessfulWithoutRendererResets() throws Exception {
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(context); CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(context);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, renderersFactory) new ExoPlayer.Builder(context, renderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();
@ -262,7 +261,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
throws Exception { throws Exception {
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(context); CapturingRenderersFactory renderersFactory = new CapturingRenderersFactory(context);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context, renderersFactory) new ExoPlayer.Builder(context, renderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();
@ -319,7 +318,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
@Test @Test
public void playbackWithSeek_isHandledCorrectly() throws Exception { public void playbackWithSeek_isHandledCorrectly() throws Exception {
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(context).setClock(new FakeClock(/* isAutoAdvancing= */ true)).build(); new ExoPlayer.Builder(context).setClock(new FakeClock(/* isAutoAdvancing= */ true)).build();
player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1))); player.setVideoSurface(new Surface(new SurfaceTexture(/* texName= */ 1)));

View File

@ -25,7 +25,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
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.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper; import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
@ -54,7 +53,7 @@ public final class DashPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();
@ -81,7 +80,7 @@ public final class DashPlaybackTest {
Context applicationContext = ApplicationProvider.getApplicationContext(); Context applicationContext = ApplicationProvider.getApplicationContext();
CapturingRenderersFactory capturingRenderersFactory = CapturingRenderersFactory capturingRenderersFactory =
new CapturingRenderersFactory(applicationContext); new CapturingRenderersFactory(applicationContext);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(new FakeClock(/* isAutoAdvancing= */ true)) .setClock(new FakeClock(/* isAutoAdvancing= */ true))
.build(); .build();

View File

@ -30,7 +30,6 @@ import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.Listener; import com.google.android.exoplayer2.Player.Listener;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.robolectric.PlaybackOutput; import com.google.android.exoplayer2.robolectric.PlaybackOutput;
import com.google.android.exoplayer2.robolectric.RobolectricUtil; import com.google.android.exoplayer2.robolectric.RobolectricUtil;
import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig;
@ -103,8 +102,7 @@ public final class RtspPlaybackTest {
fakeRtpDataChannel); fakeRtpDataChannel);
try (RtspServer rtspServer = new RtspServer(responseProvider)) { try (RtspServer rtspServer = new RtspServer(responseProvider)) {
SimpleExoPlayer player = ExoPlayer player = createExoPlayer(rtspServer.startAndGetPortNumber(), rtpDataChannelFactory);
createSimpleExoPlayer(rtspServer.startAndGetPortNumber(), rtpDataChannelFactory);
PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory); PlaybackOutput playbackOutput = PlaybackOutput.register(player, capturingRenderersFactory);
player.prepare(); player.prepare();
@ -126,8 +124,7 @@ public final class RtspPlaybackTest {
new RtspServer( new RtspServer(
new ResponseProvider( new ResponseProvider(
clock, ImmutableList.of(mp4aLatmRtpPacketStreamDump), fakeRtpDataChannel))) { clock, ImmutableList.of(mp4aLatmRtpPacketStreamDump), fakeRtpDataChannel))) {
SimpleExoPlayer player = ExoPlayer player = createExoPlayer(rtspServer.startAndGetPortNumber(), rtpDataChannelFactory);
createSimpleExoPlayer(rtspServer.startAndGetPortNumber(), rtpDataChannelFactory);
AtomicReference<Throwable> playbackError = new AtomicReference<>(); AtomicReference<Throwable> playbackError = new AtomicReference<>();
player.prepare(); player.prepare();
@ -148,9 +145,9 @@ public final class RtspPlaybackTest {
} }
} }
private SimpleExoPlayer createSimpleExoPlayer( private ExoPlayer createExoPlayer(
int serverRtspPortNumber, RtpDataChannel.Factory rtpDataChannelFactory) { int serverRtspPortNumber, RtpDataChannel.Factory rtpDataChannelFactory) {
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(applicationContext, capturingRenderersFactory) new ExoPlayer.Builder(applicationContext, capturingRenderersFactory)
.setClock(clock) .setClock(clock)
.build(); .build();

View File

@ -44,7 +44,6 @@ import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.TracksInfo; import com.google.android.exoplayer2.TracksInfo;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
@ -366,7 +365,7 @@ public final class TranscodingTransformer {
private TranscodingTransformer.Listener listener; private TranscodingTransformer.Listener listener;
@Nullable private MuxerWrapper muxerWrapper; @Nullable private MuxerWrapper muxerWrapper;
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
@ProgressState private int progressState; @ProgressState private int progressState;
private TranscodingTransformer( private TranscodingTransformer(

View File

@ -44,7 +44,6 @@ import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.TracksInfo; import com.google.android.exoplayer2.TracksInfo;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
@ -363,7 +362,7 @@ public final class Transformer {
private Transformer.Listener listener; private Transformer.Listener listener;
@Nullable private MuxerWrapper muxerWrapper; @Nullable private MuxerWrapper muxerWrapper;
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
@ProgressState private int progressState; @ProgressState private int progressState;
private Transformer( private Transformer(

View File

@ -29,7 +29,6 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.RendererCapabilities; import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
@ -312,9 +311,9 @@ import java.util.List;
} }
@Override @Override
protected SimpleExoPlayer buildExoPlayer( protected ExoPlayer buildExoPlayer(
HostActivity host, Surface surface, MappingTrackSelector trackSelector) { HostActivity host, Surface surface, MappingTrackSelector trackSelector) {
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(host, new DebugRenderersFactory(host)) new ExoPlayer.Builder(host, new DebugRenderersFactory(host))
.setTrackSelector(trackSelector) .setTrackSelector(trackSelector)
.build(); .build();

View File

@ -23,7 +23,6 @@ import android.os.Looper;
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.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.util.ConditionVariable; import com.google.android.exoplayer2.util.ConditionVariable;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
@ -33,8 +32,8 @@ import java.util.concurrent.atomic.AtomicReference;
import org.checkerframework.checker.nullness.compatqual.NullableType; import org.checkerframework.checker.nullness.compatqual.NullableType;
/** /**
* Helper methods to block the calling thread until the provided {@link SimpleExoPlayer} instance * Helper methods to block the calling thread until the provided {@link ExoPlayer} instance reaches
* reaches a particular state. * a particular state.
*/ */
public class TestPlayerRunHelper { public class TestPlayerRunHelper {
@ -260,7 +259,7 @@ public class TestPlayerRunHelper {
* @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is * @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is
* exceeded. * exceeded.
*/ */
public static void runUntilRenderedFirstFrame(SimpleExoPlayer player) throws TimeoutException { public static void runUntilRenderedFirstFrame(ExoPlayer player) throws TimeoutException {
verifyMainTestThread(player); verifyMainTestThread(player);
AtomicBoolean receivedCallback = new AtomicBoolean(false); AtomicBoolean receivedCallback = new AtomicBoolean(false);
Player.Listener listener = Player.Listener listener =

View File

@ -26,7 +26,6 @@ import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.PlayerMessage; import com.google.android.exoplayer2.PlayerMessage;
import com.google.android.exoplayer2.PlayerMessage.Target; import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
@ -72,7 +71,7 @@ public abstract class Action {
* null} if there's no next action. * null} if there's no next action.
*/ */
public final void doActionAndScheduleNext( public final void doActionAndScheduleNext(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -84,7 +83,7 @@ public abstract class Action {
} }
/** /**
* Called by {@link #doActionAndScheduleNext(SimpleExoPlayer, DefaultTrackSelector, Surface, * Called by {@link #doActionAndScheduleNext(ExoPlayer, DefaultTrackSelector, Surface,
* HandlerWrapper, ActionNode)} to perform the action and to schedule the next action node. * HandlerWrapper, ActionNode)} to perform the action and to schedule the next action node.
* *
* @param player The player to which the action should be applied. * @param player The player to which the action should be applied.
@ -96,7 +95,7 @@ public abstract class Action {
* null} if there's no next action. * null} if there's no next action.
*/ */
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -108,7 +107,7 @@ public abstract class Action {
} }
/** /**
* Called by {@link #doActionAndScheduleNextImpl(SimpleExoPlayer, DefaultTrackSelector, Surface, * Called by {@link #doActionAndScheduleNextImpl(ExoPlayer, DefaultTrackSelector, Surface,
* HandlerWrapper, ActionNode)} to perform the action. * HandlerWrapper, ActionNode)} to perform the action.
* *
* @param player The player to which the action should be applied. * @param player The player to which the action should be applied.
@ -117,7 +116,7 @@ public abstract class Action {
* needed. * needed.
*/ */
protected abstract void doActionImpl( protected abstract void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface); ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface);
/** Calls {@link Player#seekTo(long)} or {@link Player#seekTo(int, long)}. */ /** Calls {@link Player#seekTo(long)} or {@link Player#seekTo(int, long)}. */
public static final class Seek extends Action { public static final class Seek extends Action {
@ -157,7 +156,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
try { try {
if (windowIndex == null) { if (windowIndex == null) {
player.seekTo(positionMs); player.seekTo(positionMs);
@ -172,7 +171,7 @@ public abstract class Action {
} }
} }
/** Calls {@link SimpleExoPlayer#setMediaSources(List, int, long)}. */ /** Calls {@link ExoPlayer#setMediaSources(List, int, long)}. */
public static final class SetMediaItems extends Action { public static final class SetMediaItems extends Action {
private final int windowIndex; private final int windowIndex;
@ -195,12 +194,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setMediaSources(Arrays.asList(mediaSources), windowIndex, positionMs); player.setMediaSources(Arrays.asList(mediaSources), windowIndex, positionMs);
} }
} }
/** Calls {@link SimpleExoPlayer#addMediaSources(List)}. */ /** Calls {@link ExoPlayer#addMediaSources(List)}. */
public static final class AddMediaItems extends Action { public static final class AddMediaItems extends Action {
private final MediaSource[] mediaSources; private final MediaSource[] mediaSources;
@ -216,12 +215,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.addMediaSources(Arrays.asList(mediaSources)); player.addMediaSources(Arrays.asList(mediaSources));
} }
} }
/** Calls {@link SimpleExoPlayer#setMediaSources(List, boolean)}. */ /** Calls {@link ExoPlayer#setMediaSources(List, boolean)}. */
public static final class SetMediaItemsResetPosition extends Action { public static final class SetMediaItemsResetPosition extends Action {
private final boolean resetPosition; private final boolean resetPosition;
@ -241,12 +240,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setMediaSources(Arrays.asList(mediaSources), resetPosition); player.setMediaSources(Arrays.asList(mediaSources), resetPosition);
} }
} }
/** Calls {@link SimpleExoPlayer#moveMediaItem(int, int)}. */ /** Calls {@link ExoPlayer#moveMediaItem(int, int)}. */
public static class MoveMediaItem extends Action { public static class MoveMediaItem extends Action {
private final int currentIndex; private final int currentIndex;
@ -265,12 +264,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.moveMediaItem(currentIndex, newIndex); player.moveMediaItem(currentIndex, newIndex);
} }
} }
/** Calls {@link SimpleExoPlayer#removeMediaItem(int)}. */ /** Calls {@link ExoPlayer#removeMediaItem(int)}. */
public static class RemoveMediaItem extends Action { public static class RemoveMediaItem extends Action {
private final int index; private final int index;
@ -286,12 +285,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.removeMediaItem(index); player.removeMediaItem(index);
} }
} }
/** Calls {@link SimpleExoPlayer#removeMediaItems(int, int)}. */ /** Calls {@link ExoPlayer#removeMediaItems(int, int)}. */
public static class RemoveMediaItems extends Action { public static class RemoveMediaItems extends Action {
private final int fromIndex; private final int fromIndex;
@ -310,12 +309,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.removeMediaItems(fromIndex, toIndex); player.removeMediaItems(fromIndex, toIndex);
} }
} }
/** Calls {@link SimpleExoPlayer#clearMediaItems()}}. */ /** Calls {@link ExoPlayer#clearMediaItems()}}. */
public static class ClearMediaItems extends Action { public static class ClearMediaItems extends Action {
/** @param tag A tag to use for logging. */ /** @param tag A tag to use for logging. */
@ -325,7 +324,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.clearMediaItems(); player.clearMediaItems();
} }
} }
@ -360,7 +359,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
if (reset == null) { if (reset == null) {
player.stop(); player.stop();
} else { } else {
@ -385,7 +384,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setPlayWhenReady(playWhenReady); player.setPlayWhenReady(playWhenReady);
} }
} }
@ -412,13 +411,13 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
trackSelector.setParameters( trackSelector.setParameters(
trackSelector.buildUponParameters().setRendererDisabled(rendererIndex, disabled)); trackSelector.buildUponParameters().setRendererDisabled(rendererIndex, disabled));
} }
} }
/** Calls {@link SimpleExoPlayer#clearVideoSurface()}. */ /** Calls {@link ExoPlayer#clearVideoSurface()}. */
public static final class ClearVideoSurface extends Action { public static final class ClearVideoSurface extends Action {
/** @param tag A tag to use for logging. */ /** @param tag A tag to use for logging. */
@ -428,12 +427,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.clearVideoSurface(); player.clearVideoSurface();
} }
} }
/** Calls {@link SimpleExoPlayer#setVideoSurface(Surface)}. */ /** Calls {@link ExoPlayer#setVideoSurface(Surface)}. */
public static final class SetVideoSurface extends Action { public static final class SetVideoSurface extends Action {
/** @param tag A tag to use for logging. */ /** @param tag A tag to use for logging. */
@ -443,12 +442,12 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setVideoSurface(Assertions.checkNotNull(surface)); player.setVideoSurface(Assertions.checkNotNull(surface));
} }
} }
/** Calls {@link SimpleExoPlayer#setAudioAttributes(AudioAttributes, boolean)}. */ /** Calls {@link ExoPlayer#setAudioAttributes(AudioAttributes, boolean)}. */
public static final class SetAudioAttributes extends Action { public static final class SetAudioAttributes extends Action {
private final AudioAttributes audioAttributes; private final AudioAttributes audioAttributes;
@ -468,7 +467,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setAudioAttributes(audioAttributes, handleAudioFocus); player.setAudioAttributes(audioAttributes, handleAudioFocus);
} }
} }
@ -482,7 +481,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.prepare(); player.prepare();
} }
} }
@ -503,7 +502,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setRepeatMode(repeatMode); player.setRepeatMode(repeatMode);
} }
} }
@ -524,7 +523,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setShuffleOrder(shuffleOrder); player.setShuffleOrder(shuffleOrder);
} }
} }
@ -545,7 +544,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setShuffleModeEnabled(shuffleModeEnabled); player.setShuffleModeEnabled(shuffleModeEnabled);
} }
} }
@ -591,9 +590,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
final SimpleExoPlayer player, final ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
DefaultTrackSelector trackSelector,
@Nullable Surface surface) {
if (target instanceof PlayerTarget) { if (target instanceof PlayerTarget) {
((PlayerTarget) target).setPlayer(player); ((PlayerTarget) target).setPlayer(player);
} }
@ -627,7 +624,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player.setPlaybackParameters(playbackParameters); player.setPlaybackParameters(playbackParameters);
} }
} }
@ -648,7 +645,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
player player
.createMessage( .createMessage(
(messageType, payload) -> { (messageType, payload) -> {
@ -680,7 +677,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -724,7 +721,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -768,7 +765,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -798,7 +795,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -816,7 +813,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -839,7 +836,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -863,7 +860,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -890,7 +887,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -914,7 +911,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -940,7 +937,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -964,7 +961,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -980,7 +977,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -1004,7 +1001,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -1030,7 +1027,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -1045,7 +1042,7 @@ public abstract class Action {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -1065,7 +1062,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }
@ -1083,7 +1080,7 @@ public abstract class Action {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
if (runnable instanceof PlayerRunnable) { if (runnable instanceof PlayerRunnable) {
((PlayerRunnable) runnable).setPlayer(player); ((PlayerRunnable) runnable).setPlayer(player);
} }

View File

@ -20,12 +20,12 @@ import android.view.Surface;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.PlayerMessage; import com.google.android.exoplayer2.PlayerMessage;
import com.google.android.exoplayer2.PlayerMessage.Target; import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
@ -91,7 +91,7 @@ public final class ActionSchedule {
* notification is needed. * notification is needed.
*/ */
/* package */ void start( /* package */ void start(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper mainHandler, HandlerWrapper mainHandler,
@ -601,7 +601,7 @@ public final class ActionSchedule {
void onMessageArrived(); void onMessageArrived();
} }
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
private boolean hasArrived; private boolean hasArrived;
@Nullable private Callback callback; @Nullable private Callback callback;
@ -613,8 +613,7 @@ public final class ActionSchedule {
} }
/** Handles the message send to the component and additionally provides access to the player. */ /** Handles the message send to the component and additionally provides access to the player. */
public abstract void handleMessage( public abstract void handleMessage(ExoPlayer player, int messageType, @Nullable Object message);
SimpleExoPlayer player, int messageType, @Nullable Object message);
@Override @Override
public final void handleMessage( public final void handleMessage(
@ -626,8 +625,8 @@ public final class ActionSchedule {
} }
} }
/** Sets the player to be passed to {@link #handleMessage(SimpleExoPlayer, int, Object)}. */ /** Sets the player to be passed to {@link #handleMessage(ExoPlayer, int, Object)}. */
/* package */ void setPlayer(SimpleExoPlayer player) { /* package */ void setPlayer(ExoPlayer player) {
this.player = player; this.player = player;
} }
} }
@ -638,18 +637,18 @@ public final class ActionSchedule {
*/ */
public abstract static class PlayerRunnable implements Runnable { public abstract static class PlayerRunnable implements Runnable {
@Nullable private SimpleExoPlayer player; @Nullable private ExoPlayer player;
/** Executes Runnable with reference to player. */ /** Executes Runnable with reference to player. */
public abstract void run(SimpleExoPlayer player); public abstract void run(ExoPlayer player);
@Override @Override
public final void run() { public final void run() {
run(Assertions.checkStateNotNull(player)); run(Assertions.checkStateNotNull(player));
} }
/** Sets the player to be passed to {@link #run(SimpleExoPlayer)} . */ /** Sets the player to be passed to {@link #run(ExoPlayer)} . */
/* package */ void setPlayer(SimpleExoPlayer player) { /* package */ void setPlayer(ExoPlayer player) {
this.player = player; this.player = player;
} }
} }
@ -663,7 +662,7 @@ public final class ActionSchedule {
@Nullable private ActionNode next; @Nullable private ActionNode next;
private @MonotonicNonNull SimpleExoPlayer player; private @MonotonicNonNull ExoPlayer player;
private @MonotonicNonNull DefaultTrackSelector trackSelector; private @MonotonicNonNull DefaultTrackSelector trackSelector;
@Nullable private Surface surface; @Nullable private Surface surface;
private @MonotonicNonNull HandlerWrapper mainHandler; private @MonotonicNonNull HandlerWrapper mainHandler;
@ -707,7 +706,7 @@ public final class ActionSchedule {
* @param mainHandler A handler associated with the main thread of the host activity. * @param mainHandler A handler associated with the main thread of the host activity.
*/ */
public void schedule( public void schedule(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper mainHandler) { HandlerWrapper mainHandler) {
@ -754,7 +753,7 @@ public final class ActionSchedule {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Do nothing. // Do nothing.
} }
} }
@ -774,7 +773,7 @@ public final class ActionSchedule {
@Override @Override
protected void doActionAndScheduleNextImpl( protected void doActionAndScheduleNextImpl(
SimpleExoPlayer player, ExoPlayer player,
DefaultTrackSelector trackSelector, DefaultTrackSelector trackSelector,
@Nullable Surface surface, @Nullable Surface surface,
HandlerWrapper handler, HandlerWrapper handler,
@ -788,7 +787,7 @@ public final class ActionSchedule {
@Override @Override
protected void doActionImpl( protected void doActionImpl(
SimpleExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) { ExoPlayer player, DefaultTrackSelector trackSelector, @Nullable Surface surface) {
// Not triggered. // Not triggered.
} }
} }

View File

@ -27,7 +27,6 @@ import com.google.android.exoplayer2.DefaultRenderersFactory;
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.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
import com.google.android.exoplayer2.audio.DefaultAudioSink; import com.google.android.exoplayer2.audio.DefaultAudioSink;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
@ -66,7 +65,7 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
private final ConditionVariable testFinished; private final ConditionVariable testFinished;
@Nullable private ActionSchedule pendingSchedule; @Nullable private ActionSchedule pendingSchedule;
private @MonotonicNonNull SimpleExoPlayer player; private @MonotonicNonNull ExoPlayer player;
private @MonotonicNonNull HandlerWrapper actionHandler; private @MonotonicNonNull HandlerWrapper actionHandler;
private @MonotonicNonNull DefaultTrackSelector trackSelector; private @MonotonicNonNull DefaultTrackSelector trackSelector;
private @MonotonicNonNull Surface surface; private @MonotonicNonNull Surface surface;
@ -242,12 +241,12 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
return new DefaultTrackSelector(host); return new DefaultTrackSelector(host);
} }
protected SimpleExoPlayer buildExoPlayer( protected ExoPlayer buildExoPlayer(
HostActivity host, Surface surface, MappingTrackSelector trackSelector) { HostActivity host, Surface surface, MappingTrackSelector trackSelector) {
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(host); DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(host);
renderersFactory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF); renderersFactory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);
renderersFactory.setAllowedVideoJoiningTimeMs(/* allowedVideoJoiningTimeMs= */ 0); renderersFactory.setAllowedVideoJoiningTimeMs(/* allowedVideoJoiningTimeMs= */ 0);
SimpleExoPlayer player = ExoPlayer player =
new ExoPlayer.Builder(host, renderersFactory).setTrackSelector(trackSelector).build(); new ExoPlayer.Builder(host, renderersFactory).setTrackSelector(trackSelector).build();
player.setVideoSurface(surface); player.setVideoSurface(surface);
return player; return player;

View File

@ -34,7 +34,6 @@ import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.analytics.AnalyticsListener;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
@ -71,7 +70,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
.build(); .build();
/** /**
* Builder to set-up a {@link ExoPlayerTestRunner}. Default fake implementations will be used for * Builder to set-up an {@link ExoPlayerTestRunner}. Default fake implementations will be used for
* unset test properties. * unset test properties.
*/ */
public static final class Builder { public static final class Builder {
@ -267,7 +266,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
/** /**
* Sets an {@link ActionSchedule} to be run by the test runner. The first action will be * Sets an {@link ActionSchedule} to be run by the test runner. The first action will be
* executed immediately before {@link SimpleExoPlayer#prepare()}. * executed immediately before {@link ExoPlayer#prepare()}.
* *
* @param actionSchedule An {@link ActionSchedule} to be used by the test runner. * @param actionSchedule An {@link ActionSchedule} to be used by the test runner.
* @return This builder. * @return This builder.
@ -379,7 +378,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
private final ArrayList<Integer> playbackStates; private final ArrayList<Integer> playbackStates;
private final boolean pauseAtEndOfMediaItems; private final boolean pauseAtEndOfMediaItems;
private SimpleExoPlayer player; private ExoPlayer player;
private Exception exception; private Exception exception;
private boolean playerWasPrepared; private boolean playerWasPrepared;