SubtitleData
class SubtitleData : VersionedParcelable
kotlin.Any | |
↳ | androidx.media2.common.SubtitleData |
Class encapsulating subtitle data, as received through the SessionPlayer.PlayerCallback#onSubtitleData
interface. The subtitle data includes:
- the start time (in microseconds) of the data
- the duration (in microseconds) of the data
- the actual data.
SessionPlayer.TrackInfo
of the subtitle track, one of android.media.MediaFormat#MIMETYPE_TEXT_CEA_608
or android.media.MediaFormat#MIMETYPE_TEXT_CEA_708
.
Here is an example of iterating over the tracks of a SessionPlayer
, and checking which encoding is used for the subtitle tracks:
// Initialize instance of player that extends SessionPlayer SessionPlayerExtension player = new SessionPlayerExtension(); final TrackInfo[] trackInfos = player.getTrackInfo(); for (TrackInfo info : trackInfo) { if (info.getTrackType() == TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) { final String mime = info.getFormat().getString(MediaFormat.KEY_MIME); if ("text/cea-608".equals(mime) { // subtitle encoding is CEA 608 } else if ("text/cea-708".equals(mime) { // subtitle encoding is CEA 708 } } }
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
Boolean | |
ByteArray |
getData() Returns the encoded data for the subtitle content. |
Long |
Returns the duration in microsecond during which the subtitle should be displayed. |
Long |
Returns the media time at which the subtitle should be displayed, expressed in microseconds. |
Int |
hashCode() |
Public constructors
Public methods
getData
@NonNull fun getData(): ByteArray
Returns the encoded data for the subtitle content. Encoding format depends on the subtitle type, refer to CEA 708, and CEA/EIA 608 defined by the MIME type of the subtitle track.
Return | |
---|---|
ByteArray |
the encoded subtitle data |
getDurationUs
fun getDurationUs(): Long
Returns the duration in microsecond during which the subtitle should be displayed.
Return | |
---|---|
Long |
the display duration for the subtitle |
getStartTimeUs
fun getStartTimeUs(): Long
Returns the media time at which the subtitle should be displayed, expressed in microseconds.
Return | |
---|---|
Long |
the display start time for the subtitle |
hashCode
fun hashCode(): Int