Package com.google.android.exoplayer2

## Interface ExoPlayer.AudioComponent

- All Known Implementing Classes:
    `SimpleExoPlayer`
  Enclosing interface:
    ExoPlayer

      public static interface ExoPlayer.AudioComponent

  The audio component of an `ExoPlayer`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addAudioListener​(AudioListener listener)` | Deprecated. Use `Player.addListener(Listener)`.
    `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 (signal unchanged).
    `void` | `removeAudioListener​(AudioListener listener)` | Deprecated. Use `Player.removeListener(Listener)`.
    `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 (signal unchanged).

- - ### Method Detail

    - #### addAudioListener

          @Deprecated
          void addAudioListener​(AudioListener listener)

      Deprecated.
      Use `Player.addListener(Listener)`.
      Adds a listener to receive audio events.
      Parameters:
        `listener` - The listener to register.

    - #### removeAudioListener

          @Deprecated
          void removeAudioListener​(AudioListener listener)

      Deprecated.
      Use `Player.removeListener(Listener)`.
      Removes a listener of audio events.
      Parameters:
        `listener` - The listener to unregister.

    - #### setAudioAttributes

          void setAudioAttributes​(AudioAttributes audioAttributes,
                                  boolean handleAudioFocus)

      Sets the attributes for audio playback, used by the underlying audio track. If not set, the default audio attributes will be used. They are suitable for general media playback.

      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`.

      Parameters:
        `audioAttributes` - The attributes to use for audio playback.
        `handleAudioFocus` - True if the player should handle audio focus, false otherwise.

    - #### getAudioAttributes

          AudioAttributes getAudioAttributes()

      Returns the attributes for audio playback.

    - #### setAudioSessionId

          void setAudioSessionId​(int audioSessionId)

      Sets the ID of the audio session to attach to the underlying `AudioTrack`.

      The audio session ID can be generated using `C.generateAudioSessionIdV21(Context)` for API 21+.

      Parameters:
        `audioSessionId` - The audio session ID, or `C.AUDIO_SESSION_ID_UNSET` if it should be generated by the framework.

    - #### getAudioSessionId

          int getAudioSessionId()

      Returns the audio session identifier, or `C.AUDIO_SESSION_ID_UNSET` if not set.

    - #### setAuxEffectInfo

          void setAuxEffectInfo​(AuxEffectInfo auxEffectInfo)

      Sets information on an auxiliary audio effect to attach to the underlying audio track.

    - #### clearAuxEffectInfo

          void clearAuxEffectInfo()

      Detaches any previously attached auxiliary audio effect from the underlying audio track.

    - #### setVolume

          void setVolume​(float audioVolume)

      Sets the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).
      Parameters:
        `audioVolume` - Linear output gain to apply to all audio channels.

    - #### getVolume

          float getVolume()

      Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).
      Returns:
        The linear gain applied to all audio channels.

    - #### setSkipSilenceEnabled

          void setSkipSilenceEnabled​(boolean skipSilenceEnabled)

      Sets whether skipping silences in the audio stream is enabled.
      Parameters:
        `skipSilenceEnabled` - Whether skipping silences in the audio stream is enabled.

    - #### getSkipSilenceEnabled

          boolean getSkipSilenceEnabled()

      Returns whether skipping silences in the audio stream is enabled.