List of usage examples for android.media MediaPlayer MEDIA_ERROR_UNKNOWN
int MEDIA_ERROR_UNKNOWN
To view the source code for android.media MediaPlayer MEDIA_ERROR_UNKNOWN.
Click Source Link
From source file:leoisasmendi.android.com.suricatepodcast.services.MediaPlayerService.java
@Override public boolean onError(MediaPlayer mp, int what, int extra) { //Invoked when there has been an error during an asynchronous operation Log.d(TAG, "onError: " + R.string.media_player_error_2); switch (what) { case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK: Log.d("MediaPlayer Error", "MEDIA ERROR NOT VALID FOR PROGRESSIVE PLAYBACK " + extra); break;/*from w w w. ja v a 2 s . c o m*/ case MediaPlayer.MEDIA_ERROR_SERVER_DIED: Log.d("MediaPlayer Error", "MEDIA ERROR SERVER DIED " + extra); break; case MediaPlayer.MEDIA_ERROR_UNKNOWN: Log.d("MediaPlayer Error", "MEDIA ERROR UNKNOWN " + extra); break; } return false; }
From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java
public boolean onError(MediaPlayer mediaPlayer, int what, int extra) { if (LOCAL_LOGV) log("onError()", "e"); //check if mediaPlayer is or needs to be released if (mediaPlayer != null) { stopAndReleasePlayer(mediaPlayer); mediaPlayer = null;// w ww. ja va 2 s.co m mMediaPlayer = null; } String oldState = mCurrentPlayerState; mCurrentPlayerState = ServiceRadioPlayer.STATE_ERROR; //set 'now playing' to error stopInfo(getResources().getString(R.string.status_error)); String title; String text; boolean unknown = false; if (what == MediaPlayer.MEDIA_ERROR_UNKNOWN && extra == -2147483648) { title = getResources().getString(R.string.error_title); text = getResources().getString(R.string.error_url_format); } else if (extra == MediaPlayer.MEDIA_ERROR_IO) { title = getResources().getString(R.string.error_title); text = getResources().getString(R.string.error_media_io); } else if (extra == MediaPlayer.MEDIA_ERROR_TIMED_OUT) { title = getResources().getString(R.string.error_title); text = getResources().getString(R.string.error_timed_out); } else //unknown/unhandled error { title = getResources().getString(R.string.error_title); text = getResources().getString(R.string.error_unknown); this.getErrorNotification(title, text); unknown = true; } //show user error notification this.getErrorNotification(title, text); if (unknown) { text += ", " + String.valueOf(what) + ":" + String.valueOf(extra); } if (LOCAL_LOGD) log("Previous:" + oldState, "e"); log(text, "e"); return false; }
From source file:androidx.media.widget.VideoView2.java
private void openVideo(Uri uri, Map<String, String> headers) { resetPlayer();/* w w w .j av a 2s. com*/ if (isRemotePlayback()) { // TODO (b/77158231) // mRoutePlayer.openVideo(dsd); return; } try { Log.d(TAG, "openVideo(): creating new MediaPlayer instance."); mMediaPlayer = new MediaPlayer(); mSurfaceView.setMediaPlayer(mMediaPlayer); mTextureView.setMediaPlayer(mMediaPlayer); mCurrentView.assignSurfaceToMediaPlayer(mMediaPlayer); final Context context = getContext(); // TODO: Add timely firing logic for more accurate sync between CC and video frame // mSubtitleController = new SubtitleController(context); // mSubtitleController.registerRenderer(new ClosedCaptionRenderer(context)); // mSubtitleController.setAnchor((SubtitleController.Anchor) mSubtitleView); mMediaPlayer.setOnPreparedListener(mPreparedListener); mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener); mMediaPlayer.setOnCompletionListener(mCompletionListener); mMediaPlayer.setOnSeekCompleteListener(mSeekCompleteListener); mMediaPlayer.setOnErrorListener(mErrorListener); mMediaPlayer.setOnInfoListener(mInfoListener); mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); mCurrentBufferPercentage = -1; mMediaPlayer.setDataSource(getContext(), uri, headers); mMediaPlayer.setAudioAttributes(mAudioAttributes); // mMediaPlayer.setOnSubtitleDataListener(mSubtitleListener); // we don't set the target state here either, but preserve the // target state that was there before. mCurrentState = STATE_PREPARING; mMediaPlayer.prepareAsync(); // Save file name as title since the file may not have a title Metadata. mTitle = uri.getPath(); String scheme = uri.getScheme(); if (scheme != null && scheme.equals("file")) { mTitle = uri.getLastPathSegment(); } mRetriever = new MediaMetadataRetriever(); mRetriever.setDataSource(getContext(), uri); if (DEBUG) { Log.d(TAG, "openVideo(). mCurrentState=" + mCurrentState + ", mTargetState=" + mTargetState); } } catch (IOException | IllegalArgumentException ex) { Log.w(TAG, "Unable to open content: " + uri, ex); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, MediaPlayer.MEDIA_ERROR_IO); } }