Java Code Examples for android.media.MediaPlayer#MEDIA_ERROR_UNKNOWN

The following examples show how to use android.media.MediaPlayer#MEDIA_ERROR_UNKNOWN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoPlayerActivity.java    From Simpler with Apache License 2.0 7 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    AppToast.showToast("播放失败");
    Log.d(TAG, "播放失败, " + what + ", " + extra);
    switch (what) {
        case MediaPlayer.MEDIA_ERROR_IO:
            Log.d(TAG, "MEDIA_ERROR_IO");
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            Log.d(TAG, "MEDIA_ERROR_SERVER_DIED");
            break;
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            Log.d(TAG, "MEDIA_ERROR_UNKNOWN");
            break;
        case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
            Log.d(TAG, "MEDIA_ERROR_TIMED_OUT");
            break;
        default:
            break;
    }
    return true;
}
 
Example 2
Source File: Signal.java    From react-native-audio-streaming with MIT License 7 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    switch (what) {
        case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
            //Log.v("ERROR", "MEDIA ERROR NOT VALID FOR PROGRESSIVE PLAYBACK "	+ extra);
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            //Log.v("ERROR", "MEDIA ERROR SERVER DIED " + extra);
            break;
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            //Log.v("ERROR", "MEDIA ERROR UNKNOWN " + extra);
            break;
    }
    sendBroadcast(new Intent(Mode.ERROR));
    return false;
}
 
Example 3
Source File: ParsingPlayerProxy.java    From ParsingPlayer with GNU Lesser General Public License v2.1 6 votes vote down vote up
private String errToStr(int framework_err, int impl_err) {
    String msg = null;
    if (framework_err == MediaPlayer.MEDIA_ERROR_IO) {
        msg = "IO Error";
    } else if (framework_err == MediaPlayer.MEDIA_ERROR_MALFORMED) {
        msg = "Bitstream unsupported";
    } else if (framework_err == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) {
        msg = "Invalid progressive playback";
    } else if (framework_err == MediaPlayer.MEDIA_ERROR_TIMED_OUT) {
        msg = "Operation time out";
    } else if (framework_err == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
        msg = "MediaPlayer died";
    } else if (framework_err == MediaPlayer.MEDIA_ERROR_UNSUPPORTED) {
        msg = "File spec is not supported in the media framework";
    } else if (framework_err == MediaPlayer.MEDIA_ERROR_UNKNOWN) {
        msg = "Unknown error";
    }
    return msg;
}
 
Example 4
Source File: Signal.java    From react-native-android-audio-streaming-aac with MIT License 6 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
	switch (what) {
	case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
		//Log.v("ERROR", "MEDIA ERROR NOT VALID FOR PROGRESSIVE PLAYBACK "	+ extra);
		break;
	case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
		//Log.v("ERROR", "MEDIA ERROR SERVER DIED " + extra);
		break;
	case MediaPlayer.MEDIA_ERROR_UNKNOWN:
		//Log.v("ERROR", "MEDIA ERROR UNKNOWN " + extra);
		break;
	}
   sendBroadcast(new Intent(Mode.ERROR));
	return false;
}
 
Example 5
Source File: AudioService.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    MediaErrorEvent evt = fireMediaError(AndroidImplementation.createMediaException(extra));
    fireMediaStateChange(State.Playing);
    fireMediaStateChange(State.Paused);
    if (!evt.isConsumed()) {
        switch (what) {
            case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
                Toast.makeText(AudioService.this,
                        "MEDIA ERROR NOT VALID FOR PROGRESSIVE PLAYBACK " + extra,
                        Toast.LENGTH_SHORT).show();
                break;
            case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
                Toast.makeText(AudioService.this, "MEDIA ERROR SERVER DIED " + extra,
                        Toast.LENGTH_SHORT).show();
                break;
            case MediaPlayer.MEDIA_ERROR_UNKNOWN:
                Toast.makeText(AudioService.this, "MEDIA ERROR UNKNOWN " + extra,
                        Toast.LENGTH_SHORT).show();
                break;
        }
    }
    return false;
}
 
Example 6
Source File: SimpleAudioStream.java    From cordova-plugin-streaming-media with MIT License 6 votes vote down vote up
public boolean onError(MediaPlayer mp, int what, int extra) {
	StringBuilder sb = new StringBuilder();
	sb.append("Media Player Error: ");
	switch (what) {
		case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
		sb.append("Not Valid for Progressive Playback");
		break;
		case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
		sb.append("Server Died");
		break;
		case MediaPlayer.MEDIA_ERROR_UNKNOWN:
		sb.append("Unknown");
		break;
		default:
		sb.append(" Non standard (");
		sb.append(what);
		sb.append(")");
	}
	sb.append(" (" + what + ") ");
	sb.append(extra);
	Log.e(TAG, sb.toString());
	wrapItUp(RESULT_CANCELED, sb.toString());
	return true;
}
 
Example 7
Source File: SimpleVideoStream.java    From cordova-plugin-streaming-media with MIT License 6 votes vote down vote up
public boolean onError(MediaPlayer mp, int what, int extra) {
	StringBuilder sb = new StringBuilder();
	sb.append("MediaPlayer Error: ");
	switch (what) {
		case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
		sb.append("Not Valid for Progressive Playback");
		break;
		case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
		sb.append("Server Died");
		break;
		case MediaPlayer.MEDIA_ERROR_UNKNOWN:
		sb.append("Unknown");
		break;
		default:
		sb.append(" Non standard (");
		sb.append(what);
		sb.append(")");
	}
	sb.append(" (" + what + ") ");
	sb.append(extra);
	Log.e(TAG, sb.toString());

	wrapItUp(RESULT_CANCELED, sb.toString());
	return true;
}
 
Example 8
Source File: SysMediaPlayer.java    From PlayerBase with Apache License 2.0 5 votes vote down vote up
public boolean onError(MediaPlayer mp, int framework_err, int impl_err) {
    PLog.d(TAG, "Error: " + framework_err + "," + impl_err);
    updateStatus(STATE_ERROR);
    mTargetState = STATE_ERROR;

    int eventCode = OnErrorEventListener.ERROR_EVENT_COMMON;

    switch (framework_err){
        case MediaPlayer.MEDIA_ERROR_IO:
            eventCode = OnErrorEventListener.ERROR_EVENT_IO;
            break;
        case MediaPlayer.MEDIA_ERROR_MALFORMED:
            eventCode = OnErrorEventListener.ERROR_EVENT_MALFORMED;
            break;
        case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
            eventCode = OnErrorEventListener.ERROR_EVENT_TIMED_OUT;
            break;
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            eventCode = OnErrorEventListener.ERROR_EVENT_UNKNOWN;
            break;
        case MediaPlayer.MEDIA_ERROR_UNSUPPORTED:
            eventCode = OnErrorEventListener.ERROR_EVENT_UNSUPPORTED;
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            eventCode = OnErrorEventListener.ERROR_EVENT_SERVER_DIED;
            break;
        case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
            eventCode = OnErrorEventListener.ERROR_EVENT_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK;
            break;
    }

    /* If an error handler has been supplied, use it and finish. */
    Bundle bundle = BundlePool.obtain();
    submitErrorEvent(eventCode,bundle);
    return true;
}
 
Example 9
Source File: SystemImplMediaPlayer.java    From android-jungle-mediaplayer with Apache License 2.0 5 votes vote down vote up
public boolean onError(MediaPlayer player, int what, int extra) {
    String errorWhat;
    switch (what) {
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            errorWhat = "MEDIA_ERROR_UNKNOWN";
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            errorWhat = "MEDIA_ERROR_SERVER_DIED";
            break;
        default:
            errorWhat = "!";
    }

    String errorExtra;
    switch (extra) {
        case MediaPlayer.MEDIA_ERROR_UNSUPPORTED:
            errorExtra = "MEDIA_ERROR_UNSUPPORTED";
            break;
        case MediaPlayer.MEDIA_ERROR_MALFORMED:
            errorExtra = "MEDIA_ERROR_MALFORMED";
            break;
        case MediaPlayer.MEDIA_ERROR_IO:
            errorExtra = "MEDIA_ERROR_IO";
            break;
        case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
            errorExtra = "MEDIA_ERROR_TIMED_OUT";
            break;
        default:
            errorExtra = "!";
    }

    String msg = String.format("what = %d (%s), extra = %d (%s)",
            what, errorWhat, extra, errorExtra);

    Log.e(TAG, msg);
    notifyError(what, msg);
    return true;
}
 
Example 10
Source File: MediaPlayerListener.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    int errorType;
    switch (what) {
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            switch (extra) {
                case MEDIA_ERROR_MALFORMED:
                    errorType = MEDIA_ERROR_DECODE;
                    break;
                case MEDIA_ERROR_TIMED_OUT:
                    errorType = MEDIA_ERROR_INVALID_CODE;
                    break;
                default:
                    errorType = MEDIA_ERROR_FORMAT;
                    break;
            }
            break;
        case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
            errorType = MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK;
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            errorType = MEDIA_ERROR_SERVER_DIED;
            break;
        default:
            // There are some undocumented error codes for android media player.
            // For example, when surfaceTexture got deleted before we setVideoSuface
            // to NULL, mediaplayer will report error -38. These errors should be ignored
            // and not be treated as an error to webkit.
            errorType = MEDIA_ERROR_INVALID_CODE;
            break;
    }
    nativeOnMediaError(mNativeMediaPlayerListener, errorType);
    return true;
}
 
Example 11
Source File: GPlayer.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int whatError, int extra) {
    Log.d(LOGTAG, "onError Called" + whatError + "  " + extra);
    if (whatError == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
        Log.v(LOGTAG, "Media Error, Server Died " + extra);
    } else if (whatError == MediaPlayer.MEDIA_ERROR_UNKNOWN) {
        Log.v(LOGTAG, "Media Error, Error Unknown " + extra);
    }

    return false;
}
 
Example 12
Source File: StreamService.java    From example with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onError(MediaPlayer mediaPlayer, int what, int extra) {
    switch (what) {
        case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
            Toast.makeText(this, "Error not valid playback", Toast.LENGTH_SHORT).show();
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            Toast.makeText(this, "Error server died", Toast.LENGTH_SHORT).show();
            break;
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            Toast.makeText(this, "Error unknown", Toast.LENGTH_SHORT).show();
            break;
    }
    return false;
}
 
Example 13
Source File: MediaPlayerListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    int errorType;
    switch (what) {
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            switch (extra) {
                case MEDIA_ERROR_MALFORMED:
                    errorType = MEDIA_ERROR_DECODE;
                    break;
                case MEDIA_ERROR_TIMED_OUT:
                    errorType = MEDIA_ERROR_INVALID_CODE;
                    break;
                default:
                    errorType = MEDIA_ERROR_FORMAT;
                    break;
            }
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            errorType = MEDIA_ERROR_DECODE;
            break;
        case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
            errorType = MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK;
            break;
        default:
            // There are some undocumented error codes for android media player.
            // For example, when surfaceTexture got deleted before we setVideoSuface
            // to NULL, mediaplayer will report error -38. These errors should be ignored
            // and not be treated as an error to webkit.
            errorType = MEDIA_ERROR_INVALID_CODE;
            break;
    }
    nativeOnMediaError(mNativeMediaPlayerListener, errorType);
    return true;
}
 
Example 14
Source File: MediaPlayerListener.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    int errorType;
    switch (what) {
        case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            switch (extra) {
                case MEDIA_ERROR_MALFORMED:
                    errorType = MEDIA_ERROR_DECODE;
                    break;
                case MEDIA_ERROR_TIMED_OUT:
                    errorType = MEDIA_ERROR_INVALID_CODE;
                    break;
                default:
                    errorType = MEDIA_ERROR_FORMAT;
                    break;
            }
            break;
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            errorType = MEDIA_ERROR_DECODE;
            break;
        case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
            errorType = MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK;
            break;
        default:
            // There are some undocumented error codes for android media player.
            // For example, when surfaceTexture got deleted before we setVideoSuface
            // to NULL, mediaplayer will report error -38. These errors should be ignored
            // and not be treated as an error to webkit.
            errorType = MEDIA_ERROR_INVALID_CODE;
            break;
    }
    nativeOnMediaError(mNativeMediaPlayerListener, errorType);
    return true;
}