AudioRendererEventListener


@UnstableApi
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 functions

Unit
onAudioCodecError(audioCodecError: Exception!)

Called when an audio decoder encounters an error.

Unit
onAudioDecoderInitialized(
    decoderName: String!,
    initializedTimestampMs: Long,
    initializationDurationMs: Long
)

Called when a decoder is created.

Unit

Called when a decoder is released.

Unit

Called when the renderer is disabled.

Unit

Called when the renderer is enabled.

Unit

This function is deprecated.

Use onAudioInputFormatChanged.

Unit
onAudioInputFormatChanged(
    format: Format!,
    decoderReuseEvaluation: DecoderReuseEvaluation?
)

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

Unit
onAudioPositionAdvancing(playoutStartSystemTimeMs: Long)

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

Unit
onAudioSinkError(audioSinkError: Exception!)

Called when AudioSink has encountered an error.

Unit

Called when an AudioTrack has been initialized.

Unit

Called when an AudioTrack has been released.

Unit
onAudioUnderrun(
    bufferSize: Int,
    bufferSizeMs: Long,
    elapsedSinceLastFeedMs: Long
)

Called when an audio underrun occurs.

Unit
onSkipSilenceEnabledChanged(skipSilenceEnabled: Boolean)

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

Public functions

onAudioCodecError

fun onAudioCodecError(audioCodecError: Exception!): Unit

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
audioCodecError: Exception!

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

onAudioDecoderInitialized

fun onAudioDecoderInitialized(
    decoderName: String!,
    initializedTimestampMs: Long,
    initializationDurationMs: Long
): Unit

Called when a decoder is created.

Parameters
decoderName: String!

The decoder that was created.

initializedTimestampMs: Long

elapsedRealtime when initialization finished.

initializationDurationMs: Long

The time taken to initialize the decoder in milliseconds.

onAudioDecoderReleased

fun onAudioDecoderReleased(decoderName: String!): Unit

Called when a decoder is released.

Parameters
decoderName: String!

The decoder that was released.

onAudioDisabled

fun onAudioDisabled(counters: DecoderCounters!): Unit

Called when the renderer is disabled.

Parameters
counters: DecoderCounters!

DecoderCounters that were updated by the renderer.

onAudioEnabled

fun onAudioEnabled(counters: DecoderCounters!): Unit

Called when the renderer is enabled.

Parameters
counters: DecoderCounters!

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

onAudioInputFormatChanged

fun onAudioInputFormatChanged(format: Format!): Unit

onAudioInputFormatChanged

fun onAudioInputFormatChanged(
    format: Format!,
    decoderReuseEvaluation: DecoderReuseEvaluation?
): Unit

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

Parameters
format: Format!

The new format.

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

fun onAudioPositionAdvancing(playoutStartSystemTimeMs: Long): Unit

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

Parameters
playoutStartSystemTimeMs: Long

The approximate derived currentTimeMillis at which playout started.

onAudioSinkError

fun onAudioSinkError(audioSinkError: Exception!): Unit

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
audioSinkError: Exception!

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

onAudioTrackInitialized

fun onAudioTrackInitialized(audioTrackConfig: AudioSink.AudioTrackConfig!): Unit

Called when an AudioTrack has been initialized.

Parameters
audioTrackConfig: AudioSink.AudioTrackConfig!

The AudioSink.AudioTrackConfig of the initialized .

onAudioTrackReleased

fun onAudioTrackReleased(audioTrackConfig: AudioSink.AudioTrackConfig!): Unit

Called when an AudioTrack has been released.

Parameters
audioTrackConfig: AudioSink.AudioTrackConfig!

The AudioSink.AudioTrackConfig of the released .

onAudioUnderrun

fun onAudioUnderrun(
    bufferSize: Int,
    bufferSizeMs: Long,
    elapsedSinceLastFeedMs: Long
): Unit

Called when an audio underrun occurs.

Parameters
bufferSize: Int

The size of the audio output buffer, in bytes.

bufferSizeMs: Long

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.

elapsedSinceLastFeedMs: Long

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

onSkipSilenceEnabledChanged

fun onSkipSilenceEnabledChanged(skipSilenceEnabled: Boolean): Unit

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

Parameters
skipSilenceEnabled: Boolean

Whether skipping silences in the audio stream is enabled.