SimpleExoPlayer
public static interface Player.AudioComponent
Player
.Modifier and Type | Method | 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. |
boolean |
getSkipSilenceEnabled() |
Returns whether skipping silences in the audio stream is enabled.
|
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,
boolean handleAudioFocus) |
Sets the attributes for audio playback, used by the underlying audio track.
|
void |
setAudioSessionId(int audioSessionId) |
Sets the ID of the audio session to attach to the underlying
AudioTrack . |
void |
setAuxEffectInfo(AuxEffectInfo auxEffectInfo) |
Sets information on an auxiliary audio effect to attach to the underlying audio track.
|
void |
setSkipSilenceEnabled(boolean skipSilenceEnabled) |
Sets whether skipping silences in the audio stream is enabled.
|
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.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()
void setAudioSessionId(int audioSessionId)
AudioTrack
.
The audio session ID can be generated using C.generateAudioSessionIdV21(Context)
for API 21+.
audioSessionId
- The audio session ID, or C.AUDIO_SESSION_ID_UNSET
if it should
be generated by the framework.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()
void setSkipSilenceEnabled(boolean skipSilenceEnabled)
skipSilenceEnabled
- Whether skipping silences in the audio stream is enabled.boolean getSkipSilenceEnabled()