Package com.castlabs.android.player.models

# Class AudioTrack

java.lang.Object
com.castlabs.android.player.models.Track
com.castlabs.android.player.models.AudioTrack

public class AudioTrack extends Track
A Audio track.

Since:
  3.0.0

- ## Field Summary

  ### Fields inherited from class com.castlabs.android.player.models.Track

  `LABEL_LOCALE, UNKNOWN_INDEX`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AudioTrack(int bitrate)`
  Create a new track with the given bitrate
  `AudioTrack(long durationUs, com.google.android.exoplayer2.Format format)`
  Create a new track with the given duration and initialise it from the given format data

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `int`
  `getAudioChannels()`
  `float`
  `getAudioSamplingRate()`
  `int`
  `getBitrate()`
  `String`
  `getCodecs()`
  `Drm`
  `getDrm()`
  Get `Drm` of the current track
  `com.google.android.exoplayer2.drm.DrmInitData`
  `getDrmInitData()`
  `long`
  `getDurationUs()`
  The duration in microseconds, or `SdkConsts.UNKNOWN_TIME_US` if the duration is unknown, or `SdkConsts.MATCH_LONGEST_US` if the duration should match the duration of the longest track whose duration is known.
  `String`
  `getId()`
  Set the id of this track
  `String`
  `getLabel()`
  Returns the default label for this track.
  `String`
  `getLanguage()`
  The language of the format.
  `String`
  `getMediaMimeType()`
  `String`
  `getMimeType()`
  `String`
  `getName()`
  The name associated with this track.
  `String`
  `getOriginalLanguage()`
  The language tag as present in the manifest.
  `int`
  `getSelectionFlags()`
  `TrackRendererPlugin.Type`
  `getType()`
  `int`
  `hashCode()`
  `boolean`
  `isSupportedCodec()`
  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.
  `void`
  `setAudioChannels(int audioChannels)`
  Set the number of audio channels for this track
  `void`
  `setAudioSamplingRate(float audioSamplingRate)`
  Set the samplign rate
  `void`
  `setCodecs(String codecs)`
  `void`
  `setDrm(Drm drm)`
  Assign `Drm` to the current track
  `void`
  `setDurationUs(long durationUs)`
  Set the duration of this track in microseconds
  `void`
  `setId(String id)`
  Set the id associated with this track
  `void`
  `setLanguage(String language)`
  Set the language of this track.
  `void`
  `setMediaMimeType(String mimeType)`
  Set the media mime type accociated with this track
  `void`
  `setMimeType(String mimeType)`
  Set the codec mime type accociated with this track.
  `void`
  `setName(String name)`
  Set a name associated with this track
  `void`
  `setOriginalLanguage(String language)`
  Set the manifest language of this track.
  `void`
  `setSelectionFlags(int selectionFlags)`
  Set the selection flags
  `String`
  `toString()`

  ### Methods inherited from class com.castlabs.android.player.models.Track

  `addDescriptor, getDescriptors, getLocalizedLanguageName, getOriginalGroupIndex, getOriginalTrackIndex, getTrackIndex, hasTrickModeId, isTrickModeTrack, setDescriptors, setOriginalGroupIndex, setOriginalTrackIndex, setTrackIndex, setTrickModeIds`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### 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 Details

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

  - ### getDurationUs

    public long getDurationUs()
    The duration in microseconds, or `SdkConsts.UNKNOWN_TIME_US` if the duration is unknown, or `SdkConsts.MATCH_LONGEST_US` if the duration should match the duration of the longest track whose duration is known.
    Returns:
      The duration in microseconds or `SdkConsts.UNKNOWN_TIME_US`

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

  - ### getMediaMimeType

    @Nullable public String getMediaMimeType()
    Returns:
      The media mime type associated with this track. This is the type of the media container

  - ### setMediaMimeType

    public void setMediaMimeType(@Nullable String mimeType)
    Set the media mime type accociated with this track
    Parameters:
      `mimeType` - media the mime type

  - ### getMimeType

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

  - ### setMimeType

    public void setMimeType(@Nullable String mimeType)
    Set the codec mime type accociated with this track. This is the type of the elementary stream (i.e. the individual samples)
    Parameters:
      `mimeType` - codec 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

  - ### getType

    public TrackRendererPlugin.Type getType()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Track`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Track`