List of usage examples for android.media MediaPlayer MEDIA_ERROR_TIMED_OUT
int MEDIA_ERROR_TIMED_OUT
To view the source code for android.media MediaPlayer MEDIA_ERROR_TIMED_OUT.
Click Source Link
From source file:com.repkap11.repcast.activities.LocalPlayerActivity.java
private void setupControlsCallbacks() { mVideoView.setOnErrorListener(new OnErrorListener() { @Override// w ww . j a v a 2 s.c om public boolean onError(MediaPlayer mp, int what, int extra) { Log.e(TAG, "OnErrorListener.onError(): VideoView encountered an " + "error, what: " + what + ", extra: " + extra); String msg; if (extra == MediaPlayer.MEDIA_ERROR_TIMED_OUT) { msg = getString(R.string.video_error_media_load_timeout); } else if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) { msg = getString(R.string.video_error_server_unaccessible); } else { msg = getString(R.string.video_error_unknown_error); } Utils.showErrorDialog(LocalPlayerActivity.this, msg); mVideoView.stopPlayback(); mPlaybackState = PlaybackState.IDLE; updatePlayButton(mPlaybackState); return true; } }); mVideoView.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { Log.d(TAG, "onPrepared is reached"); mDuration = mp.getDuration(); mEndText.setText( com.google.android.libraries.cast.companionlibrary.utils.Utils.formatMillis(mDuration)); mSeekbar.setMax(mDuration); restartTrickplayTimer(); } }); mVideoView.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { stopTrickplayTimer(); Log.d(TAG, "setOnCompletionListener()"); mPlaybackState = PlaybackState.IDLE; updatePlayButton(mPlaybackState); } }); mVideoView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (!mControllersVisible) { updateControllersVisibility(!mControllersVisible); } startControllersTimer(); return false; } }); mSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { if (mPlaybackState == PlaybackState.PLAYING) { play(seekBar.getProgress()); } else if (mPlaybackState != PlaybackState.IDLE) { mVideoView.seekTo(seekBar.getProgress()); } startControllersTimer(); } @Override public void onStartTrackingTouch(SeekBar seekBar) { stopTrickplayTimer(); mVideoView.pause(); stopControllersTimer(); } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mStartText.setText( com.google.android.libraries.cast.companionlibrary.utils.Utils.formatMillis(progress)); } }); mPlayPause.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mLocation == PlaybackLocation.LOCAL) { togglePlayback(); } } }); }
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;/*from www . jav a2 s. c o 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; }