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 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
getAudioChannels()
float
getAudioSamplingRate()
int
getBitrate()
String
getCodecs()
Drm
getDrm()
GetDrm
of the current trackcom.google.android.exoplayer2.drm.DrmInitData
getDrmInitData()
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.String
getId()
Set the id of this trackString
getLabel()
Returns the default label for this track.String
getLanguage()
The language of the format.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 trackvoid
setAudioSamplingRate(float audioSamplingRate)
Set the samplign ratevoid
setCodecs(String codecs)
void
setDrm(Drm drm)
AssignDrm
to the current trackvoid
setDurationUs(long durationUs)
Set the duration of this track in microsecondsvoid
setId(String id)
Set the id associated with this trackvoid
setLanguage(String language)
Set the language of this track.void
setMimeType(String mimeType)
Set the mime type accociated with this trackvoid
setName(String name)
Set a name associated with this trackvoid
setOriginalLanguage(String language)
Set the manifest language of this track.void
setSelectionFlags(int selectionFlags)
Set the selection flagsString
toString()
-
Methods inherited from class com.castlabs.android.player.models.Track
addDescriptor, getDescriptors, getLocalizedLanguageName, getOriginalGroupIndex, getOriginalTrackIndex, getTrackIndex, hasTrickModeId, isTrickModeTrack, setDescriptors, setOriginalGroupIndex, setOriginalTrackIndex, setTrackIndex, setTrickModeIds
-
-
-
-
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 secondsformat
- the underlying format
-
-
Method Detail
-
getDrmInitData
@Nullable public com.google.android.exoplayer2.drm.DrmInitData getDrmInitData()
-
getDrm
@Nullable public Drm getDrm()
GetDrm
of the current track- Returns:
Drm
ornull
for clear content
-
setDrm
public void setDrm(@Nullable Drm drm)
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
-
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, 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.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()
-
-