Class AudioTrack


  • public class AudioTrack
    extends Track
    A Audio track.
    Since:
    3.0.0
    • Constructor Detail

      • AudioTrack

        public AudioTrack​(int bitrate)
        Create a new track with the given bitrate
        Parameters:
        bitrate - the bitrate
      • AudioTrack

        public AudioTrack​(long durationUs,
                          @NonNull
                          com.google.android.exoplayer2.Format format)
        Create a new track with the given duration and initialise it from the given format data
        Parameters:
        durationUs - the duration in micro seconds
        format - the underlying format
    • Method Detail

      • getDrmInitData

        @Nullable
        public com.google.android.exoplayer2.drm.DrmInitData getDrmInitData()
      • getDrm

        @Nullable
        public Drm getDrm()
        Get Drm of the current track
        Returns:
        Drm or null for clear content
      • setDrm

        public void setDrm​(@Nullable
                           Drm drm)
        Assign Drm to the current track
        Parameters:
        drm - Drm or null for clear content
      • getBitrate

        public int getBitrate()
        Returns:
        The average bandwidth in bits per second.
      • setDurationUs

        public void setDurationUs​(long durationUs)
        Set the duration of this track in microseconds
        Parameters:
        durationUs - the duration of this track in microseconds or SdkConsts.UNKNOWN_TIME_US
      • getMimeType

        @Nullable
        public String getMimeType()
        Returns:
        The mime type associated with this track
      • setMimeType

        public void setMimeType​(@Nullable
                                String mimeType)
        Set the mime type accociated with this track
        Parameters:
        mimeType - the mime type
      • getId

        @Nullable
        public String getId()
        Set the id of this track
        Returns:
        The id associated with this track
      • setId

        public void setId​(@Nullable
                          String id)
        Set the id associated with this track
        Parameters:
        id - the id
      • setSelectionFlags

        public void setSelectionFlags​(int selectionFlags)
        Set the selection flags
        Parameters:
        selectionFlags - the selection flags to set
      • getSelectionFlags

        public int getSelectionFlags()
        Returns:
        the selection flags
      • getAudioChannels

        public int getAudioChannels()
        Returns:
        The number of audio channels, or -1 if unknown
      • setAudioChannels

        public void setAudioChannels​(int audioChannels)
        Set the number of audio channels for this track
        Parameters:
        audioChannels - the number of channels
      • getLanguage

        @Nullable
        public String getLanguage()
        The language of the format. Can be null if unknown.

        The language codes are two-letter lowercase ISO language codes (such as "en") as defined by IETF BCP 47.

        Returns:
        The language tag associated with this track or null
      • setLanguage

        public void setLanguage​(@Nullable
                                String language)
        Set the language of this track.
        Parameters:
        language - the language
      • getOriginalLanguage

        @Nullable
        public String getOriginalLanguage()
        The language tag as present in the manifest. Can be null if unknown.
        Returns:
        The manifest language tag associated with this track or null
      • setOriginalLanguage

        public void setOriginalLanguage​(@Nullable
                                        String language)
        Set the manifest language of this track.
        Parameters:
        language - the language
      • getAudioSamplingRate

        public float getAudioSamplingRate()
        Returns:
        The audio sampling rate in Hz, or -1 if unknown
      • setAudioSamplingRate

        public void setAudioSamplingRate​(float audioSamplingRate)
        Set the samplign rate
        Parameters:
        audioSamplingRate - the sampling rate in Hz
      • getCodecs

        @Nullable
        public String getCodecs()
        Returns:
        A ist of codec of this quality or null
      • setCodecs

        public void setCodecs​(@Nullable
                              String codecs)
        Parameters:
        codecs - the codecs of this quality
      • getName

        @Nullable
        public String getName()
        The name associated with this track.
        Returns:
        The name associated with this track
      • setName

        public void setName​(@Nullable
                            String name)
        Set a name associated with this track
        Parameters:
        name - the name
      • getLabel

        public String getLabel()
        Returns the default label for this track. The label is either the DASH label if its available, or name if its set or the language, or it falls back to the codec name.
        Returns:
        The default label for this track
      • isSupportedCodec

        public boolean isSupportedCodec()
                                 throws com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException
        Based on the manifest mime type returns if it is possible to play this audio track either on the device querying the available decoders or via passthrough using HDMI information.
        Returns:
        the audio track is supported on the device or some other device connected to this one (such as Android TVs)
        Throws:
        com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException - in case an error occurs when decoder information is queried
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Track