Package com.google.android.exoplayer2.audio

## Interface AudioRendererEventListener

- All Known Implementing Classes:
    `AnalyticsCollector`

      public interface AudioRendererEventListener

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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static class` | `AudioRendererEventListener.EventDispatcher` | Dispatches events to an `AudioRendererEventListener`.

  - ### Method Summary

    All Methods Instance Methods Default Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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` | `onAudioDecoderReleased​(String decoderName)` | Called when a decoder is released.
    `default void` | `onAudioDisabled​(DecoderCounters counters)` | Called when the renderer is disabled.
    `default void` | `onAudioEnabled​(DecoderCounters counters)` | Called when the renderer is enabled.
    `default void` | `onAudioInputFormatChanged​(Format format)` | Deprecated. Use `onAudioInputFormatChanged(Format, DecoderReuseEvaluation)`.
    `default void` | `onAudioInputFormatChanged​(Format format, 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` | `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.

- - ### Method Detail

    - #### onAudioEnabled

          default void onAudioEnabled​(DecoderCounters counters)

      Called when the renderer is enabled.
      Parameters:
        `counters` - `DecoderCounters` that will be updated by the renderer for as long as it remains enabled.

    - #### onAudioDecoderInitialized

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

      Called when a decoder is created.
      Parameters:
        `decoderName` - The decoder that was created.
        `initializedTimestampMs` - `SystemClock.elapsedRealtime()` when initialization finished.
        `initializationDurationMs` - The time taken to initialize the decoder in milliseconds.

    - #### onAudioInputFormatChanged

          @Deprecated
          default void onAudioInputFormatChanged​(Format format)

      Deprecated.
      Use `onAudioInputFormatChanged(Format, DecoderReuseEvaluation)`.

    - #### onAudioInputFormatChanged

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

      Called when the format of the media being consumed by the renderer changes.
      Parameters:
        `format` - The new format.
        `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:
        `playoutStartSystemTimeMs` - The approximate derived `System.currentTimeMillis()` at which playout started.

    - #### onAudioUnderrun

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

      Called when an audio underrun occurs.
      Parameters:
        `bufferSize` - The size of the audio output buffer, in bytes.
        `bufferSizeMs` - The size of the audio output buffer, in milliseconds, if it contains PCM encoded audio. `C.TIME_UNSET` if the output buffer contains non-PCM encoded audio.
        `elapsedSinceLastFeedMs` - The time since audio was last written to the output buffer.

    - #### onAudioDecoderReleased

          default void onAudioDecoderReleased​(String decoderName)

      Called when a decoder is released.
      Parameters:
        `decoderName` - The decoder that was released.

    - #### onAudioDisabled

          default void onAudioDisabled​(DecoderCounters counters)

      Called when the renderer is disabled.
      Parameters:
        `counters` - `DecoderCounters` that were updated by the renderer.

    - #### onSkipSilenceEnabledChanged

          default void onSkipSilenceEnabledChanged​(boolean skipSilenceEnabled)

      Called when skipping silences is enabled or disabled in the audio stream.
      Parameters:
        `skipSilenceEnabled` - Whether skipping silences in the audio stream is enabled.

    - #### 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. `Player.EventListener.onPlayerError(com.google.android.exoplayer2.ExoPlaybackException)` 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` - The error. Typically a `MediaCodec.CodecException` if the renderer uses `MediaCodec`, or a `DecoderException` if the renderer uses a software decoder.

    - #### onAudioSinkError

          default void onAudioSinkError​(Exception audioSinkError)

      Called when `AudioSink` has encountered an error.

      If the sink writes to a platform `AudioTrack`, this will called for all `AudioTrack` 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. `Player.EventListener.onPlayerError(com.google.android.exoplayer2.ExoPlaybackException)` 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` - The error that occurred. Typically an `AudioSink.InitializationException`, a `AudioSink.WriteException`, or an `AudioSink.UnexpectedDiscontinuityException`.