mirror of
https://github.com/samsonjs/media.git
synced 2026-03-28 09:55:48 +00:00
Add experimentalSetForegroundModeTimeoutMs on SimpleExoPlayer
This is necessary to migrate apps which are using ExoPlayer.Builder.experimentalSetForegroundModeTimeoutMs from ExoPlayerImpl to SimpleExoPlayer. PiperOrigin-RevId: 368657557
This commit is contained in:
parent
3ab344c218
commit
b0260f7cb8
1 changed files with 18 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
@ -252,6 +253,20 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
detachSurfaceTimeoutMs = DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue