Interface AudioSink.Listener
-
- Enclosing interface:
- AudioSink
public static interface AudioSink.Listener
Listener for audio sink events.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
onAudioCapabilitiesChanged()
Called when audio capabilities changed.default void
onAudioSinkError(Exception audioSinkError)
Called whenAudioSink
has encountered an error.default void
onOffloadBufferEmptying()
Called when the offload buffer has been partially emptied.default void
onOffloadBufferFull()
Called when the offload buffer has been filled completely.default void
onPositionAdvancing(long playoutStartSystemTimeMs)
Called when the audio sink's position has increased for the first time since it was last paused or flushed.void
onPositionDiscontinuity()
Called when the audio sink handles a buffer whose timestamp is discontinuous with the last buffer handled since it was reset.void
onSkipSilenceEnabledChanged(boolean skipSilenceEnabled)
Called when skipping silences is enabled or disabled.void
onUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs)
Called when the audio sink runs out of data.
-
-
-
Method Detail
-
onPositionDiscontinuity
void onPositionDiscontinuity()
Called when the audio sink handles a buffer whose timestamp is discontinuous with the last buffer handled since it was reset.
-
onPositionAdvancing
default void onPositionAdvancing(long playoutStartSystemTimeMs)
Called when the audio sink's position has increased for the first time since it was last paused or flushed.- Parameters:
playoutStartSystemTimeMs
- The approximate derivedSystem.currentTimeMillis()
at which playout started. Only valid if the audio track has not underrun.
-
onUnderrun
void onUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs)
Called when the audio sink runs out of data.An audio sink implementation may never call this method (for example, if audio data is consumed in batches rather than based on the sink's own clock).
- Parameters:
bufferSize
- The size of the sink's buffer, in bytes.bufferSizeMs
- The size of the sink's buffer, in milliseconds, if it is configured for PCM output.C.TIME_UNSET
if it is configured for encoded audio output, as the buffered media can have a variable bitrate so the duration may be unknown.elapsedSinceLastFeedMs
- The time since the sink was last fed data, in milliseconds.
-
onSkipSilenceEnabledChanged
void onSkipSilenceEnabledChanged(boolean skipSilenceEnabled)
Called when skipping silences is enabled or disabled.- Parameters:
skipSilenceEnabled
- Whether skipping silences is enabled.
-
onOffloadBufferEmptying
default void onOffloadBufferEmptying()
Called when the offload buffer has been partially emptied.
-
onOffloadBufferFull
default void onOffloadBufferFull()
Called when the offload buffer has been filled completely.
-
onAudioSinkError
default void onAudioSinkError(Exception audioSinkError)
Called whenAudioSink
has encountered an error.If the sink writes to a platform
AudioTrack
, this will called for allAudioTrack
errors.This method being called does not indicate that playback has failed, or that it will fail. The player may be able to recover from the error (for example by recreating the AudioTrack, possibly with different settings) and continue. Hence applications should not implement this method to display a user visible error or initiate an application level retry (
Player.Listener.onPlayerError(com.google.android.exoplayer2.PlaybackException)
is the appropriate place to implement such behavior). This method is called to provide the application with an opportunity to log the error if it wishes to do so.Fatal errors that cannot be recovered will be reported wrapped in a
ExoPlaybackException
byPlayer.Listener.onPlayerError(PlaybackException)
.- Parameters:
audioSinkError
- The error that occurred. Typically anAudioSink.InitializationException
, aAudioSink.WriteException
, or anAudioSink.UnexpectedDiscontinuityException
.
-
onAudioCapabilitiesChanged
default void onAudioCapabilitiesChanged()
Called when audio capabilities changed.
-
-