Interface ExoPlayer.AudioComponent

  • All Known Implementing Classes:
    Enclosing interface:

    public static interface ExoPlayer.AudioComponent
    The audio component of an ExoPlayer.
    • Method Detail

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

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

        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).
        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).
        The linear gain applied to all audio channels.
      • setSkipSilenceEnabled

        void setSkipSilenceEnabled​(boolean skipSilenceEnabled)
        Sets whether skipping silences in the audio stream is enabled.
        skipSilenceEnabled - Whether skipping silences in the audio stream is enabled.
      • getSkipSilenceEnabled

        boolean getSkipSilenceEnabled()
        Returns whether skipping silences in the audio stream is enabled.