Stay organized with collections
Save and categorize content based on your preferences.
TimedText
class TimedText
Class to hold the timed text's metadata, including:
- The characters for rendering
- The rendering position for the timed text
To render the timed text, applications need to do the following:
Summary
Public methods |
Rect! |
Get the rectangle area or region for rendering the timed text as specified by a Rect object.
|
String! |
Get the characters in the timed text.
|
Public methods
getBounds
fun getBounds(): Rect!
Get the rectangle area or region for rendering the timed text as specified by a Rect object.
Return |
Rect! |
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. |
getText
fun getText(): String!
Get the characters in the timed text.
Return |
String! |
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. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# TimedText\n\nAdded in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nTimedText\n=========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/TimedText \"View this page in Java\") \n\n```\nclass TimedText\n```\n\n|---|------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.media.TimedText](#) |\n\nClass to hold the timed text's metadata, including:\n\n- The characters for rendering\n- The rendering position for the timed text\n\n\u003cbr /\u003e\n\nTo render the timed text, applications need to do the following:\n\n- Implement the [MediaPlayer.OnTimedTextListener](/reference/kotlin/android/media/MediaPlayer.OnTimedTextListener) interface\n- Register the [MediaPlayer.OnTimedTextListener](/reference/kotlin/android/media/MediaPlayer.OnTimedTextListener) callback on a MediaPlayer object that is used for playback\n- When a onTimedText callback is received, do the following:\n - call [getText](#getText()) to get the characters for rendering\n - call [getBounds](#getBounds()) to get the text rendering area/region\n\nSummary\n-------\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|\n| [Rect](../graphics/Rect.html#)! | [getBounds](#getBounds())`()` Get the rectangle area or region for rendering the timed text as specified by a Rect object. |\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getText](#getText())`()` Get the characters in the timed text. |\n\nPublic methods\n--------------\n\n### getBounds\n\nAdded in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getBounds(): Rect!\n```\n\nGet the rectangle area or region for rendering the timed text as specified by a Rect object.\n\n| Return ||\n|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Rect](../graphics/Rect.html#)! | 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. |\n\n### getText\n\nAdded in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getText(): String!\n```\n\nGet the characters in the timed text.\n\n| Return ||\n|-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | 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. |"]]