Stay organized with collections
Save and categorize content based on your preferences.
public
static
interface
MediaPlayer.OnErrorListener
android.media.MediaPlayer.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
|
onError(MediaPlayer mp, int what, int extra)
Called to indicate an error.
|
Public methods
public abstract boolean onError (MediaPlayer mp,
int what,
int extra)
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.
|
Returns |
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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nMediaPlayer.OnErrorListener\n===========================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/media/MediaPlayer.OnErrorListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nMediaPlayer.OnErrorListener\n`\n\n\n`\n\n\n`\n\n|-------------------------------------------|\n| android.media.MediaPlayer.OnErrorListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface definition of a callback to be invoked when there\nhas been an error during an asynchronous operation (other errors\nwill throw exceptions at method call time).\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[onError](/reference/android/media/MediaPlayer.OnErrorListener#onError(android.media.MediaPlayer,%20int,%20int))`(`[MediaPlayer](/reference/android/media/MediaPlayer)` mp, int what, int extra) ` Called to indicate an error. |\n\nPublic methods\n--------------\n\n### onError\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean onError (MediaPlayer mp, \n int what, \n int extra)\n```\n\nCalled to indicate an error.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mp` | `MediaPlayer`: the MediaPlayer the error pertains to \u003cbr /\u003e |\n| `what` | `int`: the type of error that has occurred: - [MediaPlayer.MEDIA_ERROR_UNKNOWN](/reference/android/media/MediaPlayer#MEDIA_ERROR_UNKNOWN) - [MediaPlayer.MEDIA_ERROR_SERVER_DIED](/reference/android/media/MediaPlayer#MEDIA_ERROR_SERVER_DIED) \u003cbr /\u003e |\n| `extra` | `int`: an extra code, specific to the error. Typically implementation dependent. - [MediaPlayer.MEDIA_ERROR_IO](/reference/android/media/MediaPlayer#MEDIA_ERROR_IO) - [MediaPlayer.MEDIA_ERROR_MALFORMED](/reference/android/media/MediaPlayer#MEDIA_ERROR_MALFORMED) - [MediaPlayer.MEDIA_ERROR_UNSUPPORTED](/reference/android/media/MediaPlayer#MEDIA_ERROR_UNSUPPORTED) - [MediaPlayer.MEDIA_ERROR_TIMED_OUT](/reference/android/media/MediaPlayer#MEDIA_ERROR_TIMED_OUT) - `MEDIA_ERROR_SYSTEM (-2147483648)` - low-level system error. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. \u003cbr /\u003e |"]]