public abstract class SubtitleTrack extends Object implements MediaTimeProvider.OnMediaTimeListener
Modifier and Type | Class and Description |
---|---|
static class |
SubtitleTrack.Cue |
static interface |
SubtitleTrack.RenderingWidget
Interface for rendering subtitles onto a Canvas.
|
Modifier and Type | Field and Description |
---|---|
boolean |
DEBUG |
protected Vector<SubtitleTrack.Cue> |
mActiveCues |
protected android.media.SubtitleTrack.CueList |
mCues |
protected Handler |
mHandler |
protected LongSparseArray<android.media.SubtitleTrack.Run> |
mRunsByEndTime |
protected LongSparseArray<android.media.SubtitleTrack.Run> |
mRunsByID |
protected MediaTimeProvider |
mTimeProvider |
protected boolean |
mVisible |
Constructor and Description |
---|
SubtitleTrack(MediaFormat format) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addCue(SubtitleTrack.Cue cue) |
protected void |
clearActiveCues() |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
protected void |
finishedRun(long runID) |
MediaFormat |
getFormat() |
abstract SubtitleTrack.RenderingWidget |
getRenderingWidget()
Called when adding the subtitle rendering widget to the view hierarchy,
as well as when showing or hiding the subtitle track, or when the video
surface position has changed.
|
int |
getTrackType() |
void |
hide() |
abstract void |
onData(byte[] data,
boolean eos,
long runID)
Called when there is input data for the subtitle track.
|
protected void |
onData(SubtitleData data) |
void |
onSeek(long timeUs)
Called when the media time changed due to seeking.
|
void |
onStop()
Called when the playback stopped.
|
void |
onTimedEvent(long timeUs)
Called when the registered time was reached naturally.
|
protected void |
scheduleTimedEvents() |
void |
setRunDiscardTimeMs(long runID,
long timeMs) |
void |
setTimeProvider(MediaTimeProvider timeProvider) |
void |
show() |
protected void |
updateActiveCues(boolean rebuild,
long timeMs) |
abstract void |
updateView(Vector<SubtitleTrack.Cue> activeCues)
Called when the active cues have changed, and the contents of the subtitle
view should be updated.
|
protected final LongSparseArray<android.media.SubtitleTrack.Run> mRunsByEndTime
protected final LongSparseArray<android.media.SubtitleTrack.Run> mRunsByID
protected android.media.SubtitleTrack.CueList mCues
protected final Vector<SubtitleTrack.Cue> mActiveCues
protected boolean mVisible
public boolean DEBUG
protected Handler mHandler
protected MediaTimeProvider mTimeProvider
public SubtitleTrack(MediaFormat format)
public final MediaFormat getFormat()
protected void onData(SubtitleData data)
public abstract void onData(byte[] data, boolean eos, long runID)
data
- subtitle data byte buffereos
- true if this is the last section of the run.runID
- mostly-unique ID for this run of data. Subtitle cues
with runID of 0 are discarded immediately after
display. Cues with runID of ~0 are discarded
only at the deletion of the track object. Cues
with other runID-s are discarded at the end of the
run, which defaults to the latest timestamp of
any of its cues (with this runID).public abstract SubtitleTrack.RenderingWidget getRenderingWidget()
public abstract void updateView(Vector<SubtitleTrack.Cue> activeCues)
protected void updateActiveCues(boolean rebuild, long timeMs)
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
protected void clearActiveCues()
protected void scheduleTimedEvents()
public void onTimedEvent(long timeUs)
MediaTimeProvider.OnMediaTimeListener
onTimedEvent
in interface MediaTimeProvider.OnMediaTimeListener
timeUs
- current media timepublic void onSeek(long timeUs)
MediaTimeProvider.OnMediaTimeListener
onSeek
in interface MediaTimeProvider.OnMediaTimeListener
timeUs
- current media timepublic void onStop()
MediaTimeProvider.OnMediaTimeListener
onStop
in interface MediaTimeProvider.OnMediaTimeListener
public void show()
public void hide()
protected boolean addCue(SubtitleTrack.Cue cue)
public void setTimeProvider(MediaTimeProvider timeProvider)
protected void finishedRun(long runID)
public void setRunDiscardTimeMs(long runID, long timeMs)
public int getTrackType()