Use SimpleExoPlayer.Builder where necessary

An upcoming change will modify ExoPlayer.Builder#build() to return
ExoPlayer, so any places that explicitly need a SimpleExoPlayer
instance should be using SimpleExoPlayer.Builder.

PiperOrigin-RevId: 403028312
This commit is contained in:
ibaker 2021-10-14 09:31:13 +01:00 committed by Oliver Woodman
parent 5fe3ec59ca
commit a168c8c928
2 changed files with 9 additions and 14 deletions

View File

@ -53,7 +53,7 @@ public class SimpleExoPlayerTest {
public void builder_inBackgroundThread_doesNotThrow() throws Exception {
Thread builderThread =
new Thread(
() -> new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build());
() -> new SimpleExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build());
AtomicReference<Throwable> builderThrow = new AtomicReference<>();
builderThread.setUncaughtExceptionHandler((thread, throwable) -> builderThrow.set(throwable));
@ -66,7 +66,7 @@ public class SimpleExoPlayerTest {
@Test
public void onPlaylistMetadataChanged_calledWhenPlaylistMetadataSet() {
SimpleExoPlayer player =
new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build();
new SimpleExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build();
Player.Listener playerListener = mock(Player.Listener.class);
player.addListener(playerListener);
AnalyticsListener analyticsListener = mock(AnalyticsListener.class);
@ -82,7 +82,7 @@ public class SimpleExoPlayerTest {
@Test
public void release_triggersAllPendingEventsInAnalyticsListeners() throws Exception {
SimpleExoPlayer player =
new ExoPlayer.Builder(
new SimpleExoPlayer.Builder(
ApplicationProvider.getApplicationContext(),
(handler, videoListener, audioListener, textOutput, metadataOutput) ->
new Renderer[] {new FakeVideoRenderer(handler, videoListener)})
@ -108,7 +108,7 @@ public class SimpleExoPlayerTest {
public void releaseAfterRendererEvents_triggersPendingVideoEventsInListener() throws Exception {
Surface surface = new Surface(new SurfaceTexture(/* texName= */ 0));
SimpleExoPlayer player =
new ExoPlayer.Builder(
new SimpleExoPlayer.Builder(
ApplicationProvider.getApplicationContext(),
(handler, videoListener, audioListener, textOutput, metadataOutput) ->
new Renderer[] {new FakeVideoRenderer(handler, videoListener)})
@ -134,7 +134,7 @@ public class SimpleExoPlayerTest {
@Test
public void releaseAfterVolumeChanges_triggerPendingVolumeEventInListener() throws Exception {
SimpleExoPlayer player =
new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build();
new SimpleExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build();
Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener);
@ -148,7 +148,7 @@ public class SimpleExoPlayerTest {
@Test
public void releaseAfterVolumeChanges_triggerPendingDeviceVolumeEventsInListener() {
SimpleExoPlayer player =
new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build();
new SimpleExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build();
Player.Listener listener = mock(Player.Listener.class);
player.addListener(listener);

View File

@ -22,7 +22,6 @@ import android.os.Looper;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.LoadControl;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.RenderersFactory;
@ -274,11 +273,7 @@ public class TestExoPlayerBuilder {
return seekForwardIncrementMs;
}
/**
* Builds an {@link SimpleExoPlayer} using the provided values or their defaults.
*
* @return The built {@link ExoPlayerTestRunner}.
*/
/** Builds an {@link SimpleExoPlayer} using the provided values or their defaults. */
public SimpleExoPlayer build() {
Assertions.checkNotNull(
looper, "TestExoPlayer builder run on a thread without Looper and no Looper specified.");
@ -300,8 +295,8 @@ public class TestExoPlayerBuilder {
};
}
ExoPlayer.Builder builder =
new ExoPlayer.Builder(context, playerRenderersFactory)
SimpleExoPlayer.Builder builder =
new SimpleExoPlayer.Builder(context, playerRenderersFactory)
.setTrackSelector(trackSelector)
.setLoadControl(loadControl)
.setBandwidthMeter(bandwidthMeter)