AudioRendererEventListener


@UnstableApi
public interface AudioRendererEventListener


Listener of audio Renderer events. All methods have no-op default implementations to allow selective overrides.

Summary

Nested types

Dispatches events to an AudioRendererEventListener.

Public methods

default void
onAudioCodecError(Exception audioCodecError)

Called when an audio decoder encounters an error.

default void
onAudioDecoderInitialized(
    String decoderName,
    long initializedTimestampMs,
    long initializationDurationMs
)

Called when a decoder is created.

default void

Called when a decoder is released.

default void

Called when the renderer is disabled.

default void

Called when the renderer is enabled.

default void
onAudioInputFormatChanged(
    Format format,
    @Nullable DecoderReuseEvaluation decoderReuseEvaluation
)

Called when the format of the media being consumed by the renderer changes.

default void
onAudioPositionAdvancing(long playoutStartSystemTimeMs)

Called when the audio position has increased for the first time since the last pause or position reset.

default void
onAudioSinkError(Exception audioSinkError)

Called when AudioSink has encountered an error.

default void

Called when an AudioTrack has been initialized.

default void

Called when an AudioTrack has been released.

default void
onAudioUnderrun(
    int bufferSize,
    long bufferSizeMs,
    long elapsedSinceLastFeedMs
)

Called when an audio underrun occurs.

default void
onSkipSilenceEnabledChanged(boolean skipSilenceEnabled)

Called when skipping silences is enabled or disabled in the audio stream.

Public methods

onAudioCodecError

default void onAudioCodecError(Exception audioCodecError)

Called when an audio decoder encounters an error.

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. Hence applications should not implement this method to display a user visible error or initiate an application level retry. onPlayerError 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.

Parameters
Exception audioCodecError

The error. Typically a CodecException if the renderer uses MediaCodec, or a DecoderException if the renderer uses a software decoder.

onAudioDecoderInitialized

default void onAudioDecoderInitialized(
    String decoderName,
    long initializedTimestampMs,
    long initializationDurationMs
)

Called when a decoder is created.

Parameters
String decoderName

The decoder that was created.

long initializedTimestampMs

elapsedRealtime when initialization finished.

long initializationDurationMs

The time taken to initialize the decoder in milliseconds.

onAudioDecoderReleased

default void onAudioDecoderReleased(String decoderName)

Called when a decoder is released.

Parameters
String decoderName

The decoder that was released.

onAudioDisabled

default void onAudioDisabled(DecoderCounters counters)

Called when the renderer is disabled.

Parameters
DecoderCounters counters

DecoderCounters that were updated by the renderer.

onAudioEnabled

default void onAudioEnabled(DecoderCounters counters)

Called when the renderer is enabled.

Parameters
DecoderCounters counters

DecoderCounters that will be updated by the renderer for as long as it remains enabled.

onAudioInputFormatChanged

default void onAudioInputFormatChanged(
    Format format,
    @Nullable DecoderReuseEvaluation decoderReuseEvaluation
)

Called when the format of the media being consumed by the renderer changes.

Parameters
Format format

The new format.

@Nullable DecoderReuseEvaluation decoderReuseEvaluation

The result of the evaluation to determine whether an existing decoder instance can be reused for the new format, or null if the renderer did not have a decoder.

onAudioPositionAdvancing

default void onAudioPositionAdvancing(long playoutStartSystemTimeMs)

Called when the audio position has increased for the first time since the last pause or position reset.

Parameters
long playoutStartSystemTimeMs

The approximate derived currentTimeMillis at which playout started.

onAudioSinkError

default void onAudioSinkError(Exception audioSinkError)

Called when AudioSink has encountered an error.

If the sink writes to a platform AudioTrack, this will be called for all 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. Hence applications should not implement this method to display a user visible error or initiate an application level retry. onPlayerError 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.

Parameters
Exception audioSinkError

The error that occurred. Typically an , a AudioSink.WriteException, or an .

onAudioTrackInitialized

default void onAudioTrackInitialized(AudioSink.AudioTrackConfig audioTrackConfig)

Called when an AudioTrack has been initialized.

Parameters
AudioSink.AudioTrackConfig audioTrackConfig

The AudioSink.AudioTrackConfig of the initialized .

onAudioTrackReleased

default void onAudioTrackReleased(AudioSink.AudioTrackConfig audioTrackConfig)

Called when an AudioTrack has been released.

Parameters
AudioSink.AudioTrackConfig audioTrackConfig

The AudioSink.AudioTrackConfig of the released .

onAudioUnderrun

default void onAudioUnderrun(
    int bufferSize,
    long bufferSizeMs,
    long elapsedSinceLastFeedMs
)

Called when an audio underrun occurs.

Parameters
int bufferSize

The size of the audio output buffer, in bytes.

long bufferSizeMs

The size of the audio output buffer, in milliseconds, if it contains PCM encoded audio. TIME_UNSET if the output buffer contains non-PCM encoded audio.

long elapsedSinceLastFeedMs

The time since audio was last written to the output buffer.

onSkipSilenceEnabledChanged

default void onSkipSilenceEnabledChanged(boolean skipSilenceEnabled)

Called when skipping silences is enabled or disabled in the audio stream.

Parameters
boolean skipSilenceEnabled

Whether skipping silences in the audio stream is enabled.