public static interface Player.AudioComponent
Player
.Modifier and Type | Method and Description |
---|---|
void |
addAudioListener(AudioListener listener)
Adds a listener to receive audio events.
|
void |
clearAuxEffectInfo()
Detaches any previously attached auxiliary audio effect from the underlying audio track.
|
AudioAttributes |
getAudioAttributes()
Returns the attributes for audio playback.
|
int |
getAudioSessionId()
Returns the audio session identifier, or
C.AUDIO_SESSION_ID_UNSET if not set. |
float |
getVolume()
Returns the audio volume, with 0 being silence and 1 being unity gain.
|
void |
removeAudioListener(AudioListener listener)
Removes a listener of audio events.
|
void |
setAudioAttributes(AudioAttributes audioAttributes)
Deprecated.
|
void |
setAudioAttributes(AudioAttributes audioAttributes,
boolean handleAudioFocus)
Sets the attributes for audio playback, used by the underlying audio track.
|
void |
setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
Sets information on an auxiliary audio effect to attach to the underlying audio track.
|
void |
setVolume(float audioVolume)
Sets the audio volume, with 0 being silence and 1 being unity gain.
|
void addAudioListener(AudioListener listener)
listener
- The listener to register.void removeAudioListener(AudioListener listener)
listener
- The listener to unregister.@Deprecated void setAudioAttributes(AudioAttributes audioAttributes)
setAudioAttributes(AudioAttributes, boolean)
.Setting the audio attributes during playback may introduce a short gap in audio output as the audio track is recreated. A new audio session id will also be generated.
If tunneling is enabled by the track selector, the specified audio attributes will be ignored, but they will take effect if audio is later played without tunneling.
If the device is running a build before platform API version 21, audio attributes cannot
be set directly on the underlying audio track. In this case, the usage will be mapped onto an
equivalent stream type using Util.getStreamTypeForAudioUsage(int)
.
audioAttributes
- The attributes to use for audio playback.void setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)
Setting the audio attributes during playback may introduce a short gap in audio output as the audio track is recreated. A new audio session id will also be generated.
If tunneling is enabled by the track selector, the specified audio attributes will be ignored, but they will take effect if audio is later played without tunneling.
If the device is running a build before platform API version 21, audio attributes cannot
be set directly on the underlying audio track. In this case, the usage will be mapped onto an
equivalent stream type using Util.getStreamTypeForAudioUsage(int)
.
If audio focus should be handled, the AudioAttributes.usage
must be C.USAGE_MEDIA
or C.USAGE_GAME
. Other usages will throw an IllegalArgumentException
.
audioAttributes
- The attributes to use for audio playback.handleAudioFocus
- True if the player should handle audio focus, false otherwise.AudioAttributes getAudioAttributes()
int getAudioSessionId()
C.AUDIO_SESSION_ID_UNSET
if not set.void setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
void clearAuxEffectInfo()
void setVolume(float audioVolume)
audioVolume
- The audio volume.float getVolume()