Java Code Examples for android.media.MediaPlayer#MEDIA_ERROR_SERVER_DIED

The following examples show how to use android.media.MediaPlayer#MEDIA_ERROR_SERVER_DIED . 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: 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 2
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 3
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 4
Source File: BeepManager.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
  if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
    // we are finished, so put up an appropriate error toast if required and finish
    activity.finish();
  } else {
    // possibly media player error, so release and recreate
    close();
    updatePrefs();
  }
  return true;
}
 
Example 5
Source File: BeepManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
  if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
    // we are finished, so put up an appropriate error toast if required and finish
    activity.finish();
  } else {
    // possibly media player error, so release and recreate
    close();
    updatePrefs();
  }
  return true;
}
 
Example 6
Source File: BeepManager.java    From BarcodeEye with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
    if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
        // we are finished, so put up an appropriate error toast if required and finish
        activity.finish();
    } else {
        // possibly media player error, so release and recreate
        mp.release();
        mediaPlayer = null;
        updatePrefs();
    }
    return true;
}
 
Example 7
Source File: MediaPlayerError.java    From AntennaPodSP with MIT License 5 votes vote down vote up
/**
 * Get a human-readable string for a specific error code.
 */
public static String getErrorString(Context context, int code) {
    int resId;
    switch (code) {
        case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
            resId = R.string.playback_error_server_died;
            break;
        default:
            resId = R.string.playback_error_unknown;
            break;
    }
    return context.getString(resId);
}
 
Example 8
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 9
Source File: BeepManager.java    From ZXing-Orient with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
  if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
    // we are finished, so put up an appropriate error toast if required and finish
    activity.finish();
  } else {
    // possibly media player error, so release and recreate
    mp.release();
    mediaPlayer = null;
    updatePrefs(false, true);
  }
  return true;
}
 
Example 10
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 11
Source File: BeepManager.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
  if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
    // we are finished, so put up an appropriate error toast if required and finish
    activity.finish();
  } else {
    // possibly media player error, so release and recreate
    mp.release();
    mediaPlayer = null;
    updatePrefs();
  }
  return true;
}
 
Example 12
Source File: BeepManager.java    From moVirt with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
    if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
        // we are finished, so put up an appropriate error toast if required and finish
        activity.finish();
    } else {
        // possibly media player error, so release and recreate
        mp.release();
        mediaPlayer = null;
        updatePrefs();
    }
    return true;
}
 
Example 13
Source File: BeepManager.java    From BarcodeScanner with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
	if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
		// we are finished, so put up an appropriate error toast if required
		// and finish
		activity.finish();
	}
	else {
		// possibly media player error, so release and recreate
		mp.release();
		mediaPlayer = null;
		updatePrefs();
	}
	return true;
}
 
Example 14
Source File: BeepManager.java    From YZxing with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
    if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
        // we are finished, so put up an appropriate error toast if required and finish
        activity.finish();
    } else {
        // possibly media player error, so release and recreate
        close();
        updatePrefs();
    }
    return true;
}
 
Example 15
Source File: BeepManager.java    From Android with MIT License 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
	if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
		// we are finished, so put up an appropriate error toast if required
		// and finish
		activity.finish();
	} else {
		// possibly media player error, so release and recreate
		mp.release();
		mediaPlayer = null;
		updatePrefs();
	}
	return true;
}
 
Example 16
Source File: BeepManager.java    From ZXingProject with MIT License 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
	if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
		// we are finished, so put up an appropriate error toast if required
		// and finish
		activity.finish();
	} else {
		// possibly media player error, so release and recreate
		mp.release();
		mediaPlayer = null;
		updatePrefs();
	}
	return true;
}
 
Example 17
Source File: BeepManager.java    From ScanZxing with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
	if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
		// we are finished, so put up an appropriate error toast if required
		// and finish
		activity.finish();
	} else {
		// possibly media player error, so release and recreate
		mp.release();
		mediaPlayer = null;
		updatePrefs();
	}
	return true;
}
 
Example 18
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 19
Source File: BeepManager.java    From qrcode_android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
    if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
        // we are finished, so put up an appropriate error toast if required
        // and finish
        activity.finish();
    } else {
        // possibly media player error, so release and recreate
        mp.release();
        mediaPlayer = null;
        updatePrefs();
    }
    return true;
}
 
Example 20
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;
}