Commit b0260f7c by kimvde Committed by Oliver Woodman

Add experimentalSetForegroundModeTimeoutMs on SimpleExoPlayer

This is necessary to migrate apps which are using
ExoPlayer.Builder.experimentalSetForegroundModeTimeoutMs
from ExoPlayerImpl to SimpleExoPlayer.

PiperOrigin-RevId: 368657557
parent 3ab344c2
......@@ -98,6 +98,7 @@ public class SimpleExoPlayer extends BasePlayer
private final RenderersFactory renderersFactory;
private Clock clock;
private long foregroundModeTimeoutMs;
private TrackSelector trackSelector;
private MediaSourceFactory mediaSourceFactory;
private LoadControl loadControl;
......@@ -253,6 +254,20 @@ public class SimpleExoPlayer extends BasePlayer
}
/**
* Set a limit on the time a call to {@link #setForegroundMode} can spend. If a call to {@link
* #setForegroundMode} takes more than {@code timeoutMs} milliseconds to complete, the player
* will raise an error via {@link Player.EventListener#onPlayerError}.
*
* <p>This method is experimental, and will be renamed or removed in a future release.
*
* @param timeoutMs The time limit in milliseconds.
*/
public Builder experimentalSetForegroundModeTimeoutMs(long timeoutMs) {
foregroundModeTimeoutMs = timeoutMs;
return this;
}
/**
* Sets the {@link TrackSelector} that will be used by the player.
*
* @param trackSelector A {@link TrackSelector}.
......@@ -704,6 +719,9 @@ public class SimpleExoPlayer extends BasePlayer
additionalPermanentAvailableCommands);
player.addListener(componentListener);
player.addAudioOffloadListener(componentListener);
if (builder.foregroundModeTimeoutMs > 0) {
player.experimentalSetForegroundModeTimeoutMs(builder.foregroundModeTimeoutMs);
}
audioBecomingNoisyManager =
new AudioBecomingNoisyManager(builder.context, eventHandler, componentListener);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment