Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3c19850e
authored
Oct 13, 2021
by
samrobinson
Committed by
Oliver Woodman
Oct 14, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Migrate library usages of SimpleExoPlayer to ExoPlayer.
PiperOrigin-RevId: 402853522
parent
3b8eba2d
Hide whitespace changes
Inline
Side-by-side
Showing
59 changed files
with
377 additions
and
416 deletions
demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java
demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/PlayerManager.java
demos/gl/src/main/java/com/google/android/exoplayer2/gldemo/MainActivity.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
demos/surface/src/main/java/com/google/android/exoplayer2/surfacedemo/MainActivity.java
docs/ad-insertion.md
docs/analytics.md
docs/customization.md
docs/dash.md
docs/debug-logging.md
docs/downloading-media.md
docs/hello-world.md
docs/hls.md
docs/listening-to-player-events.md
docs/live-streaming.md
docs/media-sources.md
docs/network-stacks.md
docs/playlists.md
docs/progressive.md
docs/rtsp.md
docs/shrinking.md
docs/smoothstreaming.md
docs/track-selection.md
docs/troubleshooting.md
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacPlaybackTest.java
extensions/ima/src/androidTest/java/com/google/android/exoplayer2/ext/ima/ImaPlaybackTest.java
extensions/opus/src/androidTest/java/com/google/android/exoplayer2/ext/opus/OpusPlaybackTest.java
extensions/vp9/src/androidTest/java/com/google/android/exoplayer2/ext/vp9/VpxPlaybackTest.java
library/core/src/androidTest/java/com/google/android/exoplayer2/ClippedPlaybackTest.java
library/core/src/androidTest/java/com/google/android/exoplayer2/drm/DrmPlaybackTest.java
library/core/src/main/java/com/google/android/exoplayer2/RenderersFactory.java
library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java
library/core/src/test/java/com/google/android/exoplayer2/analytics/PlaybackStatsListenerTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/EndToEndGaplessTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlacPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlvPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkaPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkvPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp3PlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/OggPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/PlaylistPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/SilencePlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/Vp9PlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/e2etest/WavPlaybackTest.java
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdMediaSourceTest.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/e2etest/DashPlaybackTest.java
library/rtsp/src/test/java/com/google/android/exoplayer2/source/rtsp/RtspPlaybackTest.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java
playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java
robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/TestPlayerRunHelper.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/Action.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java
demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java
View file @
3c19850e
...
...
@@ -37,8 +37,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ExoPlayer
;
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.PlayerView
;
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
;
/**
* An activity that plays video using {@link
SimpleExoPlayer} and supports casting using ExoPlayer's
*
Cast
extension.
* An activity that plays video using {@link
ExoPlayer} and supports casting using ExoPlayer's Cast
* extension.
*/
public
class
MainActivity
extends
AppCompatActivity
implements
OnClickListener
,
PlayerManager
.
Listener
{
...
...
demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/PlayerManager.java
View file @
3c19850e
...
...
@@ -25,7 +25,6 @@ import com.google.android.exoplayer2.MediaItem;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player.DiscontinuityReason
;
import
com.google.android.exoplayer2.Player.TimelineChangeReason
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.TracksInfo
;
import
com.google.android.exoplayer2.ext.cast.CastPlayer
;
...
...
@@ -64,7 +63,7 @@ import java.util.ArrayList;
private
Player
currentPlayer
;
/**
* Creates a new manager for {@link
Simple
ExoPlayer} and {@link CastPlayer}.
* Creates a new manager for {@link ExoPlayer} and {@link CastPlayer}.
*
* @param listener A {@link Listener} for queue position changes.
* @param localPlayerView The {@link PlayerView} for local playback.
...
...
demos/gl/src/main/java/com/google/android/exoplayer2/gldemo/MainActivity.java
View file @
3c19850e
...
...
@@ -27,7 +27,6 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.DrmSessionManager
;
import
com.google.android.exoplayer2.drm.FrameworkMediaDrm
;
...
...
@@ -65,7 +64,7 @@ public final class MainActivity extends Activity {
@Nullable
private
PlayerView
playerView
;
@Nullable
private
VideoProcessingGLSurfaceView
videoProcessingGLSurfaceView
;
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
...
@@ -173,7 +172,7 @@ public final class MainActivity extends Activity {
throw
new
IllegalStateException
();
}
Simple
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
getApplicationContext
()).
build
();
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
getApplicationContext
()).
build
();
player
.
setRepeatMode
(
Player
.
REPEAT_MODE_ALL
);
player
.
setMediaSource
(
mediaSource
);
player
.
prepare
();
...
...
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
View file @
3c19850e
...
...
@@ -37,7 +37,6 @@ import com.google.android.exoplayer2.MediaItem;
import
com.google.android.exoplayer2.PlaybackException
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.RenderersFactory
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.TracksInfo
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.drm.FrameworkMediaDrm
;
...
...
@@ -61,7 +60,7 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.Map
;
/** An activity that plays media using {@link
Simple
ExoPlayer}. */
/** An activity that plays media using {@link ExoPlayer}. */
public
class
PlayerActivity
extends
AppCompatActivity
implements
OnClickListener
,
StyledPlayerControlView
.
VisibilityListener
{
...
...
@@ -75,7 +74,7 @@ public class PlayerActivity extends AppCompatActivity
protected
StyledPlayerView
playerView
;
protected
LinearLayout
debugRootView
;
protected
TextView
debugTextView
;
protected
@Nullable
Simple
ExoPlayer
player
;
protected
@Nullable
ExoPlayer
player
;
private
boolean
isShowingTrackSelectionDialog
;
private
Button
selectTracksButton
;
...
...
demos/surface/src/main/java/com/google/android/exoplayer2/surfacedemo/MainActivity.java
View file @
3c19850e
...
...
@@ -31,7 +31,6 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.DrmSessionManager
;
import
com.google.android.exoplayer2.drm.FrameworkMediaDrm
;
...
...
@@ -67,7 +66,7 @@ public final class MainActivity extends Activity {
@Nullable
private
SurfaceView
nonFullScreenView
;
@Nullable
private
SurfaceView
currentOutputView
;
@Nullable
private
static
Simple
ExoPlayer
player
;
@Nullable
private
static
ExoPlayer
player
;
@Nullable
private
static
SurfaceControl
surfaceControl
;
@Nullable
private
static
Surface
videoSurface
;
...
...
@@ -217,7 +216,7 @@ public final class MainActivity extends Activity {
}
else
{
throw
new
IllegalStateException
();
}
Simple
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
getApplicationContext
()).
build
();
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
getApplicationContext
()).
build
();
player
.
setMediaSource
(
mediaSource
);
player
.
prepare
();
player
.
play
();
...
...
docs/ad-insertion.md
View file @
3c19850e
...
...
@@ -53,7 +53,7 @@ MediaSourceFactory mediaSourceFactory =
new DefaultMediaSourceFactory(context)
.setAdsLoaderProvider(adsLoaderProvider)
.setAdViewProvider(playerView);
Simple
ExoPlayer player = new ExoPlayer.Builder(context)
ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(mediaSourceFactory)
.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
][]
for information on what timed metadata formats are supported by ExoPlayer). Apps
can listen for timed metadata events from the player, e.g., via
`
Simple
ExoPlayer.addMetadataOutput`
.
`ExoPlayer.addMetadataOutput`
.
The IMA extension currently only handles client-side ad insertion. It does not
provide any integration with the DAI part of the IMA SDK.
...
...
docs/analytics.md
View file @
3c19850e
...
...
@@ -44,7 +44,7 @@ implementations. You can easily add your own listener and override only the
methods you are interested in:
~~~
simpleE
xoPlayer.addAnalyticsListener(new AnalyticsListener() {
e
xoPlayer.addAnalyticsListener(new AnalyticsListener() {
@Override
public void onPlaybackStateChanged(
EventTime eventTime, @Player.State int state) {
...
...
@@ -98,7 +98,7 @@ current playback session at any time using
`PlaybackStatsListener.getPlaybackStats()`
.
~~~
simpleE
xoPlayer.addAnalyticsListener(
e
xoPlayer.addAnalyticsListener(
new PlaybackStatsListener(
/* keepHistory= */ true, (eventTime, playbackStats) -> {
// Analytics data for the session started at `eventTime` is ready.
...
...
@@ -246,7 +246,7 @@ class ExtendedCollector extends AnalyticsCollector {
}
// Usage - Setup and listener registration.
Simple
ExoPlayer player = new ExoPlayer.Builder(context)
ExoPlayer player = new ExoPlayer.Builder(context)
.setAnalyticsCollector(new ExtendedCollector())
.build();
player.addAnalyticsListener(new ExtendedListener() {
...
...
docs/customization.md
View file @
3c19850e
...
...
@@ -4,13 +4,13 @@ title: Customization
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
buffer media, play, pause and seek. The default implementation
s
`ExoPlayer`
and
`SimpleExoPlayer`
are designed to make few assumptions about (and hence impose
few restrictions on) the type of media being played, how and where it is stored,
and how it is rendered. Rather than implementing the loading and rendering of
media directly,
`ExoPlayer`
implementations delegate this work to components
that are injected when a player is created or when new media sources are passed
to the player.
Components common to all
`ExoPlayer`
implementations are:
buffer media, play, pause and seek. The default implementation
`ExoPlayer`
is
designed to make few assumptions about (and hence impose few restrictions on)
the type of media being played, how and where it is stored, and how it is
rendered. Rather than implementing the loading and rendering of media directly,
`ExoPlayer`
implementations delegate this work to components that are injected
when a player is created or when new media sources are passed to the player.
Components common to all
`ExoPlayer`
implementations are:
*
`MediaSource`
instances that define media to be played, load the media, and
from which the loaded media can be read.
`MediaSource`
instances are created
...
...
@@ -59,7 +59,7 @@ DefaultDataSource.Factory dataSourceFactory =
new DefaultDataSource.Factory(context, httpDataSourceFactory);
// Inject the DefaultDataSourceFactory when creating the player.
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context)
.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory))
.build();
...
...
@@ -82,7 +82,7 @@ DataSource.Factory cacheDataSourceFactory =
.setCache(simpleCache)
.setUpstreamDataSourceFactory(httpDataSourceFactory);
Simple
ExoPlayer player = new ExoPlayer.Builder(context)
ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(
new DefaultMediaSourceFactory(cacheDataSourceFactory))
.build();
...
...
@@ -107,7 +107,7 @@ DataSource.Factory dataSourceFactory = () -> {
return dataSource;
};
Simple
ExoPlayer player = new ExoPlayer.Builder(context)
ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory))
.build();
~~~
...
...
@@ -157,7 +157,7 @@ LoadErrorHandlingPolicy loadErrorHandlingPolicy =
}
};
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context)
.setMediaSourceFactory(
new DefaultMediaSourceFactory(context)
...
...
@@ -181,7 +181,7 @@ DefaultExtractorsFactory extractorsFactory =
new DefaultExtractorsFactory()
.setMp3ExtractorFlags(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING);
Simple
ExoPlayer player = new ExoPlayer.Builder(context)
ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(
new DefaultMediaSourceFactory(context, extractorsFactory))
.build();
...
...
docs/dash.md
View file @
3c19850e
...
...
@@ -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.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(dashUri));
// Prepare the player.
...
...
@@ -45,7 +45,7 @@ MediaSource mediaSource =
new DashMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(dashUri));
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played.
player.setMediaSource(mediaSource);
// Prepare the player.
...
...
docs/debug-logging.md
View file @
3c19850e
...
...
@@ -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
understanding what the player is doing, as well as for debugging playback
issues.
`EventLogger`
implements
`AnalyticsListener`
, so registering an instance
with a
`Simple
ExoPlayer`
is easy:
with a
n
`
ExoPlayer`
is easy:
```
player.addAnalyticsListener(new EventLogger(trackSelector));
...
...
docs/downloading-media.md
View file @
3c19850e
...
...
@@ -322,7 +322,7 @@ DataSource.Factory cacheDataSourceFactory =
.setUpstreamDataSourceFactory(httpDataSourceFactory)
.setCacheWriteDataSinkFactory(null); // Disable writing.
Simple
ExoPlayer player = new ExoPlayer.Builder(context)
ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(
new DefaultMediaSourceFactory(cacheDataSourceFactory))
.build();
...
...
docs/hello-world.md
View file @
3c19850e
...
...
@@ -14,7 +14,7 @@ For simple use cases, getting started with `ExoPlayer` consists of implementing
the following steps:
1.
Add ExoPlayer as a dependency to your project.
1.
Create a
`Simple
ExoPlayer`
instance.
1.
Create a
n
`
ExoPlayer`
instance.
1.
Attach the player to a view (for video output and user input).
1.
Prepare the player with a
`MediaItem`
to play.
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.
~~~
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
~~~
{: .language-java}
...
...
@@ -117,12 +117,12 @@ which the player must be accessed can be queried using
`Player.getApplicationLooper`
.
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
`
SimpleExoPlayer`
instance on the wrong thread (the exception's stack trace
shows you where). You can temporarily opt out from these exceptions being thrown
by calling
`SimpleExoPlayer.setThrowsWhenUsingWrongThread(false)`
, in which cas
e
the issue will be logged as a warning instead. Using this opt out is not safe
and
may result in unexpected or obscure errors. It will be removed in ExoPlayer
accessed on the wrong thread", then some code in your app is accessing a
n
`
ExoPlayer`
instance on the wrong thread (the exception's stack trace shows you
where). You can temporarily opt out from these exceptions being thrown by
calling
`ExoPlayer.setThrowsWhenUsingWrongThread(false)`
, in which case th
e
issue will be logged as a warning instead. Using this opt out is not safe and
may result in unexpected or obscure errors. It will be removed in ExoPlayer
2.
16.
{:.info}
...
...
@@ -148,10 +148,10 @@ useful for audio only use cases.
Use of ExoPlayer's pre-built UI components is optional. For video applications
that implement their own UI, the target
`SurfaceView`
,
`TextureView`
,
`SurfaceHolder`
or
`Surface`
can be set using
`
Simple
ExoPlayer`
's
`SurfaceHolder`
or
`Surface`
can be set using
`ExoPlayer`
's
`setVideoSurfaceView`
,
`setVideoTextureView`
,
`setVideoSurfaceHolder`
and
`setVideoSurface`
methods respectively.
`
SimpleExoPlayer`
's
`addTextOutput`
method can
be used to receive captions that should be rendered during playback.
`setVideoSurface`
methods respectively.
`
ExoPlayer`
's
`addTextOutput`
method can
be used to receive captions that should be rendered during playback.
## Populating the playlist and preparing the player ##
...
...
docs/hls.md
View file @
3c19850e
...
...
@@ -18,7 +18,7 @@ player.
~~~
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(hlsUri));
// Prepare the player.
...
...
@@ -48,7 +48,7 @@ HlsMediaSource hlsMediaSource =
new HlsMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(hlsUri));
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played.
player.setMediaSource(hlsMediaSource);
// Prepare the player.
...
...
docs/listening-to-player-events.md
View file @
3c19850e
...
...
@@ -180,15 +180,15 @@ together in `onEvents`.
## Using AnalyticsListener ##
When using
`
SimpleExoPlayer`
, an
`AnalyticsListener`
can be registered with the
player by calling
`addAnalyticsListener`
.
`AnalyticsListener`
implementations
are able to listen to detailed events that may be useful for analytics and
logging
purposes. Please refer to the
[
analytics page
][]
for more details.
When using
`
ExoPlayer`
, an
`AnalyticsListener`
can be registered with the player
by calling
`addAnalyticsListener`
.
`AnalyticsListener`
implementations are able
to listen to detailed events that may be useful for analytics and logging
purposes. Please refer to the
[
analytics page
][]
for more details.
### Using EventLogger ###
`EventLogger`
is an
`AnalyticsListener`
provided directly by the library for
logging purposes. It can be added to a
`Simple
ExoPlayer`
to enable useful
logging purposes. It can be added to a
n
`
ExoPlayer`
to enable useful
additional logging with a single line.
```
...
...
docs/live-streaming.md
View file @
3c19850e
...
...
@@ -96,7 +96,7 @@ values will override parameters defined by the media.
~~~
// Global settings.
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context)
.setMediaSourceFactory(
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:
~~~
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context)
.setLivePlaybackSpeedControl(
new DefaultLivePlaybackSpeedControl.Builder()
...
...
docs/media-sources.md
View file @
3c19850e
...
...
@@ -37,7 +37,7 @@ MediaSourceFactory mediaSourceFactory =
new DefaultMediaSourceFactory(cacheDataSourceFactory)
.setAdsLoaderProvider(adsLoaderProvider)
.setAdViewProvider(playerView);
Simple
ExoPlayer player = new ExoPlayer.Builder(context)
ExoPlayer player = new ExoPlayer.Builder(context)
.setMediaSourceFactory(mediaSourceFactory)
.build();
~~~
...
...
docs/network-stacks.md
View file @
3c19850e
...
...
@@ -32,8 +32,8 @@ where `PreferredHttpDataSource.Factory` is the factory corresponding to your
preferred network stack. The
`DefaultDataSourceFactory`
layer adds in support
for non-http(s) sources such as local files.
The example below shows how to build a
`SimpleExoPlayer`
that will use
the Cronet
network stack and also support playback of non-http(s) content.
The example below shows how to build a
n
`ExoPlayer`
that will use the Cronet
network stack and also support playback of non-http(s) content.
~~~
// Given a CronetEngine and Executor, build a CronetDataSource.Factory.
...
...
@@ -49,7 +49,7 @@ DefaultDataSource.Factory dataSourceFactory =
/* baseDataSourceFactory= */ cronetDataSourceFactory);
// Inject the DefaultDataSourceFactory when creating the player.
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context)
.setMediaSourceFactory(new DefaultMediaSourceFactory(dataSourceFactory))
.build();
...
...
docs/playlists.md
View file @
3c19850e
...
...
@@ -166,9 +166,9 @@ This can be customized by providing a custom shuffle order implementation:
~~~
// Set the custom shuffle order.
simpleE
xoPlayer.setShuffleOrder(shuffleOrder);
e
xoPlayer.setShuffleOrder(shuffleOrder);
// Enable shuffle mode.
simpleE
xoPlayer.setShuffleModeEnabled(/* shuffleModeEnabled= */ true);
e
xoPlayer.setShuffleModeEnabled(/* shuffleModeEnabled= */ true);
~~~
{: .language-java}
...
...
docs/progressive.md
View file @
3c19850e
...
...
@@ -11,7 +11,7 @@ it to the player.
~~~
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(progressiveUri));
// Prepare the player.
...
...
@@ -31,7 +31,7 @@ DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();
MediaSource mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(progressiveUri));
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played.
player.setMediaSource(mediaSource);
// Prepare the player.
...
...
docs/rtsp.md
View file @
3c19850e
...
...
@@ -17,7 +17,7 @@ You can then create a `MediaItem` for an RTSP URI and pass it to the player.
~~~
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(rtspUri));
// Prepare the player.
...
...
@@ -43,7 +43,7 @@ MediaSource mediaSource =
new RtspMediaSource.Factory()
.createMediaSource(MediaItem.fromUri(rtspUri));
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played.
player.setMediaSource(mediaSource);
// Prepare the player.
...
...
docs/shrinking.md
View file @
3c19850e
...
...
@@ -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
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
this when instantiating
`
Simple
ExoPlayer`
instances:
this when instantiating
`ExoPlayer`
instances:
~~~
RenderersFactory audioOnlyRenderersFactory =
...
...
@@ -58,7 +58,7 @@ RenderersFactory audioOnlyRenderersFactory =
new MediaCodecAudioRenderer(
context, MediaCodecSelector.DEFAULT, handler, audioListener)
};
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context, audioOnlyRenderersFactory).build();
~~~
{: .language-java}
...
...
@@ -80,7 +80,7 @@ an app that only needs to play mp4 files can provide a factory like:
~~~
ExtractorsFactory mp4ExtractorFactory =
() -> new Extractor[] {new Mp4Extractor()};
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context, mp4ExtractorFactory).build();
~~~
{: .language-java}
...
...
@@ -98,18 +98,18 @@ constructor, if your app is doing one of the following:
~~~
// Only playing DASH, HLS or SmoothStreaming.
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY).build();
// Providing a customized `DefaultMediaSourceFactory`
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY)
.setMediaSourceFactory(
new DefaultMediaSourceFactory(context, customExtractorsFactory))
.build();
// Using a MediaSource directly.
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context, ExtractorsFactory.EMPTY).build();
ProgressiveMediaSource mediaSource =
new ProgressiveMediaSource.Factory(
...
...
docs/smoothstreaming.md
View file @
3c19850e
...
...
@@ -19,7 +19,7 @@ to the player.
~~~
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(ssUri));
// Prepare the player.
...
...
@@ -47,7 +47,7 @@ MediaSource mediaSource =
new SsMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(ssUri));
// Create a player instance.
Simple
ExoPlayer player = new ExoPlayer.Builder(context).build();
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played.
player.setMediaSource(mediaSource);
// Prepare the player.
...
...
docs/track-selection.md
View file @
3c19850e
...
...
@@ -8,7 +8,7 @@ of which can be provided whenever an `ExoPlayer` is built.
~~~
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
Simple
ExoPlayer player =
ExoPlayer player =
new ExoPlayer.Builder(context)
.setTrackSelector(trackSelector)
.build();
...
...
docs/troubleshooting.md
View file @
3c19850e
...
...
@@ -230,7 +230,7 @@ audio when your app is in the background:
from killing your process to free up resources.
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
[
`
Simple
ExoPlayer`
][]
by calling
[
`setWakeMode`
][]
, which will automatically
[
`ExoPlayer`
][]
by calling
[
`setWakeMode`
][]
, which will automatically
acquire and release the required locks at the correct times.
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
[
`WifiLock`
]:
{{
site.android_sdk }}/android/net/wifi/WifiManager.WifiLock.html
[
`WakeLock`
]:
{{
site.android_sdk }}/android/os/PowerManager.WakeLock.html
[
`
SimpleExoPlayer`
]:
{{
site.exo_sdk }}/Simple
ExoPlayer.html
[
`setWakeMode`
]:
{{
site.exo_sdk }}/
Simple
ExoPlayer.html#setWakeMode(int)
[
`
ExoPlayer`
]:
{{
site.exo_sdk }}/
ExoPlayer.html
[
`setWakeMode`
]:
{{
site.exo_sdk }}/ExoPlayer.html#setWakeMode(int)
[
A note on threading
]:
{{
site.base_url }}/hello-world.html#a-note-on-threading
[
OkHttp extension
]:
{{
site.release_v2 }}/extensions/okhttp
[
CORS enabled
]:
https://www.w3.org/wiki/CORS_Enabled
...
...
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacPlaybackTest.java
View file @
3c19850e
...
...
@@ -29,7 +29,6 @@ import com.google.android.exoplayer2.PlaybackException;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Renderer
;
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.AudioSink
;
import
com.google.android.exoplayer2.audio.DefaultAudioSink
;
...
...
@@ -96,7 +95,7 @@ public class FlacPlaybackTest {
private
final
Uri
uri
;
private
final
AudioSink
audioSink
;
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
@Nullable
private
PlaybackException
playbackException
;
public
TestPlaybackRunnable
(
Uri
uri
,
Context
context
,
AudioSink
audioSink
)
{
...
...
extensions/ima/src/androidTest/java/com/google/android/exoplayer2/ext/ima/ImaPlaybackTest.java
View file @
3c19850e
...
...
@@ -25,11 +25,11 @@ import androidx.annotation.Nullable;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.rule.ActivityTestRule
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Player.DiscontinuityReason
;
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.analytics.AnalyticsListener
;
import
com.google.android.exoplayer2.decoder.DecoderCounters
;
...
...
@@ -192,7 +192,7 @@ public final class ImaPlaybackTest {
private
final
List
<
AdId
>
expectedAdIds
;
private
final
List
<
AdId
>
seenAdIds
;
private
@MonotonicNonNull
ImaAdsLoader
imaAdsLoader
;
private
@MonotonicNonNull
Simple
ExoPlayer
player
;
private
@MonotonicNonNull
ExoPlayer
player
;
private
ImaHostedTest
(
Uri
contentUri
,
String
adsResponse
,
AdId
...
expectedAdIds
)
{
// fullPlaybackNoSeeking is false as the playback lasts longer than the content source
...
...
@@ -207,7 +207,7 @@ public final class ImaPlaybackTest {
}
@Override
protected
Simple
ExoPlayer
buildExoPlayer
(
protected
ExoPlayer
buildExoPlayer
(
HostActivity
host
,
Surface
surface
,
MappingTrackSelector
trackSelector
)
{
player
=
super
.
buildExoPlayer
(
host
,
surface
,
trackSelector
);
player
.
addAnalyticsListener
(
...
...
extensions/opus/src/androidTest/java/com/google/android/exoplayer2/ext/opus/OpusPlaybackTest.java
View file @
3c19850e
...
...
@@ -29,7 +29,6 @@ import com.google.android.exoplayer2.PlaybackException;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Renderer
;
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.source.MediaSource
;
import
com.google.android.exoplayer2.source.ProgressiveMediaSource
;
...
...
@@ -79,7 +78,7 @@ public class OpusPlaybackTest {
private
final
Context
context
;
private
final
Uri
uri
;
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
@Nullable
private
PlaybackException
playbackException
;
public
TestPlaybackRunnable
(
Uri
uri
,
Context
context
)
{
...
...
extensions/vp9/src/androidTest/java/com/google/android/exoplayer2/ext/vp9/VpxPlaybackTest.java
View file @
3c19850e
...
...
@@ -30,7 +30,6 @@ import com.google.android.exoplayer2.PlaybackException;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Renderer
;
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.source.MediaSource
;
import
com.google.android.exoplayer2.source.ProgressiveMediaSource
;
...
...
@@ -107,7 +106,7 @@ public class VpxPlaybackTest {
private
final
Context
context
;
private
final
Uri
uri
;
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
@Nullable
private
PlaybackException
playbackException
;
public
TestPlaybackRunnable
(
Uri
uri
,
Context
context
)
{
...
...
library/core/src/androidTest/java/com/google/android/exoplayer2/ClippedPlaybackTest.java
View file @
3c19850e
...
...
@@ -54,7 +54,7 @@ public final class ClippedPlaybackTest {
// Expect the clipping to affect both subtitles and video.
.
setClipEndPositionMs
(
1000
)
.
build
();
AtomicReference
<
Simple
ExoPlayer
>
player
=
new
AtomicReference
<>();
AtomicReference
<
ExoPlayer
>
player
=
new
AtomicReference
<>();
TextCapturingPlaybackListener
textCapturer
=
new
TextCapturingPlaybackListener
();
getInstrumentation
()
.
runOnMainSync
(
...
...
@@ -96,7 +96,7 @@ public final class ClippedPlaybackTest {
// subtitle content (3.5s).
.
setClipEndPositionMs
(
4_000
)
.
build
());
AtomicReference
<
Simple
ExoPlayer
>
player
=
new
AtomicReference
<>();
AtomicReference
<
ExoPlayer
>
player
=
new
AtomicReference
<>();
TextCapturingPlaybackListener
textCapturer
=
new
TextCapturingPlaybackListener
();
getInstrumentation
()
.
runOnMainSync
(
...
...
library/core/src/androidTest/java/com/google/android/exoplayer2/drm/DrmPlaybackTest.java
View file @
3c19850e
...
...
@@ -24,7 +24,6 @@ import com.google.android.exoplayer2.ExoPlayer;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.PlaybackException
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.util.ConditionVariable
;
import
java.util.concurrent.atomic.AtomicReference
;
import
okhttp3.mockwebserver.MockResponse
;
...
...
@@ -64,7 +63,7 @@ public final class DrmPlaybackTest {
.
setLicenseUri
(
mockWebServer
.
url
(
"license"
).
toString
())
.
build
())
.
build
();
AtomicReference
<
Simple
ExoPlayer
>
player
=
new
AtomicReference
<>();
AtomicReference
<
ExoPlayer
>
player
=
new
AtomicReference
<>();
ConditionVariable
playbackComplete
=
new
ConditionVariable
();
AtomicReference
<
PlaybackException
>
playbackException
=
new
AtomicReference
<>();
getInstrumentation
()
...
...
library/core/src/main/java/com/google/android/exoplayer2/RenderersFactory.java
View file @
3c19850e
...
...
@@ -21,11 +21,11 @@ import com.google.android.exoplayer2.metadata.MetadataOutput;
import
com.google.android.exoplayer2.text.TextOutput
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener
;
/** Builds {@link Renderer} instances for use by a
{@link Simple
ExoPlayer}. */
/** Builds {@link Renderer} instances for use by a
n {@link
ExoPlayer}. */
public
interface
RenderersFactory
{
/**
* Builds the {@link Renderer} instances for a
{@link Simple
ExoPlayer}.
* Builds the {@link Renderer} instances for a
n {@link
ExoPlayer}.
*
* @param eventHandler A handler to use when invoking event listeners and outputs.
* @param videoRendererEventListener An event listener for video renderers.
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java
View file @
3c19850e
...
...
@@ -18,32 +18,32 @@ package com.google.android.exoplayer2.util;
import
android.annotation.SuppressLint
;
import
android.os.Looper
;
import
android.widget.TextView
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.decoder.DecoderCounters
;
import
java.util.Locale
;
/**
* A helper class for periodically updating a {@link TextView} with debug information obtained from
* a
{@link Simple
ExoPlayer}.
* a
n {@link
ExoPlayer}.
*/
public
class
DebugTextViewHelper
implements
Player
.
Listener
,
Runnable
{
private
static
final
int
REFRESH_INTERVAL_MS
=
1000
;
private
final
Simple
ExoPlayer
player
;
private
final
ExoPlayer
player
;
private
final
TextView
textView
;
private
boolean
started
;
/**
* @param player The {@link
Simple
ExoPlayer} 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
* player.getApplicationLooper() == Looper.getMainLooper()}).
* @param textView The {@link TextView} that should be updated to display the information.
*/
public
DebugTextViewHelper
(
Simple
ExoPlayer
player
,
TextView
textView
)
{
public
DebugTextViewHelper
(
ExoPlayer
player
,
TextView
textView
)
{
Assertions
.
checkArgument
(
player
.
getApplicationLooper
()
==
Looper
.
getMainLooper
());
this
.
player
=
player
;
this
.
textView
=
textView
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
3c19850e
...
...
@@ -206,7 +206,7 @@ public final class ExoPlayerTest {
new
MaskingMediaSource
.
PlaceholderTimeline
(
FakeMediaSource
.
FAKE_MEDIA_ITEM
);
FakeRenderer
renderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_UNKNOWN
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
Player
.
Listener
mockListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockListener
);
...
...
@@ -237,7 +237,7 @@ public final class ExoPlayerTest {
public
void
playSinglePeriodTimeline
()
throws
Exception
{
Timeline
timeline
=
new
FakeTimeline
();
FakeRenderer
renderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_VIDEO
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
Player
.
Listener
mockListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockListener
);
...
...
@@ -272,7 +272,7 @@ public final class ExoPlayerTest {
public
void
playMultiPeriodTimeline
()
throws
Exception
{
Timeline
timeline
=
new
FakeTimeline
(
/* windowCount= */
3
);
FakeRenderer
renderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_VIDEO
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
Player
.
Listener
mockPlayerListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockPlayerListener
);
...
...
@@ -310,7 +310,7 @@ public final class ExoPlayerTest {
Timeline
timeline
=
new
FakeTimeline
(
new
TimelineWindowDefinition
(
/* periodCount= */
100
,
/* id= */
0
));
FakeRenderer
renderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_VIDEO
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
Player
.
Listener
mockPlayerListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockPlayerListener
);
...
...
@@ -342,7 +342,7 @@ public final class ExoPlayerTest {
Timeline
timeline
=
new
FakeTimeline
();
final
FakeRenderer
videoRenderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_VIDEO
);
final
FakeRenderer
audioRenderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_AUDIO
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
videoRenderer
,
audioRenderer
).
build
();
Player
.
Listener
mockPlayerListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockPlayerListener
);
...
...
@@ -366,7 +366,7 @@ public final class ExoPlayerTest {
final
FakeRenderer
videoRenderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_VIDEO
);
final
FakeRenderer
audioRenderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_AUDIO
);
final
FakeRenderer
textRenderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_TEXT
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
videoRenderer
,
audioRenderer
).
build
();
Player
.
Listener
mockPlayerListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockPlayerListener
);
...
...
@@ -404,7 +404,7 @@ public final class ExoPlayerTest {
final
FakeRenderer
textRenderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_TEXT
);
Format
textFormat
=
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
TEXT_VTT
).
setLanguage
(
"en"
).
build
();
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
audioRenderer
,
textRenderer
).
build
();
Player
.
Listener
mockPlayerListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockPlayerListener
);
...
...
@@ -440,7 +440,7 @@ public final class ExoPlayerTest {
final
FakeRenderer
textRenderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_TEXT
);
Format
textFormat
=
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
TEXT_VTT
).
setLanguage
(
"en"
).
build
();
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
)
.
setRenderers
(
videoRenderer
,
audioRenderer
,
textRenderer
)
.
build
();
...
...
@@ -531,7 +531,7 @@ public final class ExoPlayerTest {
return
videoRenderer
.
isEnded
();
}
};
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
videoRenderer
,
audioRenderer
).
build
();
Player
.
Listener
mockPlayerListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockPlayerListener
);
...
...
@@ -581,7 +581,7 @@ public final class ExoPlayerTest {
};
Timeline
thirdTimeline
=
new
FakeTimeline
();
MediaSource
thirdSource
=
new
FakeMediaSource
(
thirdTimeline
,
ExoPlayerTestRunner
.
VIDEO_FORMAT
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
Player
.
Listener
mockPlayerListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockPlayerListener
);
...
...
@@ -639,7 +639,7 @@ public final class ExoPlayerTest {
public
void
repeatModeChanges
()
throws
Exception
{
Timeline
timeline
=
new
FakeTimeline
(
/* windowCount= */
3
);
FakeRenderer
renderer
=
new
FakeRenderer
(
C
.
TRACK_TYPE_VIDEO
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
renderer
).
build
();
AnalyticsListener
mockAnalyticsListener
=
mock
(
AnalyticsListener
.
class
);
player
.
addAnalyticsListener
(
mockAnalyticsListener
);
...
...
@@ -803,7 +803,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
try
{
player
.
seekTo
(
/* windowIndex= */
100
,
/* positionMs= */
0
);
}
catch
(
IllegalSeekPositionException
e
)
{
...
...
@@ -1196,7 +1196,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
try
{
player
.
getClock
().
onThreadBlocked
();
createPeriodCalledCountDownLatch
.
await
();
...
...
@@ -1273,7 +1273,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionWhenReady
.
set
(
player
.
getCurrentPosition
());
}
})
...
...
@@ -1306,7 +1306,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPosition
[
0
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
0
]
=
player
.
getBufferedPosition
();
...
...
@@ -1322,7 +1322,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndex
[
2
]
=
player
.
getCurrentWindowIndex
();
currentPosition
[
2
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
2
]
=
player
.
getBufferedPosition
();
...
...
@@ -1398,7 +1398,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPosition
[
0
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
0
]
=
player
.
getBufferedPosition
();
...
...
@@ -1414,7 +1414,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndex
[
2
]
=
player
.
getCurrentWindowIndex
();
currentPosition
[
2
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
2
]
=
player
.
getBufferedPosition
();
...
...
@@ -1492,7 +1492,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPosition
[
0
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
0
]
=
player
.
getBufferedPosition
();
...
...
@@ -1508,7 +1508,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndex
[
2
]
=
player
.
getCurrentWindowIndex
();
currentPosition
[
2
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
2
]
=
player
.
getBufferedPosition
();
...
...
@@ -1559,7 +1559,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndexAfterStop
.
set
(
player
.
getCurrentWindowIndex
());
positionAfterStop
.
set
(
player
.
getCurrentPosition
());
}
...
...
@@ -1627,7 +1627,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionAfterReprepare
.
set
(
player
.
getCurrentPosition
());
}
})
...
...
@@ -1681,7 +1681,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionAfterReprepare
.
set
(
player
.
getCurrentPosition
());
}
})
...
...
@@ -1738,7 +1738,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionAfterReprepare
.
set
(
player
.
getCurrentPosition
());
}
})
...
...
@@ -1846,7 +1846,7 @@ public final class ExoPlayerTest {
@Test
public
void
seekAndReprepareAfterPlaybackError_keepsSeekPositionAndTimeline
()
throws
Exception
{
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
Player
.
Listener
mockListener
=
mock
(
Player
.
Listener
.
class
);
player
.
addListener
(
mockListener
);
FakeMediaSource
fakeMediaSource
=
new
FakeMediaSource
();
...
...
@@ -1907,7 +1907,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndexAfterAddingSources
.
set
(
player
.
getCurrentWindowIndex
());
}
})
...
...
@@ -1940,7 +1940,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Position while in error state
positionHolder
[
0
]
=
player
.
getCurrentPosition
();
windowIndexHolder
[
0
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -1950,7 +1950,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Position while repreparing.
positionHolder
[
1
]
=
player
.
getCurrentPosition
();
windowIndexHolder
[
1
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -1960,7 +1960,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Position after repreparation finished.
positionHolder
[
2
]
=
player
.
getCurrentPosition
();
windowIndexHolder
[
2
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -2005,7 +2005,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Position while in error state
positionHolder
[
0
]
=
player
.
getCurrentPosition
();
windowIndexHolder
[
0
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -2016,7 +2016,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Position while in error state
positionHolder
[
1
]
=
player
.
getCurrentPosition
();
windowIndexHolder
[
1
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -2026,7 +2026,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Position after prepare.
positionHolder
[
2
]
=
player
.
getCurrentPosition
();
windowIndexHolder
[
2
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -2618,7 +2618,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
message
.
set
(
player
.
createMessage
(
target
).
setPosition
(
/* positionMs= */
50
).
send
());
}
...
...
@@ -2648,7 +2648,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
message
.
set
(
player
.
createMessage
(
target
)
...
...
@@ -2879,7 +2879,7 @@ public final class ExoPlayerTest {
return
super
.
createPeriod
(
id
,
allocator
,
startPositionUs
);
}
};
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
setMediaSource
(
mediaSource
);
// Throw on the playback thread if the player position reaches a value that is just less than
// seek position. This ensures that playback stops and the assertion on the player position
...
...
@@ -2973,7 +2973,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
mediaSource
.
removeMediaSource
(
/* index= */
0
);
try
{
// Wait until the source to be removed is released on the playback thread. So
...
...
@@ -2994,7 +2994,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowCount
[
0
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
position
[
0
]
=
player
.
getCurrentPosition
();
}
...
...
@@ -3076,7 +3076,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerReference
.
set
(
player
);
player
.
addListener
(
playerListener1
);
player
.
addListener
(
playerListener2
);
...
...
@@ -3137,7 +3137,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerReference
.
set
(
player
);
player
.
addListener
(
playerListener
);
}
...
...
@@ -3176,7 +3176,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerReference
.
set
(
player
);
player
.
addListener
(
playerListener
);
}
...
...
@@ -3244,7 +3244,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerReference
.
set
(
player
);
player
.
addListener
(
playerListener
);
}
...
...
@@ -3375,7 +3375,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionWhenReady
.
set
(
player
.
getContentPosition
());
}
})
...
...
@@ -3419,7 +3419,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
periodIndexWhenReady
.
set
(
player
.
getCurrentPeriodIndex
());
positionWhenReady
.
set
(
player
.
getContentPosition
());
}
...
...
@@ -3469,7 +3469,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerReference
.
set
(
player
);
player
.
addListener
(
playerListener
);
}
...
...
@@ -3520,7 +3520,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerReference
.
set
(
player
);
player
.
addListener
(
playerListener
);
}
...
...
@@ -3573,7 +3573,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerReference
.
set
(
player
);
player
.
addListener
(
playerListener
);
}
...
...
@@ -3593,7 +3593,7 @@ public final class ExoPlayerTest {
@Test
public
void
adInMovingLiveWindow_keepsContentPosition
()
throws
Exception
{
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
AdPlaybackState
adPlaybackState
=
FakeTimeline
.
createAdPlaybackState
(
/* adsPerAdGroup= */
1
,
/* adGroupTimesUs...= */
42_000_004_000_000L
);
...
...
@@ -3648,9 +3648,7 @@ public final class ExoPlayerTest {
new
Action
(
"getPlaybackSpeed"
,
/* description= */
null
)
{
@Override
protected
void
doActionImpl
(
SimpleExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
maskedPlaybackSpeeds
.
add
(
player
.
getPlaybackParameters
().
speed
);
}
};
...
...
@@ -3864,7 +3862,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPlaybackPositions
[
0
]
=
player
.
getCurrentPosition
();
windowCounts
[
0
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
...
...
@@ -3902,7 +3900,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionMs
[
0
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
0
]
=
player
.
getBufferedPosition
();
//noinspection deprecation
...
...
@@ -3916,7 +3914,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
positionMs
[
2
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
2
]
=
player
.
getBufferedPosition
();
...
...
@@ -3956,7 +3954,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionMs
[
0
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
0
]
=
player
.
getBufferedPosition
();
player
.
setMediaSource
(
mediaSource
,
/* startPositionMs= */
7000
);
...
...
@@ -3969,7 +3967,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
positionMs
[
2
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
2
]
=
player
.
getBufferedPosition
();
...
...
@@ -4003,7 +4001,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
9000
);
}
},
...
...
@@ -4035,7 +4033,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
9200
);
}
},
...
...
@@ -4067,7 +4065,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
1000
);
}
},
...
...
@@ -4094,7 +4092,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
0
,
1000
);
}
},
...
...
@@ -4123,7 +4121,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
2
,
1000
);
}
},
...
...
@@ -4157,7 +4155,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
1
,
1000
);
}
},
...
...
@@ -4193,7 +4191,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
1
,
1000
);
}
},
...
...
@@ -4228,7 +4226,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
1
,
5000
);
}
},
...
...
@@ -4261,7 +4259,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
1
,
5000
);
}
},
...
...
@@ -4297,7 +4295,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
addMediaSource
(
/* index= */
1
,
createPartiallyBufferedMediaSource
(
/* maxBufferedPositionMs= */
0
));
}
...
...
@@ -4331,7 +4329,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
moveMediaItem
(
/* currentIndex= */
1
,
/* newIndex= */
2
);
}
},
...
...
@@ -4365,7 +4363,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
moveMediaItem
(
/* currentIndex= */
3
,
/* newIndex= */
1
);
}
},
...
...
@@ -4400,7 +4398,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
removeMediaItem
(
/* index= */
0
);
}
},
...
...
@@ -4435,7 +4433,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
removeMediaItem
(
/* index= */
2
);
}
},
...
...
@@ -4470,7 +4468,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
removeMediaItem
(
/* index= */
1
);
}
},
...
...
@@ -4504,7 +4502,7 @@ public final class ExoPlayerTest {
runPositionMaskingCapturingActionSchedule
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
clearMediaItems
();
}
},
...
...
@@ -4544,7 +4542,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
positionMs
[
0
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
0
]
=
player
.
getBufferedPosition
();
...
...
@@ -4555,7 +4553,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndex
[
1
]
=
player
.
getCurrentWindowIndex
();
positionMs
[
1
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
1
]
=
player
.
getBufferedPosition
();
...
...
@@ -4651,7 +4649,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
addMediaSource
(
/* index= */
1
,
new
FakeMediaSource
());
windowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
isPlayingAd
[
0
]
=
player
.
isPlayingAd
();
...
...
@@ -4664,7 +4662,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndex
[
1
]
=
player
.
getCurrentWindowIndex
();
isPlayingAd
[
1
]
=
player
.
isPlayingAd
();
positionMs
[
1
]
=
player
.
getCurrentPosition
();
...
...
@@ -4677,7 +4675,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
addMediaSource
(
new
FakeMediaSource
());
windowIndex
[
2
]
=
player
.
getCurrentWindowIndex
();
isPlayingAd
[
2
]
=
player
.
isPlayingAd
();
...
...
@@ -4752,7 +4750,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
/* windowIndex= */
0
,
/* positionMs= */
8000
);
windowIndex
[
0
]
=
player
.
getCurrentWindowIndex
();
isPlayingAd
[
0
]
=
player
.
isPlayingAd
();
...
...
@@ -4765,7 +4763,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndex
[
1
]
=
player
.
getCurrentWindowIndex
();
isPlayingAd
[
1
]
=
player
.
isPlayingAd
();
positionMs
[
1
]
=
player
.
getCurrentPosition
();
...
...
@@ -4820,7 +4818,7 @@ public final class ExoPlayerTest {
adPlaybackState
));
FakeMediaSource
adsMediaSource
=
new
FakeMediaSource
(
adTimeline
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
setMediaSource
(
adsMediaSource
);
player
.
pause
();
player
.
prepare
();
...
...
@@ -4835,7 +4833,7 @@ public final class ExoPlayerTest {
@Test
public
void
becomingNoisyIgnoredIfBecomingNoisyHandlingIsDisabled
()
throws
Exception
{
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
play
();
player
.
setHandleAudioBecomingNoisy
(
false
);
...
...
@@ -4849,7 +4847,7 @@ public final class ExoPlayerTest {
@Test
public
void
pausesWhenBecomingNoisyIfBecomingNoisyHandlingIsEnabled
()
throws
Exception
{
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
play
();
player
.
setHandleAudioBecomingNoisy
(
true
);
...
...
@@ -5063,7 +5061,7 @@ public final class ExoPlayerTest {
/* deferOnPrepared= */
id
.
adIndexInAdGroup
==
1
);
}
};
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
setMediaSource
(
mediaSource
);
player
.
prepare
();
player
.
play
();
...
...
@@ -5322,7 +5320,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
setMediaSource
(
new
FakeMediaSource
(),
/* startPositionMs= */
1000
);
maskingPlaybackState
[
0
]
=
player
.
getPlaybackState
();
}
...
...
@@ -5509,7 +5507,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
}
})
...
...
@@ -5574,7 +5572,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPlaybackPositions
[
0
]
=
player
.
getCurrentPosition
();
}
...
...
@@ -5610,7 +5608,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPlaybackPositions
[
0
]
=
player
.
getCurrentPosition
();
windowCounts
[
0
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
...
...
@@ -5626,7 +5624,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
1
]
=
player
.
getCurrentWindowIndex
();
currentPlaybackPositions
[
1
]
=
player
.
getCurrentPosition
();
windowCounts
[
1
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
...
...
@@ -5681,7 +5679,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPlaybackPositions
[
0
]
=
player
.
getCurrentPosition
();
windowCounts
[
0
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
...
...
@@ -5697,7 +5695,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
1
]
=
player
.
getCurrentWindowIndex
();
currentPlaybackPositions
[
1
]
=
player
.
getCurrentPosition
();
windowCounts
[
1
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
...
...
@@ -5761,7 +5759,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionAfterSetPlayWhenReady
.
set
(
player
.
getCurrentPosition
());
}
})
...
...
@@ -5785,7 +5783,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentPositionMs
[
0
]
=
player
.
getCurrentPosition
();
bufferedPositionMs
[
0
]
=
player
.
getBufferedPosition
();
player
.
setPlayWhenReady
(
true
);
...
...
@@ -5822,7 +5820,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentPositionMs
[
0
]
=
player
.
getCurrentPosition
();
bufferedPositionMs
[
0
]
=
player
.
getBufferedPosition
();
player
.
setShuffleModeEnabled
(
true
);
...
...
@@ -5859,7 +5857,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
positionAfterSetShuffleOrder
.
set
(
player
.
getCurrentPosition
());
}
})
...
...
@@ -5882,7 +5880,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
List
<
MediaSource
>
listOfTwo
=
ImmutableList
.
of
(
new
FakeMediaSource
(),
new
FakeMediaSource
());
...
...
@@ -5895,7 +5893,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
}
})
...
...
@@ -5920,7 +5918,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
/* windowIndex= */
1
,
/* positionMs= */
1000
);
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPositions
[
0
]
=
player
.
getCurrentPosition
();
...
...
@@ -5958,7 +5956,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
List
<
MediaSource
>
listOfTwo
=
ImmutableList
.
of
(
new
FakeMediaSource
(),
new
FakeMediaSource
());
...
...
@@ -5971,7 +5969,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
}
})
...
...
@@ -5999,7 +5997,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
List
<
MediaSource
>
listOfTwo
=
ImmutableList
.
of
(
new
FakeMediaSource
(),
new
FakeMediaSource
());
...
...
@@ -6012,7 +6010,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
}
})
...
...
@@ -6037,7 +6035,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Increase current window index.
player
.
addMediaSource
(
/* index= */
0
,
new
FakeMediaSource
());
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -6046,7 +6044,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Current window index is unchanged.
player
.
addMediaSource
(
/* index= */
2
,
new
FakeMediaSource
());
currentWindowIndices
[
1
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -6055,7 +6053,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
MediaSource
mediaSource
=
new
FakeMediaSource
();
ConcatenatingMediaSource
concatenatingMediaSource
=
new
ConcatenatingMediaSource
(
mediaSource
,
mediaSource
,
mediaSource
);
...
...
@@ -6067,7 +6065,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
ConcatenatingMediaSource
concatenatingMediaSource
=
new
ConcatenatingMediaSource
();
// Current window index is unchanged when adding empty source.
...
...
@@ -6103,7 +6101,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPositions
[
0
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
0
]
=
player
.
getBufferedPosition
();
...
...
@@ -6119,7 +6117,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
currentPositions
[
2
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
2
]
=
player
.
getBufferedPosition
();
...
...
@@ -6152,7 +6150,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPositions
[
0
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
0
]
=
player
.
getBufferedPosition
();
...
...
@@ -6168,7 +6166,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
currentPositions
[
2
]
=
player
.
getCurrentPosition
();
bufferedPositions
[
2
]
=
player
.
getBufferedPosition
();
...
...
@@ -6198,7 +6196,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
// Increase current window index.
player
.
addMediaSource
(
/* index= */
0
,
new
FakeMediaSource
());
...
...
@@ -6209,7 +6207,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
}
})
...
...
@@ -6233,7 +6231,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set empty media item with no seek.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
());
maskingPlaybackStates
[
0
]
=
player
.
getPlaybackState
();
...
...
@@ -6242,7 +6240,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with an implicit seek to the current position.
player
.
setMediaSource
(
new
FakeMediaSource
());
maskingPlaybackStates
[
1
]
=
player
.
getPlaybackState
();
...
...
@@ -6251,7 +6249,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with an explicit seek.
player
.
setMediaSource
(
new
FakeMediaSource
(),
/* startPositionMs= */
C
.
TIME_UNSET
);
...
...
@@ -6261,7 +6259,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set empty media item with an explicit seek.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
(),
/* startPositionMs= */
C
.
TIME_UNSET
);
...
...
@@ -6301,7 +6299,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set a media item with an implicit seek to the current position which is
// invalid in the new timeline.
player
.
setMediaSource
(
...
...
@@ -6339,7 +6337,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with no seek.
player
.
setMediaSource
(
new
FakeMediaSource
());
maskingPlaybackStates
[
0
]
=
player
.
getPlaybackState
();
...
...
@@ -6374,7 +6372,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set an empty media item with no seek.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
());
maskingPlaybackStates
[
0
]
=
player
.
getPlaybackState
();
...
...
@@ -6415,7 +6413,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set empty media item with an implicit seek to the current position.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
());
maskingPlaybackStates
[
0
]
=
player
.
getPlaybackState
();
...
...
@@ -6425,7 +6423,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set empty media item with an explicit seek.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
(),
/* startPositionMs= */
C
.
TIME_UNSET
);
...
...
@@ -6436,7 +6434,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with an implicit seek to the current position.
player
.
setMediaSource
(
firstMediaSource
);
maskingPlaybackStates
[
2
]
=
player
.
getPlaybackState
();
...
...
@@ -6447,7 +6445,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with an explicit seek.
player
.
setMediaSource
(
secondMediaSource
,
/* startPositionMs= */
C
.
TIME_UNSET
);
maskingPlaybackStates
[
3
]
=
player
.
getPlaybackState
();
...
...
@@ -6496,7 +6494,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with an invalid implicit seek to the current position.
player
.
setMediaSource
(
new
FakeMediaSource
(
new
FakeTimeline
(
/* windowCount= */
1
,
1L
)),
...
...
@@ -6536,7 +6534,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with no seek (keep current position).
player
.
setMediaSource
(
new
FakeMediaSource
(),
/* resetPosition= */
false
);
maskingPlaybackStates
[
0
]
=
player
.
getPlaybackState
();
...
...
@@ -6576,7 +6574,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set an empty media item with no seek.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
());
maskingPlaybackStates
[
0
]
=
player
.
getPlaybackState
();
...
...
@@ -6616,7 +6614,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set empty media item with an implicit seek to current position.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
(),
/* resetPosition= */
false
);
...
...
@@ -6630,7 +6628,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set empty media item with an explicit seek.
player
.
setMediaSource
(
new
ConcatenatingMediaSource
(),
/* startPositionMs= */
C
.
TIME_UNSET
);
...
...
@@ -6644,7 +6642,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with an explicit seek.
player
.
setMediaSource
(
secondMediaSource
,
/* startPositionMs= */
C
.
TIME_UNSET
);
// Expect masking state is buffering,
...
...
@@ -6657,7 +6655,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Set media item with an implicit seek to the current position.
player
.
setMediaSource
(
secondMediaSource
,
/* resetPosition= */
false
);
// Expect masking state is buffering,
...
...
@@ -6729,7 +6727,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// An implicit, invalid seek picking up the position set by the initial seek.
player
.
setMediaSource
(
firstMediaSource
,
/* resetPosition= */
false
);
// Expect masking state is ended,
...
...
@@ -6778,7 +6776,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
addMediaSource
(
/* index= */
0
,
new
FakeMediaSource
());
positions
[
0
]
=
player
.
getCurrentPosition
();
positions
[
1
]
=
player
.
getBufferedPosition
();
...
...
@@ -6814,7 +6812,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
// If the timeline is empty masking variables are used.
currentPositions
[
0
]
=
player
.
getCurrentPosition
();
...
...
@@ -6837,7 +6835,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
4
]
=
player
.
getCurrentWindowIndex
();
// Finally original playbackInfo coming from EPII is used.
currentPositions
[
2
]
=
player
.
getCurrentPosition
();
...
...
@@ -6875,7 +6873,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
player
.
addMediaSource
(
new
FakeMediaSource
());
currentWindowIndices
[
1
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -6886,7 +6884,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
}
})
...
...
@@ -6917,7 +6915,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Move the current item down in the playlist.
player
.
moveMediaItems
(
/* fromIndex= */
0
,
/* toIndex= */
2
,
/* newIndex= */
1
);
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -6926,7 +6924,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Move the current item up in the playlist.
player
.
moveMediaItems
(
/* fromIndex= */
1
,
/* toIndex= */
3
,
/* newIndex= */
0
);
currentWindowIndices
[
1
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -6936,7 +6934,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Move items from before to behind the current item.
player
.
moveMediaItems
(
/* fromIndex= */
0
,
/* toIndex= */
2
,
/* newIndex= */
1
);
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -6945,7 +6943,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Move items from behind to before the current item.
player
.
moveMediaItems
(
/* fromIndex= */
1
,
/* toIndex= */
3
,
/* newIndex= */
0
);
currentWindowIndices
[
3
]
=
player
.
getCurrentWindowIndex
();
...
...
@@ -6954,7 +6952,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Move items from before to before the current item.
// No change in currentWindowIndex.
player
.
moveMediaItems
(
/* fromIndex= */
0
,
/* toIndex= */
1
,
/* newIndex= */
1
);
...
...
@@ -6965,7 +6963,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Move items from behind to behind the current item.
// No change in currentWindowIndex.
player
.
moveMediaItems
(
/* fromIndex= */
1
,
/* toIndex= */
2
,
/* newIndex= */
2
);
...
...
@@ -6992,7 +6990,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Increase current window index.
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
player
.
moveMediaItem
(
/* currentIndex= */
0
,
/* newIndex= */
1
);
...
...
@@ -7004,7 +7002,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
}
})
...
...
@@ -7028,7 +7026,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Decrease current window index.
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
player
.
removeMediaItem
(
/* index= */
0
);
...
...
@@ -7058,7 +7056,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Remove the current item.
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPositions
[
0
]
=
player
.
getCurrentPosition
();
...
...
@@ -7110,7 +7108,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Expect the current window index to be 2 after seek.
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPositions
[
0
]
=
player
.
getCurrentPosition
();
...
...
@@ -7129,7 +7127,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Expects the current window index still on 0.
currentWindowIndices
[
2
]
=
player
.
getCurrentWindowIndex
();
// Insert an item at begin when the playlist is not empty.
...
...
@@ -7146,7 +7144,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
4
]
=
player
.
getCurrentWindowIndex
();
// Implicit seek to the current window index, which is out of bounds in new
// timeline.
...
...
@@ -7161,7 +7159,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
6
]
=
player
.
getCurrentWindowIndex
();
// Explicit seek to (0, C.TIME_UNSET). Player transitions to BUFFERING.
player
.
setMediaSource
(
fourthMediaSource
,
/* startPositionMs= */
5000
);
...
...
@@ -7175,7 +7173,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Check whether actual window index is equal masking index from above.
currentWindowIndices
[
8
]
=
player
.
getCurrentWindowIndex
();
}
...
...
@@ -7253,7 +7251,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentPosition
[
0
]
=
player
.
getCurrentPosition
();
bufferedPosition
[
0
]
=
player
.
getBufferedPosition
();
...
...
@@ -7294,7 +7292,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
currentWindowIndices
[
0
]
=
player
.
getCurrentWindowIndex
();
currentStates
[
0
]
=
player
.
getPlaybackState
();
player
.
clearMediaItems
();
...
...
@@ -7306,7 +7304,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
// Transitions to ended when prepared with zero media items.
currentStates
[
2
]
=
player
.
getPlaybackState
();
}
...
...
@@ -7357,7 +7355,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
addAnalyticsListener
(
new
AnalyticsListener
()
{
@Override
...
...
@@ -7412,7 +7410,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
seekTo
(
player
.
getCurrentPosition
());
}
})
...
...
@@ -7421,7 +7419,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
windowIndexAfterFinalEndedState
.
set
(
player
.
getCurrentWindowIndex
());
}
})
...
...
@@ -7456,7 +7454,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playbackStateAfterPause
.
set
(
player
.
getPlaybackState
());
windowIndexAfterPause
.
set
(
player
.
getCurrentWindowIndex
());
positionAfterPause
.
set
(
player
.
getContentPosition
());
...
...
@@ -7495,7 +7493,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playbackStateAfterPause
.
set
(
player
.
getPlaybackState
());
windowIndexAfterPause
.
set
(
player
.
getCurrentWindowIndex
());
positionAfterPause
.
set
(
player
.
getContentPosition
());
...
...
@@ -7747,7 +7745,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
addListener
(
playerListener1
);
player
.
addListener
(
playerListener2
);
}
...
...
@@ -7915,7 +7913,7 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playerHolder
[
0
]
=
player
;
}
})
...
...
@@ -8993,7 +8991,7 @@ public final class ExoPlayerTest {
@Test
public
void
enableOffloadSchedulingWhileIdle_isToggled_isReported
()
throws
Exception
{
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
build
();
player
.
experimentalSetOffloadSchedulingEnabled
(
true
);
assertThat
(
runUntilReceiveOffloadSchedulingEnabledNewState
(
player
)).
isTrue
();
...
...
@@ -9005,7 +9003,7 @@ public final class ExoPlayerTest {
@Test
public
void
enableOffloadSchedulingWhilePlaying_isToggled_isReported
()
throws
Exception
{
FakeSleepRenderer
sleepRenderer
=
new
FakeSleepRenderer
(
C
.
TRACK_TYPE_AUDIO
).
sleepOnNextRender
();
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
Timeline
timeline
=
new
FakeTimeline
();
player
.
setMediaSource
(
new
FakeMediaSource
(
timeline
,
ExoPlayerTestRunner
.
AUDIO_FORMAT
));
player
.
prepare
();
...
...
@@ -9022,7 +9020,7 @@ public final class ExoPlayerTest {
public
void
enableOffloadSchedulingWhileSleepingForOffload_isDisabled_isReported
()
throws
Exception
{
FakeSleepRenderer
sleepRenderer
=
new
FakeSleepRenderer
(
C
.
TRACK_TYPE_AUDIO
).
sleepOnNextRender
();
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
Timeline
timeline
=
new
FakeTimeline
();
player
.
setMediaSource
(
new
FakeMediaSource
(
timeline
,
ExoPlayerTestRunner
.
AUDIO_FORMAT
));
player
.
experimentalSetOffloadSchedulingEnabled
(
true
);
...
...
@@ -9038,7 +9036,7 @@ public final class ExoPlayerTest {
@Test
public
void
enableOffloadScheduling_isEnable_playerSleeps
()
throws
Exception
{
FakeSleepRenderer
sleepRenderer
=
new
FakeSleepRenderer
(
C
.
TRACK_TYPE_AUDIO
);
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
Timeline
timeline
=
new
FakeTimeline
();
player
.
setMediaSource
(
new
FakeMediaSource
(
timeline
,
ExoPlayerTestRunner
.
AUDIO_FORMAT
));
player
.
experimentalSetOffloadSchedulingEnabled
(
true
);
...
...
@@ -9056,7 +9054,7 @@ public final class ExoPlayerTest {
experimentalEnableOffloadSchedulingWhileSleepingForOffload_isDisabled_renderingResumes
()
throws
Exception
{
FakeSleepRenderer
sleepRenderer
=
new
FakeSleepRenderer
(
C
.
TRACK_TYPE_AUDIO
).
sleepOnNextRender
();
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
Timeline
timeline
=
new
FakeTimeline
();
player
.
setMediaSource
(
new
FakeMediaSource
(
timeline
,
ExoPlayerTestRunner
.
AUDIO_FORMAT
));
player
.
experimentalSetOffloadSchedulingEnabled
(
true
);
...
...
@@ -9074,7 +9072,7 @@ public final class ExoPlayerTest {
@Test
public
void
wakeupListenerWhileSleepingForOffload_isWokenUp_renderingResumes
()
throws
Exception
{
FakeSleepRenderer
sleepRenderer
=
new
FakeSleepRenderer
(
C
.
TRACK_TYPE_AUDIO
).
sleepOnNextRender
();
Simple
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
).
setRenderers
(
sleepRenderer
).
build
();
Timeline
timeline
=
new
FakeTimeline
();
player
.
setMediaSource
(
new
FakeMediaSource
(
timeline
,
ExoPlayerTestRunner
.
AUDIO_FORMAT
));
player
.
experimentalSetOffloadSchedulingEnabled
(
true
);
...
...
@@ -11119,7 +11117,7 @@ public final class ExoPlayerTest {
public
void
newServerSideInsertedAdAtPlaybackPosition_keepsRenderersEnabled
()
throws
Exception
{
// Injecting renderer to count number of renderer resets.
AtomicReference
<
FakeVideoRenderer
>
videoRenderer
=
new
AtomicReference
<>();
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
context
)
.
setRenderersFactory
(
(
handler
,
videoListener
,
audioListener
,
textOutput
,
metadataOutput
)
->
{
...
...
@@ -11192,14 +11190,14 @@ public final class ExoPlayerTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
setVideoSurface
(
surface1
);
}
})
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
setVideoSurface
(
surface2
);
}
});
...
...
@@ -11330,7 +11328,7 @@ public final class ExoPlayerTest {
}
@Override
public
void
handleMessage
(
Simple
ExoPlayer
player
,
int
messageType
,
@Nullable
Object
message
)
{
public
void
handleMessage
(
ExoPlayer
player
,
int
messageType
,
@Nullable
Object
message
)
{
windowIndex
=
player
.
getCurrentWindowIndex
();
positionMs
=
player
.
getCurrentPosition
();
messageCount
++;
...
...
@@ -11344,7 +11342,7 @@ public final class ExoPlayerTest {
@Nullable
public
Timeline
timeline
;
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playWhenReady
=
player
.
getPlayWhenReady
();
playbackState
=
player
.
getPlaybackState
();
timeline
=
player
.
getCurrentTimeline
();
...
...
@@ -11379,7 +11377,7 @@ public final class ExoPlayerTest {
}
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
playbackStates
[
index
]
=
player
.
getPlaybackState
();
timelineWindowCount
[
index
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java
View file @
3c19850e
...
...
@@ -81,7 +81,6 @@ import com.google.android.exoplayer2.PlaybackParameters;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Renderer
;
import
com.google.android.exoplayer2.RenderersFactory
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.Timeline.Window
;
import
com.google.android.exoplayer2.TracksInfo
;
...
...
@@ -1048,7 +1047,7 @@ public final class AnalyticsCollectorTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
addListener
(
new
Player
.
Listener
()
{
@Override
...
...
@@ -1422,7 +1421,7 @@ public final class AnalyticsCollectorTest {
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
Simple
ExoPlayer
player
)
{
public
void
run
(
ExoPlayer
player
)
{
player
.
getAnalyticsCollector
().
notifySeekStarted
();
}
})
...
...
@@ -1653,7 +1652,7 @@ public final class AnalyticsCollectorTest {
@Test
public
void
onEvents_isReportedWithCorrectEventTimes
()
throws
Exception
{
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
TestExoPlayerBuilder
(
ApplicationProvider
.
getApplicationContext
()).
build
();
Surface
surface
=
new
Surface
(
new
SurfaceTexture
(
/* texName= */
0
));
player
.
setVideoSurface
(
surface
);
...
...
@@ -1987,7 +1986,7 @@ public final class AnalyticsCollectorTest {
public
void
release_withCallbacksArrivingAfterRelease_onPlayerReleasedForwardedLast
()
throws
Exception
{
FakeClock
fakeClock
=
new
FakeClock
(
/* initialTimeMs= */
0
,
/* isAutoAdvancing= */
true
);
SimpleExoPlayer
simpleE
xoPlayer
=
ExoPlayer
e
xoPlayer
=
new
TestExoPlayerBuilder
(
ApplicationProvider
.
getApplicationContext
())
.
setClock
(
fakeClock
)
.
build
();
...
...
@@ -2001,16 +2000,16 @@ public final class AnalyticsCollectorTest {
fakeClock
.
advanceTime
(
1
);
}
});
simpleE
xoPlayer
.
addAnalyticsListener
(
analyticsListener
);
e
xoPlayer
.
addAnalyticsListener
(
analyticsListener
);
// Prepare with media to ensure video renderer is enabled.
simpleE
xoPlayer
.
setMediaSource
(
e
xoPlayer
.
setMediaSource
(
new
FakeMediaSource
(
new
FakeTimeline
(),
ExoPlayerTestRunner
.
VIDEO_FORMAT
));
simpleE
xoPlayer
.
prepare
();
TestPlayerRunHelper
.
runUntilPlaybackState
(
simpleE
xoPlayer
,
Player
.
STATE_READY
);
e
xoPlayer
.
prepare
();
TestPlayerRunHelper
.
runUntilPlaybackState
(
e
xoPlayer
,
Player
.
STATE_READY
);
// Release and add delay on releasing thread to verify timestamps of events.
simpleE
xoPlayer
.
release
();
e
xoPlayer
.
release
();
long
releaseTimeMs
=
fakeClock
.
currentTimeMillis
();
fakeClock
.
advanceTime
(
1
);
ShadowLooper
.
idleMainLooper
();
...
...
@@ -2024,11 +2023,11 @@ public final class AnalyticsCollectorTest {
inOrder
.
verify
(
analyticsListener
).
onVideoDisabled
(
videoDisabledEventTime
.
capture
(),
any
());
inOrder
.
verify
(
analyticsListener
)
.
onEvents
(
same
(
simpleE
xoPlayer
),
argThat
(
events
->
events
.
contains
(
EVENT_VIDEO_DISABLED
)));
.
onEvents
(
same
(
e
xoPlayer
),
argThat
(
events
->
events
.
contains
(
EVENT_VIDEO_DISABLED
)));
inOrder
.
verify
(
analyticsListener
).
onPlayerReleased
(
releasedEventTime
.
capture
());
inOrder
.
verify
(
analyticsListener
)
.
onEvents
(
same
(
simpleE
xoPlayer
),
argThat
(
events
->
events
.
contains
(
EVENT_PLAYER_RELEASED
)));
.
onEvents
(
same
(
e
xoPlayer
),
argThat
(
events
->
events
.
contains
(
EVENT_PLAYER_RELEASED
)));
// Verify order of timestamps of these events.
// This verification is needed as a regression test against [internal ref: b/195396384]. The
...
...
library/core/src/test/java/com/google/android/exoplayer2/analytics/PlaybackStatsListenerTest.java
View file @
3c19850e
...
...
@@ -27,10 +27,10 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import
androidx.annotation.Nullable
;
import
androidx.test.core.app.ApplicationProvider
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.PlaybackParameters
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.google.android.exoplayer2.testutil.FakeMediaSource
;
...
...
@@ -49,7 +49,7 @@ import org.robolectric.shadows.ShadowLooper;
@RunWith
(
AndroidJUnit4
.
class
)
public
final
class
PlaybackStatsListenerTest
{
private
Simple
ExoPlayer
player
;
private
ExoPlayer
player
;
@Before
public
void
setUp
()
{
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/EndToEndGaplessTest.java
View file @
3c19850e
...
...
@@ -26,7 +26,6 @@ import com.google.android.exoplayer2.ExoPlayer;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.mediacodec.MediaCodecUtil
;
import
com.google.android.exoplayer2.robolectric.RandomizedMp3Decoder
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -87,7 +86,7 @@ public class EndToEndGaplessTest {
@Test
public
void
testPlayback_twoIdenticalMp3Files
()
throws
Exception
{
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
ApplicationProvider
.
getApplicationContext
())
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlacPlaybackTest.java
View file @
3c19850e
...
...
@@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -64,7 +63,7 @@ public class FlacPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/FlvPlaybackTest.java
View file @
3c19850e
...
...
@@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -55,7 +54,7 @@ public final class FlvPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkaPlaybackTest.java
View file @
3c19850e
...
...
@@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -57,7 +56,7 @@ public final class MkaPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/MkvPlaybackTest.java
View file @
3c19850e
...
...
@@ -23,7 +23,6 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -63,7 +62,7 @@ public final class MkvPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp3PlaybackTest.java
View file @
3c19850e
...
...
@@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -60,7 +59,7 @@ public final class Mp3PlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java
View file @
3c19850e
...
...
@@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -77,7 +76,7 @@ public class Mp4PlaybackTest {
public
void
test
()
throws
Exception
{
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
renderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
renderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/OggPlaybackTest.java
View file @
3c19850e
...
...
@@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -58,7 +57,7 @@ public final class OggPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/PlaylistPlaybackTest.java
View file @
3c19850e
...
...
@@ -21,7 +21,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -45,7 +44,7 @@ public final class PlaylistPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
@@ -67,7 +66,7 @@ public final class PlaylistPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/SilencePlaybackTest.java
View file @
3c19850e
...
...
@@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.ExoPlayer
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -45,7 +44,7 @@ public final class SilencePlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
@@ -66,7 +65,7 @@ public final class SilencePlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java
View file @
3c19850e
...
...
@@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -81,7 +80,7 @@ public class TsPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/Vp9PlaybackTest.java
View file @
3c19850e
...
...
@@ -22,7 +22,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -59,7 +58,7 @@ public final class Vp9PlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/e2etest/WavPlaybackTest.java
View file @
3c19850e
...
...
@@ -20,7 +20,6 @@ import androidx.test.core.app.ApplicationProvider;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -52,7 +51,7 @@ public final class WavPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdMediaSourceTest.java
View file @
3c19850e
...
...
@@ -38,7 +38,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.analytics.AnalyticsListener
;
import
com.google.android.exoplayer2.robolectric.PlaybackOutput
;
...
...
@@ -143,7 +142,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
public
void
playbackWithPredefinedAds_playsSuccessfulWithoutRendererResets
()
throws
Exception
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
renderersFactory
=
new
CapturingRenderersFactory
(
context
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
context
,
renderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
@@ -202,7 +201,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
public
void
playbackWithNewlyInsertedAds_playsSuccessfulWithoutRendererResets
()
throws
Exception
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
renderersFactory
=
new
CapturingRenderersFactory
(
context
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
context
,
renderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
@@ -262,7 +261,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
throws
Exception
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
renderersFactory
=
new
CapturingRenderersFactory
(
context
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
context
,
renderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
@@ -319,7 +318,7 @@ public final class ServerSideInsertedAdMediaSourceTest {
@Test
public
void
playbackWithSeek_isHandledCorrectly
()
throws
Exception
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
context
).
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
)).
build
();
player
.
setVideoSurface
(
new
Surface
(
new
SurfaceTexture
(
/* texName= */
1
)));
...
...
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/e2etest/DashPlaybackTest.java
View file @
3c19850e
...
...
@@ -25,7 +25,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.MediaItem
;
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.ShadowMediaCodecConfig
;
import
com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
;
...
...
@@ -54,7 +53,7 @@ public final class DashPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
@@ -81,7 +80,7 @@ public final class DashPlaybackTest {
Context
applicationContext
=
ApplicationProvider
.
getApplicationContext
();
CapturingRenderersFactory
capturingRenderersFactory
=
new
CapturingRenderersFactory
(
applicationContext
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
new
FakeClock
(
/* isAutoAdvancing= */
true
))
.
build
();
...
...
library/rtsp/src/test/java/com/google/android/exoplayer2/source/rtsp/RtspPlaybackTest.java
View file @
3c19850e
...
...
@@ -30,7 +30,6 @@ import com.google.android.exoplayer2.MediaItem;
import
com.google.android.exoplayer2.PlaybackException
;
import
com.google.android.exoplayer2.Player
;
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.RobolectricUtil
;
import
com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig
;
...
...
@@ -103,8 +102,7 @@ public final class RtspPlaybackTest {
fakeRtpDataChannel
);
try
(
RtspServer
rtspServer
=
new
RtspServer
(
responseProvider
))
{
SimpleExoPlayer
player
=
createSimpleExoPlayer
(
rtspServer
.
startAndGetPortNumber
(),
rtpDataChannelFactory
);
ExoPlayer
player
=
createExoPlayer
(
rtspServer
.
startAndGetPortNumber
(),
rtpDataChannelFactory
);
PlaybackOutput
playbackOutput
=
PlaybackOutput
.
register
(
player
,
capturingRenderersFactory
);
player
.
prepare
();
...
...
@@ -126,8 +124,7 @@ public final class RtspPlaybackTest {
new
RtspServer
(
new
ResponseProvider
(
clock
,
ImmutableList
.
of
(
mp4aLatmRtpPacketStreamDump
),
fakeRtpDataChannel
)))
{
SimpleExoPlayer
player
=
createSimpleExoPlayer
(
rtspServer
.
startAndGetPortNumber
(),
rtpDataChannelFactory
);
ExoPlayer
player
=
createExoPlayer
(
rtspServer
.
startAndGetPortNumber
(),
rtpDataChannelFactory
);
AtomicReference
<
Throwable
>
playbackError
=
new
AtomicReference
<>();
player
.
prepare
();
...
...
@@ -148,9 +145,9 @@ public final class RtspPlaybackTest {
}
}
private
SimpleExoPlayer
createSimpl
eExoPlayer
(
private
ExoPlayer
creat
eExoPlayer
(
int
serverRtspPortNumber
,
RtpDataChannel
.
Factory
rtpDataChannelFactory
)
{
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
applicationContext
,
capturingRenderersFactory
)
.
setClock
(
clock
)
.
build
();
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TranscodingTransformer.java
View file @
3c19850e
...
...
@@ -44,7 +44,6 @@ import com.google.android.exoplayer2.PlaybackException;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Renderer
;
import
com.google.android.exoplayer2.RenderersFactory
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.TracksInfo
;
import
com.google.android.exoplayer2.analytics.AnalyticsListener
;
...
...
@@ -366,7 +365,7 @@ public final class TranscodingTransformer {
private
TranscodingTransformer
.
Listener
listener
;
@Nullable
private
MuxerWrapper
muxerWrapper
;
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
@ProgressState
private
int
progressState
;
private
TranscodingTransformer
(
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Transformer.java
View file @
3c19850e
...
...
@@ -44,7 +44,6 @@ import com.google.android.exoplayer2.PlaybackException;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Renderer
;
import
com.google.android.exoplayer2.RenderersFactory
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.TracksInfo
;
import
com.google.android.exoplayer2.analytics.AnalyticsListener
;
...
...
@@ -363,7 +362,7 @@ public final class Transformer {
private
Transformer
.
Listener
listener
;
@Nullable
private
MuxerWrapper
muxerWrapper
;
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
@ProgressState
private
int
progressState
;
private
Transformer
(
...
...
playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java
View file @
3c19850e
...
...
@@ -29,7 +29,6 @@ import com.google.android.exoplayer2.ExoPlayer;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.decoder.DecoderCounters
;
import
com.google.android.exoplayer2.drm.DefaultDrmSessionManager
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
...
...
@@ -312,9 +311,9 @@ import java.util.List;
}
@Override
protected
Simple
ExoPlayer
buildExoPlayer
(
protected
ExoPlayer
buildExoPlayer
(
HostActivity
host
,
Surface
surface
,
MappingTrackSelector
trackSelector
)
{
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
host
,
new
DebugRenderersFactory
(
host
))
.
setTrackSelector
(
trackSelector
)
.
build
();
...
...
robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/TestPlayerRunHelper.java
View file @
3c19850e
...
...
@@ -23,7 +23,6 @@ import android.os.Looper;
import
com.google.android.exoplayer2.ExoPlaybackException
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.util.ConditionVariable
;
import
com.google.android.exoplayer2.util.Util
;
...
...
@@ -33,8 +32,8 @@ import java.util.concurrent.atomic.AtomicReference;
import
org.checkerframework.checker.nullness.compatqual.NullableType
;
/**
* Helper methods to block the calling thread until the provided {@link
SimpleExoPlayer} instance
*
reaches
a particular state.
* Helper methods to block the calling thread until the provided {@link
ExoPlayer} instance reaches
* a particular state.
*/
public
class
TestPlayerRunHelper
{
...
...
@@ -260,7 +259,7 @@ public class TestPlayerRunHelper {
* @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is
* exceeded.
*/
public
static
void
runUntilRenderedFirstFrame
(
Simple
ExoPlayer
player
)
throws
TimeoutException
{
public
static
void
runUntilRenderedFirstFrame
(
ExoPlayer
player
)
throws
TimeoutException
{
verifyMainTestThread
(
player
);
AtomicBoolean
receivedCallback
=
new
AtomicBoolean
(
false
);
Player
.
Listener
listener
=
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/Action.java
View file @
3c19850e
...
...
@@ -26,7 +26,6 @@ import com.google.android.exoplayer2.PlaybackParameters;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.PlayerMessage
;
import
com.google.android.exoplayer2.PlayerMessage.Target
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.source.MediaSource
;
...
...
@@ -72,7 +71,7 @@ public abstract class Action {
* null} if there's no next action.
*/
public
final
void
doActionAndScheduleNext
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -84,7 +83,7 @@ public abstract class Action {
}
/**
* Called by {@link #doActionAndScheduleNext(
Simple
ExoPlayer, DefaultTrackSelector, Surface,
* Called by {@link #doActionAndScheduleNext(ExoPlayer, DefaultTrackSelector, Surface,
* HandlerWrapper, ActionNode)} to perform the action and to schedule the next action node.
*
* @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.
*/
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -108,7 +107,7 @@ public abstract class Action {
}
/**
* Called by {@link #doActionAndScheduleNextImpl(
Simple
ExoPlayer, DefaultTrackSelector, Surface,
* Called by {@link #doActionAndScheduleNextImpl(ExoPlayer, DefaultTrackSelector, Surface,
* HandlerWrapper, ActionNode)} to perform the action.
*
* @param player The player to which the action should be applied.
...
...
@@ -117,7 +116,7 @@ public abstract class Action {
* needed.
*/
protected
abstract
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
);
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
);
/** Calls {@link Player#seekTo(long)} or {@link Player#seekTo(int, long)}. */
public
static
final
class
Seek
extends
Action
{
...
...
@@ -157,7 +156,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
try
{
if
(
windowIndex
==
null
)
{
player
.
seekTo
(
positionMs
);
...
...
@@ -172,7 +171,7 @@ public abstract class Action {
}
}
/** Calls {@link
Simple
ExoPlayer#setMediaSources(List, int, long)}. */
/** Calls {@link ExoPlayer#setMediaSources(List, int, long)}. */
public
static
final
class
SetMediaItems
extends
Action
{
private
final
int
windowIndex
;
...
...
@@ -195,12 +194,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setMediaSources
(
Arrays
.
asList
(
mediaSources
),
windowIndex
,
positionMs
);
}
}
/** Calls {@link
Simple
ExoPlayer#addMediaSources(List)}. */
/** Calls {@link ExoPlayer#addMediaSources(List)}. */
public
static
final
class
AddMediaItems
extends
Action
{
private
final
MediaSource
[]
mediaSources
;
...
...
@@ -216,12 +215,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
addMediaSources
(
Arrays
.
asList
(
mediaSources
));
}
}
/** Calls {@link
Simple
ExoPlayer#setMediaSources(List, boolean)}. */
/** Calls {@link ExoPlayer#setMediaSources(List, boolean)}. */
public
static
final
class
SetMediaItemsResetPosition
extends
Action
{
private
final
boolean
resetPosition
;
...
...
@@ -241,12 +240,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setMediaSources
(
Arrays
.
asList
(
mediaSources
),
resetPosition
);
}
}
/** Calls {@link
Simple
ExoPlayer#moveMediaItem(int, int)}. */
/** Calls {@link ExoPlayer#moveMediaItem(int, int)}. */
public
static
class
MoveMediaItem
extends
Action
{
private
final
int
currentIndex
;
...
...
@@ -265,12 +264,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
moveMediaItem
(
currentIndex
,
newIndex
);
}
}
/** Calls {@link
Simple
ExoPlayer#removeMediaItem(int)}. */
/** Calls {@link ExoPlayer#removeMediaItem(int)}. */
public
static
class
RemoveMediaItem
extends
Action
{
private
final
int
index
;
...
...
@@ -286,12 +285,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
removeMediaItem
(
index
);
}
}
/** Calls {@link
Simple
ExoPlayer#removeMediaItems(int, int)}. */
/** Calls {@link ExoPlayer#removeMediaItems(int, int)}. */
public
static
class
RemoveMediaItems
extends
Action
{
private
final
int
fromIndex
;
...
...
@@ -310,12 +309,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
removeMediaItems
(
fromIndex
,
toIndex
);
}
}
/** Calls {@link
Simple
ExoPlayer#clearMediaItems()}}. */
/** Calls {@link ExoPlayer#clearMediaItems()}}. */
public
static
class
ClearMediaItems
extends
Action
{
/** @param tag A tag to use for logging. */
...
...
@@ -325,7 +324,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
clearMediaItems
();
}
}
...
...
@@ -360,7 +359,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
if
(
reset
==
null
)
{
player
.
stop
();
}
else
{
...
...
@@ -385,7 +384,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setPlayWhenReady
(
playWhenReady
);
}
}
...
...
@@ -412,13 +411,13 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
trackSelector
.
setParameters
(
trackSelector
.
buildUponParameters
().
setRendererDisabled
(
rendererIndex
,
disabled
));
}
}
/** Calls {@link
Simple
ExoPlayer#clearVideoSurface()}. */
/** Calls {@link ExoPlayer#clearVideoSurface()}. */
public
static
final
class
ClearVideoSurface
extends
Action
{
/** @param tag A tag to use for logging. */
...
...
@@ -428,12 +427,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
clearVideoSurface
();
}
}
/** Calls {@link
Simple
ExoPlayer#setVideoSurface(Surface)}. */
/** Calls {@link ExoPlayer#setVideoSurface(Surface)}. */
public
static
final
class
SetVideoSurface
extends
Action
{
/** @param tag A tag to use for logging. */
...
...
@@ -443,12 +442,12 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setVideoSurface
(
Assertions
.
checkNotNull
(
surface
));
}
}
/** Calls {@link
Simple
ExoPlayer#setAudioAttributes(AudioAttributes, boolean)}. */
/** Calls {@link ExoPlayer#setAudioAttributes(AudioAttributes, boolean)}. */
public
static
final
class
SetAudioAttributes
extends
Action
{
private
final
AudioAttributes
audioAttributes
;
...
...
@@ -468,7 +467,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setAudioAttributes
(
audioAttributes
,
handleAudioFocus
);
}
}
...
...
@@ -482,7 +481,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
prepare
();
}
}
...
...
@@ -503,7 +502,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setRepeatMode
(
repeatMode
);
}
}
...
...
@@ -524,7 +523,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setShuffleOrder
(
shuffleOrder
);
}
}
...
...
@@ -545,7 +544,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setShuffleModeEnabled
(
shuffleModeEnabled
);
}
}
...
...
@@ -591,9 +590,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
final
SimpleExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
final
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
if
(
target
instanceof
PlayerTarget
)
{
((
PlayerTarget
)
target
).
setPlayer
(
player
);
}
...
...
@@ -627,7 +624,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
setPlaybackParameters
(
playbackParameters
);
}
}
...
...
@@ -648,7 +645,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
player
.
createMessage
(
(
messageType
,
payload
)
->
{
...
...
@@ -680,7 +677,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -724,7 +721,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -768,7 +765,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -798,7 +795,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -816,7 +813,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -839,7 +836,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -863,7 +860,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -890,7 +887,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -914,7 +911,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -940,7 +937,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -964,7 +961,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -980,7 +977,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -1004,7 +1001,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -1030,7 +1027,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -1045,7 +1042,7 @@ public abstract class Action {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -1065,7 +1062,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
@@ -1083,7 +1080,7 @@ public abstract class Action {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
if
(
runnable
instanceof
PlayerRunnable
)
{
((
PlayerRunnable
)
runnable
).
setPlayer
(
player
);
}
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java
View file @
3c19850e
...
...
@@ -20,12 +20,12 @@ import android.view.Surface;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ExoPlaybackException
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.PlaybackParameters
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.PlayerMessage
;
import
com.google.android.exoplayer2.PlayerMessage.Target
;
import
com.google.android.exoplayer2.Renderer
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.audio.AudioAttributes
;
import
com.google.android.exoplayer2.source.MediaSource
;
...
...
@@ -91,7 +91,7 @@ public final class ActionSchedule {
* notification is needed.
*/
/* package */
void
start
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
mainHandler
,
...
...
@@ -601,7 +601,7 @@ public final class ActionSchedule {
void
onMessageArrived
();
}
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
private
boolean
hasArrived
;
@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. */
public
abstract
void
handleMessage
(
SimpleExoPlayer
player
,
int
messageType
,
@Nullable
Object
message
);
public
abstract
void
handleMessage
(
ExoPlayer
player
,
int
messageType
,
@Nullable
Object
message
);
@Override
public
final
void
handleMessage
(
...
...
@@ -626,8 +625,8 @@ public final class ActionSchedule {
}
}
/** Sets the player to be passed to {@link #handleMessage(
Simple
ExoPlayer, int, Object)}. */
/* package */
void
setPlayer
(
Simple
ExoPlayer
player
)
{
/** Sets the player to be passed to {@link #handleMessage(ExoPlayer, int, Object)}. */
/* package */
void
setPlayer
(
ExoPlayer
player
)
{
this
.
player
=
player
;
}
}
...
...
@@ -638,18 +637,18 @@ public final class ActionSchedule {
*/
public
abstract
static
class
PlayerRunnable
implements
Runnable
{
@Nullable
private
Simple
ExoPlayer
player
;
@Nullable
private
ExoPlayer
player
;
/** Executes Runnable with reference to player. */
public
abstract
void
run
(
Simple
ExoPlayer
player
);
public
abstract
void
run
(
ExoPlayer
player
);
@Override
public
final
void
run
()
{
run
(
Assertions
.
checkStateNotNull
(
player
));
}
/** Sets the player to be passed to {@link #run(
Simple
ExoPlayer)} . */
/* package */
void
setPlayer
(
Simple
ExoPlayer
player
)
{
/** Sets the player to be passed to {@link #run(ExoPlayer)} . */
/* package */
void
setPlayer
(
ExoPlayer
player
)
{
this
.
player
=
player
;
}
}
...
...
@@ -663,7 +662,7 @@ public final class ActionSchedule {
@Nullable
private
ActionNode
next
;
private
@MonotonicNonNull
Simple
ExoPlayer
player
;
private
@MonotonicNonNull
ExoPlayer
player
;
private
@MonotonicNonNull
DefaultTrackSelector
trackSelector
;
@Nullable
private
Surface
surface
;
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.
*/
public
void
schedule
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
mainHandler
)
{
...
...
@@ -754,7 +753,7 @@ public final class ActionSchedule {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Do nothing.
}
}
...
...
@@ -774,7 +773,7 @@ public final class ActionSchedule {
@Override
protected
void
doActionAndScheduleNextImpl
(
Simple
ExoPlayer
player
,
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
,
HandlerWrapper
handler
,
...
...
@@ -788,7 +787,7 @@ public final class ActionSchedule {
@Override
protected
void
doActionImpl
(
Simple
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
ExoPlayer
player
,
DefaultTrackSelector
trackSelector
,
@Nullable
Surface
surface
)
{
// Not triggered.
}
}
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java
View file @
3c19850e
...
...
@@ -27,7 +27,6 @@ import com.google.android.exoplayer2.DefaultRenderersFactory;
import
com.google.android.exoplayer2.ExoPlaybackException
;
import
com.google.android.exoplayer2.ExoPlayer
;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.analytics.AnalyticsListener
;
import
com.google.android.exoplayer2.audio.DefaultAudioSink
;
import
com.google.android.exoplayer2.decoder.DecoderCounters
;
...
...
@@ -66,7 +65,7 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
private
final
ConditionVariable
testFinished
;
@Nullable
private
ActionSchedule
pendingSchedule
;
private
@MonotonicNonNull
Simple
ExoPlayer
player
;
private
@MonotonicNonNull
ExoPlayer
player
;
private
@MonotonicNonNull
HandlerWrapper
actionHandler
;
private
@MonotonicNonNull
DefaultTrackSelector
trackSelector
;
private
@MonotonicNonNull
Surface
surface
;
...
...
@@ -242,12 +241,12 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
return
new
DefaultTrackSelector
(
host
);
}
protected
Simple
ExoPlayer
buildExoPlayer
(
protected
ExoPlayer
buildExoPlayer
(
HostActivity
host
,
Surface
surface
,
MappingTrackSelector
trackSelector
)
{
DefaultRenderersFactory
renderersFactory
=
new
DefaultRenderersFactory
(
host
);
renderersFactory
.
setExtensionRendererMode
(
DefaultRenderersFactory
.
EXTENSION_RENDERER_MODE_OFF
);
renderersFactory
.
setAllowedVideoJoiningTimeMs
(
/* allowedVideoJoiningTimeMs= */
0
);
Simple
ExoPlayer
player
=
ExoPlayer
player
=
new
ExoPlayer
.
Builder
(
host
,
renderersFactory
).
setTrackSelector
(
trackSelector
).
build
();
player
.
setVideoSurface
(
surface
);
return
player
;
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java
View file @
3c19850e
...
...
@@ -34,7 +34,6 @@ import com.google.android.exoplayer2.PlaybackException;
import
com.google.android.exoplayer2.Player
;
import
com.google.android.exoplayer2.Renderer
;
import
com.google.android.exoplayer2.RenderersFactory
;
import
com.google.android.exoplayer2.SimpleExoPlayer
;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.analytics.AnalyticsListener
;
import
com.google.android.exoplayer2.source.MediaSource
;
...
...
@@ -71,7 +70,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
.
build
();
/**
* Builder to set-up a {@link ExoPlayerTestRunner}. Default fake implementations will be used for
* Builder to set-up a
n
{@link ExoPlayerTestRunner}. Default fake implementations will be used for
* unset test properties.
*/
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
* executed immediately before {@link
Simple
ExoPlayer#prepare()}.
* executed immediately before {@link ExoPlayer#prepare()}.
*
* @param actionSchedule An {@link ActionSchedule} to be used by the test runner.
* @return This builder.
...
...
@@ -379,7 +378,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
private
final
ArrayList
<
Integer
>
playbackStates
;
private
final
boolean
pauseAtEndOfMediaItems
;
private
Simple
ExoPlayer
player
;
private
ExoPlayer
player
;
private
Exception
exception
;
private
boolean
playerWasPrepared
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment