Stay organized with collections
Save and categorize content based on your preferences.
interface OnMediaTimeDiscontinuityListener
Interface definition of a callback to be invoked when discontinuity in the normal progression of the media time is detected. The "normal progression" of media time is defined as the expected increase of the playback position when playing media, relative to the playback speed (for instance every second, media time increases by two seconds when playing at 2x).
Discontinuities are encountered in the following cases:
- when the player is starved for data and cannot play anymore
- when the player encounters a playback error
- when the a seek operation starts, and when it's completed
- when the playback speed changes
- when the playback state changes
- when the player is reset
See the
MediaPlayer.setOnMediaTimeDiscontinuityListener(OnMediaTimeDiscontinuityListener, Handler)
method to set a listener for these events.
Summary
Public methods |
abstract Unit |
Called to indicate a time discontinuity has occured.
|
Public methods
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# MediaPlayer.OnMediaTimeDiscontinuityListener\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnMediaTimeDiscontinuityListener\n================================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/MediaPlayer.OnMediaTimeDiscontinuityListener \"View this page in Java\") \n\n```\ninterface OnMediaTimeDiscontinuityListener\n```\n\n|-----------------------------------------------------------------|\n| [android.media.MediaPlayer.OnMediaTimeDiscontinuityListener](#) |\n\nInterface definition of a callback to be invoked when discontinuity in the normal progression of the media time is detected. The \"normal progression\" of media time is defined as the expected increase of the playback position when playing media, relative to the playback speed (for instance every second, media time increases by two seconds when playing at 2x). \nDiscontinuities are encountered in the following cases:\n\n- when the player is starved for data and cannot play anymore\n- when the player encounters a playback error\n- when the a seek operation starts, and when it's completed\n- when the playback speed changes\n- when the playback state changes\n- when the player is reset\n\nSee the [MediaPlayer.setOnMediaTimeDiscontinuityListener(OnMediaTimeDiscontinuityListener, Handler)](/reference/kotlin/android/media/MediaPlayer#setOnMediaTimeDiscontinuityListener(android.media.MediaPlayer.OnMediaTimeDiscontinuityListener,%20android.os.Handler)) method to set a listener for these events.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onMediaTimeDiscontinuity](#onMediaTimeDiscontinuity(android.media.MediaPlayer,%20android.media.MediaTimestamp))`(`mp:` `[MediaPlayer](/reference/kotlin/android/media/MediaPlayer)`, `mts:` `[MediaTimestamp](/reference/kotlin/android/media/MediaTimestamp)`)` Called to indicate a time discontinuity has occured. |\n\nPublic methods\n--------------\n\n### onMediaTimeDiscontinuity\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onMediaTimeDiscontinuity(\n mp: MediaPlayer, \n mts: MediaTimestamp\n): Unit\n```\n\nCalled to indicate a time discontinuity has occured.\n\n| Parameters ||\n|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mp` | [MediaPlayer](/reference/kotlin/android/media/MediaPlayer): the MediaPlayer for which the discontinuity has occured. This value cannot be `null`. |\n| `mts` | [MediaTimestamp](/reference/kotlin/android/media/MediaTimestamp): the timestamp that correlates media time, system time and clock rate, or [MediaTimestamp.TIMESTAMP_UNKNOWN](/reference/kotlin/android/media/MediaTimestamp#TIMESTAMP_UNKNOWN:android.media.MediaTimestamp) in an error case. This value cannot be `null`. |"]]