android 外掛字幕介面

haima1998發表於2015-02-26

參考:

http://developer.android.com/reference/android/media/MediaPlayer.html


1.呼叫mediaplayer類中的addTimedTextSource (String path, String mimeType)方法,
 設定需要顯示的外掛字幕檔案路徑。

2. 通過回撥通知上層應用繪製字幕,如果獲取到的getText()為空,則表示需要清除當前顯示的字幕。

void addTimedTextSource(String path, String mimeType)
Adds an external timed text source file.
void setOnTimedTextListener(MediaPlayer.OnTimedTextListener listener)
Register a callback to be invoked when a timed text is available for display.
Public Methods
abstract void onTimedText(MediaPlayer mp, TimedText text)
Called to indicate an avaliable timed text
Public Methods
Rect getBounds()
Get the rectangle area or region for rendering the timed text as specified by a Rect object.
String getText()
Get the characters in the timed text.

public Rect getBounds ()

Added in API level 16

Get the rectangle area or region for rendering the timed text as specified by a Rect object.

Returns
  • the rectangle region to render the characters in the timed text. If no bounds information is available (a null is returned), render the timed text at the center bottom of the display.

public String getText ()

Added in API level 16

Get the characters in the timed text.

Returns
  • the characters as a String object in the TimedText. Applications should stop rendering previous timed text at the current rendering region if a null is returned, until the next non-null timed text is received.





相關文章