SubtitleData
public
final
class
SubtitleData
extends Object
implements
VersionedParcelable
| java.lang.Object | |
| ↳ | androidx.media2.common.SubtitleData |
Class encapsulating subtitle data, as received through the
SessionPlayer.PlayerCallback.onSubtitleData(SessionPlayer, MediaItem, SessionPlayer.TrackInfo, SubtitleData) 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
MediaFormat.MIMETYPE_TEXT_CEA_608 or
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
}
}
}
See also:
Summary
Public constructors | |
|---|---|
SubtitleData(long startTimeUs, long durationUs, byte[] data)
|
|
Public methods | |
|---|---|
boolean
|
equals(Object o)
|
byte[]
|
getData()
Returns the encoded data for the subtitle content. |
long
|
getDurationUs()
Returns the duration in microsecond during which the subtitle should be displayed. |
long
|
getStartTimeUs()
Returns the media time at which the subtitle should be displayed, expressed in microseconds. |
int
|
hashCode()
|
Inherited methods | |
|---|---|
Public constructors
SubtitleData
public SubtitleData (long startTimeUs,
long durationUs,
byte[] data)
| Parameters | |
|---|---|
startTimeUs |
long |
durationUs |
long |
data |
byte |
Public methods
equals
public boolean equals (Object o)
| Parameters | |
|---|---|
o |
Object |
| Returns | |
|---|---|
boolean |
|
getData
public byte[] getData ()
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.
| Returns | |
|---|---|
byte[] |
the encoded subtitle data |
getDurationUs
public long getDurationUs ()
Returns the duration in microsecond during which the subtitle should be displayed.
| Returns | |
|---|---|
long |
the display duration for the subtitle |
getStartTimeUs
public long getStartTimeUs ()
Returns the media time at which the subtitle should be displayed, expressed in microseconds.
| Returns | |
|---|---|
long |
the display start time for the subtitle |
hashCode
public int hashCode ()
| Returns | |
|---|---|
int |
|