public final class AudioFocusManager
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
AudioFocusManager.PlayerCommand
Player commands.
|
static interface |
AudioFocusManager.PlayerControl
Interface to allow AudioFocusManager to give commands to a player.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
PLAYER_COMMAND_DO_NOT_PLAY
Do not play.
|
static int |
PLAYER_COMMAND_PLAY_WHEN_READY
Play freely.
|
static int |
PLAYER_COMMAND_WAIT_FOR_CALLBACK
Do not play now.
|
| Constructor and Description |
|---|
AudioFocusManager(android.content.Context context,
AudioFocusManager.PlayerControl playerControl)
Constructs an AudioFocusManager to automatically handle audio focus for a player.
|
| Modifier and Type | Method and Description |
|---|---|
float |
getVolumeMultiplier()
Gets the current player volume multiplier.
|
int |
handlePrepare(boolean playWhenReady)
Called by a player as part of
ExoPlayer.prepare(MediaSource, boolean, boolean). |
int |
handleSetPlayWhenReady(boolean playWhenReady,
int playerState)
Called by the player as part of
Player.setPlayWhenReady(boolean). |
void |
handleStop()
Called by the player as part of
Player.stop(boolean). |
int |
setAudioAttributes(AudioAttributes audioAttributes,
boolean playWhenReady,
int playerState)
Sets audio attributes that should be used to manage audio focus.
|
public static final int PLAYER_COMMAND_DO_NOT_PLAY
public static final int PLAYER_COMMAND_WAIT_FOR_CALLBACK
public static final int PLAYER_COMMAND_PLAY_WHEN_READY
public AudioFocusManager(@Nullable
android.content.Context context,
AudioFocusManager.PlayerControl playerControl)
context - The current context.playerControl - A AudioFocusManager.PlayerControl to handle commands from this instance.public float getVolumeMultiplier()
@AudioFocusManager.PlayerCommand public int setAudioAttributes(@Nullable AudioAttributes audioAttributes, boolean playWhenReady, int playerState)
audioAttributes - The audio attributes or null if audio focus should not be
managed automatically.playWhenReady - The current state of Player.getPlayWhenReady().playerState - The current player state; Player.getPlaybackState().AudioFocusManager.PlayerCommand to execute on the player.@AudioFocusManager.PlayerCommand public int handlePrepare(boolean playWhenReady)
ExoPlayer.prepare(MediaSource, boolean, boolean).playWhenReady - The current state of Player.getPlayWhenReady().AudioFocusManager.PlayerCommand to execute on the player.@AudioFocusManager.PlayerCommand public int handleSetPlayWhenReady(boolean playWhenReady, int playerState)
Player.setPlayWhenReady(boolean).playWhenReady - The desired value of playWhenReady.playerState - The current state of the player.AudioFocusManager.PlayerCommand to execute on the player.public void handleStop()
Player.stop(boolean).