Class AudioTrack
java.lang.Object
com.castlabs.android.player.models.Track
com.castlabs.android.player.models.AudioTrack
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
ConstructorsConstructorDescriptionAudioTrack
(int bitrate) Create a new track with the given bitrateAudioTrack
(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 TypeMethodDescriptionboolean
int
float
int
getDrm()
GetDrm
of the current trackcom.google.android.exoplayer2.drm.DrmInitData
long
The duration in microseconds, orSdkConsts.UNKNOWN_TIME_US
if the duration is unknown, orSdkConsts.MATCH_LONGEST_US
if the duration should match the duration of the longest track whose duration is known.getId()
Set the id of this trackgetLabel()
Returns the default label for this track.The language of the format.getName()
The name associated with this track.The language tag as present in the manifest.int
getType()
int
hashCode()
boolean
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 trackvoid
setAudioSamplingRate
(float audioSamplingRate) Set the samplign ratevoid
void
AssignDrm
to the current trackvoid
setDurationUs
(long durationUs) Set the duration of this track in microsecondsvoid
Set the id associated with this trackvoid
setLanguage
(String language) Set the language of this track.void
setMediaMimeType
(String mimeType) Set the media mime type accociated with this trackvoid
setMimeType
(String mimeType) Set the codec mime type accociated with this track.void
Set a name associated with this trackvoid
setOriginalLanguage
(String language) Set the manifest language of this track.void
setSelectionFlags
(int selectionFlags) Set the selection flagstoString()
Methods inherited from class com.castlabs.android.player.models.Track
addDescriptor, getDescriptors, getLocalizedLanguageName, getOriginalGroupIndex, getOriginalTrackIndex, getTrackIndex, hasTrickModeId, isTrickModeTrack, setDescriptors, setOriginalGroupIndex, setOriginalTrackIndex, setTrackIndex, setTrickModeIds
-
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 secondsformat
- the underlying format
-
-
Method Details
-
getDrmInitData
@Nullable public com.google.android.exoplayer2.drm.DrmInitData getDrmInitData() -
getDrm
GetDrm
of the current track- Returns:
Drm
ornull
for clear content
-
setDrm
AssignDrm
to the current track- Parameters:
drm
-Drm
ornull
for clear content
-
getBitrate
public int getBitrate()- Returns:
- The average bandwidth in bits per second.
-
getDurationUs
public long getDurationUs()The duration in microseconds, orSdkConsts.UNKNOWN_TIME_US
if the duration is unknown, orSdkConsts.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 orSdkConsts.UNKNOWN_TIME_US
-
getMediaMimeType
- Returns:
- The media mime type associated with this track. This is the type of the media container
-
setMediaMimeType
Set the media mime type accociated with this track- Parameters:
mimeType
- media the mime type
-
getMimeType
- Returns:
- The codec mime type associated with this track
-
setMimeType
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
Set the id of this track- Returns:
- The id associated with this track
-
setId
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
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
Set the language of this track.- Parameters:
language
- the language
-
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
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
- Returns:
- A ist of codec of this quality or null
-
setCodecs
- Parameters:
codecs
- the codecs of this quality
-
getName
The name associated with this track.- Returns:
- The name associated with this track
-
setName
Set a name associated with this track- Parameters:
name
- the name
-
getLabel
Returns the default label for this track. The label is either the DASH label if its available, orname
if its set or thelanguage
, 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.DecoderQueryExceptionBased 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
-
toString
-
hashCode
public int hashCode() -
equals
-