SubtitleData

Added in 1.1.0
Deprecated in 1.3.0

public final class SubtitleData implements VersionedParcelable


Class encapsulating subtitle data, as received through the onSubtitleData interface. The subtitle data includes:

  • the start time (in microseconds) of the data
  • the duration (in microseconds) of the data
  • the actual data.
The data is stored in a byte-array, and is encoded in one of the supported in-band subtitle formats. The subtitle encoding is determined by the MIME type of the of the subtitle track, one of MIMETYPE_TEXT_CEA_608 or 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

SubtitleData(long startTimeUs, long durationUs, @NonNull byte[] data)

Public methods

boolean
@NonNull byte[]

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

Public constructors

SubtitleData

Added in 1.1.0
Deprecated in 1.3.0
public SubtitleData(long startTimeUs, long durationUs, @NonNull byte[] data)

Public methods

equals

public boolean equals(@Nullable Object o)

getData

Added in 1.1.0
Deprecated in 1.3.0
public @NonNull 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
@NonNull byte[]

the encoded subtitle data

getDurationUs

Added in 1.1.0
Deprecated in 1.3.0
public long getDurationUs()

Returns the duration in microsecond during which the subtitle should be displayed.

Returns
long

the display duration for the subtitle

getStartTimeUs

Added in 1.1.0
Deprecated in 1.3.0
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()