Stay organized with collections
Save and categorize content based on your preferences.
OnErrorListener
interface OnErrorListener
Interface definition of a callback to be invoked when there has been an error during an asynchronous operation (other errors will throw exceptions at method call time).
Summary
Public methods |
abstract Boolean |
Called to indicate an error.
|
Public methods
onError
abstract fun onError(
mp: MediaPlayer!,
what: Int,
extra: Int
): Boolean
Called to indicate an error.
Parameters |
mp |
MediaPlayer!: the MediaPlayer the error pertains to |
what |
Int: the type of error that has occurred:
|
extra |
Int: an extra code, specific to the error. Typically implementation dependent.
|
Return |
Boolean |
True if the method handled the error, false if it didn't. Returning false, or not having an OnErrorListener at all, will cause the OnCompletionListener to be called. |
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,["# MediaPlayer.OnErrorListener\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnErrorListener\n===============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/MediaPlayer.OnErrorListener \"View this page in Java\") \n\n```\ninterface OnErrorListener\n```\n\n|------------------------------------------------|\n| [android.media.MediaPlayer.OnErrorListener](#) |\n\nInterface definition of a callback to be invoked when there has been an error during an asynchronous operation (other errors will throw exceptions at method call time).\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onError](#onError(android.media.MediaPlayer,%20kotlin.Int,%20kotlin.Int))`(`mp:` `[MediaPlayer](/reference/kotlin/android/media/MediaPlayer)!`, `what:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `extra:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called to indicate an error. |\n\nPublic methods\n--------------\n\n### onError\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onError(\n mp: MediaPlayer!, \n what: Int, \n extra: Int\n): Boolean\n```\n\nCalled to indicate an error.\n\n| Parameters ||\n|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mp` | [MediaPlayer](/reference/kotlin/android/media/MediaPlayer)!: the MediaPlayer the error pertains to |\n| `what` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the type of error that has occurred: - [MEDIA_ERROR_UNKNOWN](/reference/kotlin/android/media/MediaPlayer#MEDIA_ERROR_UNKNOWN:kotlin.Int) - [MEDIA_ERROR_SERVER_DIED](/reference/kotlin/android/media/MediaPlayer#MEDIA_ERROR_SERVER_DIED:kotlin.Int) |\n| `extra` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): an extra code, specific to the error. Typically implementation dependent. - [MEDIA_ERROR_IO](/reference/kotlin/android/media/MediaPlayer#MEDIA_ERROR_IO:kotlin.Int) - [MEDIA_ERROR_MALFORMED](/reference/kotlin/android/media/MediaPlayer#MEDIA_ERROR_MALFORMED:kotlin.Int) - [MEDIA_ERROR_UNSUPPORTED](/reference/kotlin/android/media/MediaPlayer#MEDIA_ERROR_UNSUPPORTED:kotlin.Int) - [MEDIA_ERROR_TIMED_OUT](/reference/kotlin/android/media/MediaPlayer#MEDIA_ERROR_TIMED_OUT:kotlin.Int) - `MEDIA_ERROR_SYSTEM (-2147483648)` - low-level system error. |\n\n| Return ||\n|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | True if the method handled the error, false if it didn't. Returning false, or not having an OnErrorListener at all, will cause the OnCompletionListener to be called. |"]]