参考:

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.


android 外挂字幕接口_第1张图片


android 外挂字幕接口_第2张图片


更多相关文章

  1. Android中callback(接口回调)机制
  2. Android调用相机接口
  3. android aidl接口初步了解
  4. android访问I2C接口
  5. Android中回调接口使用实例
  6. Android Studio酷炫插件(一)——自动化快速实现Parcelable接口序列

随机推荐

  1. scaleType分析
  2. Android(安卓)图片缩放(二)ZoomControls放
  3. Android(安卓)- PopupWindow
  4. android isDirectory()及listFiles()
  5. 2013.4.8
  6. Android(安卓)SurfaceFlinger中的工作线
  7. 没事别更新 Android(安卓)SDK 和 ADT
  8. Android中cannot be resolved or is not
  9. [置顶] android fragment hidenChanged方
  10. Android类参考---Fragment(四)