# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# SubtitleData

`public final class SubtitleData`
`extends Object` ``

java.lang.Object
↳ | android.media.SubtitleData

Class encapsulating subtitle data, as received through the `MediaPlayer.OnSubtitleDataListener` interface. The subtitle data includes:

- the track index
- 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 `MediaPlayer.TrackInfo` of the subtitle track, one of `MediaFormat#MIMETYPE_TEXT_CEA_608`, `MediaFormat#MIMETYPE_TEXT_CEA_708`, `MediaFormat#MIMETYPE_TEXT_VTT`.

Here is an example of iterating over the tracks of a `MediaPlayer`, and checking which encoding is used for the subtitle tracks:

     MediaPlayer mp = new MediaPlayer();
     mp.setDataSource(myContentLocation);
     mp.prepare(); // synchronous prepare, ready to use when method returns
     final TrackInfo[] trackInfos = mp.getTrackInfo();
     for (TrackInfo info : trackInfo) {
         if (info.getTrackType() == TrackInfo.MEDIA_TRACK_TYPE_SUBTITLE) {
             final String mime = info.getFormat().getString(MediaFormat.KEY_MIME);
             if (MediaFormat.MIMETYPE_TEXT_CEA_608.equals(mime) {
                 // subtitle encoding is CEA 608
             } else if (MediaFormat.MIMETYPE_TEXT_CEA_708.equals(mime) {
                 // subtitle encoding is CEA 708
             } else if (MediaFormat.MIMETYPE_TEXT_VTT.equals(mime) {
                 // subtitle encoding is WebVTT
             }
         }
     }

See `MediaPlayer#setOnSubtitleDataListener(android.media.MediaPlayer.OnSubtitleDataListener, android.os.Handler)` to receive subtitle data from a MediaPlayer object.

See also:

- `MediaPlayer`

## Summary

### Public constructors
`SubtitleData(int trackIndex, long startTimeUs, long durationUs, byte[] data)` Constructor.

### Public methods
`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` | `getTrackIndex()` Returns the index of the media player track which contains this subtitle data.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### SubtitleData

    public SubtitleData (int trackIndex,
                    long startTimeUs,
                    long durationUs,
                    byte[] data)

Constructor.

Parameters
`trackIndex` | `int`: the index of the media player track which contains this subtitle data.
`startTimeUs` | `long`: the start time in microsecond for the subtitle data
`durationUs` | `long`: the duration in microsecond for the subtitle data
`data` | `byte`: the data array for the subtitle data. It should not be null. No data copying is made. This value cannot be `null`.

## Public methods

### getData

    public byte[] getData ()

Returns the encoded data for the subtitle content. Encoding format depends on the subtitle type, refer to CEA 708, CEA/EIA 608 and WebVTT, defined by the MIME type of the subtitle track.

Returns
`byte[]` | the encoded subtitle data This value cannot be `null`.

### 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

### getTrackIndex

    public int getTrackIndex ()

Returns the index of the media player track which contains this subtitle data.

Returns
`int` | an index in the array returned by `MediaPlayer#getTrackInfo()`.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*