Example usage for android.media MediaPlayer MEDIA_ERROR_SERVER_DIED

List of usage examples for android.media MediaPlayer MEDIA_ERROR_SERVER_DIED

Introduction

In this page you can find the example usage for android.media MediaPlayer MEDIA_ERROR_SERVER_DIED.

Prototype

int MEDIA_ERROR_SERVER_DIED

To view the source code for android.media MediaPlayer MEDIA_ERROR_SERVER_DIED.

Click Source Link

Document

Media server died.

Usage

From source file:com.qweex.callisto.Live.java

/** Initiates the live player. Can be called across activities. */
static public void LIVE_Init() {
    String TAG = StaticBlob.TAG();
    Log.d(TAG, "Initiating the live player.");
    live_player = new MediaPlayer();
    Log.d(TAG, "Initiating the live player.");
    live_player.setAudioStreamType(AudioManager.STREAM_MUSIC);
    Log.d(TAG, "Initiating the live player.");
    live_player.setOnErrorListener(new MediaPlayer.OnErrorListener() {
        public boolean onError(MediaPlayer mp, int what, int extra) {
            if (LIVE_PreparedListener.pd != null)
                LIVE_PreparedListener.pd.hide();
            String whatWhat = "";
            switch (what) {
            case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
                whatWhat = "MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK";
                break;
            case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
                whatWhat = "MEDIA_ERROR_SERVER_DIED";
                break;
            case MediaPlayer.MEDIA_ERROR_UNKNOWN:
                whatWhat = "MEDIA_ERROR_UNKNOWN";
                break;
            default:
                whatWhat = "???";
                return true;
            }/*ww w  .  j a v a  2s.c  o m*/
            try {
                if (StaticBlob.errorDialog != null)
                    StaticBlob.errorDialog.show();
            } catch (Exception e) {
            }

            try {
                SendErrorReport(whatWhat);
            } catch (Exception e) {
            }
            return true;
        }
    });
    Log.d(TAG, "Initiating the live player.");
}

From source file:org.y20k.transistor.PlayerService.java

@Override
public boolean onError(MediaPlayer mp, int what, int extra) {

    switch (what) {
    case MediaPlayer.MEDIA_ERROR_UNKNOWN:
        Log.e(LOG_TAG, "Unknown media playback error");
        break;/* w  w  w  . j av  a2 s  .  c o m*/
    case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
        Log.e(LOG_TAG, "Connection to server lost");
        break;
    default:
        Log.e(LOG_TAG, "Generic audio playback error");
        break;
    }

    switch (extra) {
    case MediaPlayer.MEDIA_ERROR_IO:
        Log.e(LOG_TAG, "IO media error.");
        break;
    case MediaPlayer.MEDIA_ERROR_MALFORMED:
        Log.e(LOG_TAG, "Malformed media.");
        break;
    case MediaPlayer.MEDIA_ERROR_UNSUPPORTED:
        Log.e(LOG_TAG, "Unsupported content type");
        break;
    case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
        Log.e(LOG_TAG, "Media timeout");
        break;
    default:
        Log.e(LOG_TAG, "Other case of media playback error");
        break;
    }

    mp.reset();

    return true;
}

From source file:hkapps.playmxtv.Activities.PlaybackOverlayActivity.java

private void setupCallbacks() {

    mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {

        @Override/* w  w w . j  av  a 2 s .  co m*/
        public boolean onError(MediaPlayer mp, int what, int 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_inaccessible);
            } else {
                msg = getString(R.string.video_error_unknown_error);
            }
            mVideoView.stopPlayback();
            mPlaybackState = LeanbackPlaybackState.IDLE;
            return false;
        }
    });

    mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            if (mPlaybackState == LeanbackPlaybackState.PLAYING) {
                mVideoView.start();
            }
        }
    });

    mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            mPlaybackState = LeanbackPlaybackState.IDLE;
        }
    });

}

From source file:com.reallynourl.nourl.fmpfoldermusicplayer.backend.MediaService.java

@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    mIsPreparedToPlay = false;/*from  w w  w. j ava2  s .  c  om*/
    String message = "undefined media player error";
    switch (what) {
    case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
        message = "The media server died. This is probably not my fault, but playback had to be stopped, feel free to start it again.";
        break;
    case MediaPlayer.MEDIA_ERROR_UNKNOWN:
        switch (extra) {
        case MediaPlayer.MEDIA_ERROR_IO:
            message = "There was an error reading the current media file.";
            break;
        case MediaPlayer.MEDIA_ERROR_MALFORMED:
            message = "The file is probably not a valid audio file.";
            break;
        case MediaPlayer.MEDIA_ERROR_UNSUPPORTED:
            message = "The current file is not supported by your device, I'm really sorry.";
            break;
        case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
            message = "The media player timed out.";
            break;
        case MediaService.MEDIA_ERROR_SYSTEM:
            message = "A low level system error occured. This should have never happened, sorry :/";
            break;
        }
        break;
    }
    releasePlayer();
    Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
    return false;
}

From source file:at.wada811.app.fragment.VideoFragment.java

private void initMediaPlayer() {
    LogUtils.i();//ww  w .j a v a 2s .com
    if (getArguments().keySet().contains(KEY_RES_ID)) {
        mMediaPlayer = MediaPlayer.create(getActivity(), getArguments().getInt(KEY_RES_ID));
    } else {
        mMediaPlayer = new MediaPlayer();
    }
    mMediaPlayer.setOnVideoSizeChangedListener(this);
    mMediaPlayer.setOnBufferingUpdateListener(this);
    mMediaPlayer.setOnPreparedListener(this);
    mMediaPlayer.setOnCompletionListener(this);
    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mMediaPlayer.setOnInfoListener(new OnInfoListener() {
        @Override
        public boolean onInfo(MediaPlayer mp, int what, int extra) {
            switch (what) {
            case MediaPlayer.MEDIA_INFO_BAD_INTERLEAVING:
                LogUtils.i("MediaPlayer.MEDIA_INFO_BAD_INTERLEAVING");
                break;
            case MediaPlayer.MEDIA_INFO_BUFFERING_END:
                LogUtils.i("MediaPlayer.MEDIA_INFO_BUFFERING_END");
                break;
            case MediaPlayer.MEDIA_INFO_BUFFERING_START:
                LogUtils.i("MediaPlayer.MEDIA_INFO_BUFFERING_START");
                break;
            case MediaPlayer.MEDIA_INFO_METADATA_UPDATE:
                LogUtils.i("MediaPlayer.MEDIA_INFO_METADATA_UPDATE");
                break;
            case MediaPlayer.MEDIA_INFO_NOT_SEEKABLE:
                LogUtils.i("MediaPlayer.MEDIA_INFO_NOT_SEEKABLE");
                break;
            case MediaPlayer.MEDIA_INFO_SUBTITLE_TIMED_OUT:
                LogUtils.i("MediaPlayer.MEDIA_INFO_SUBTITLE_TIMED_OUT");
                break;
            case MediaPlayer.MEDIA_INFO_UNSUPPORTED_SUBTITLE:
                LogUtils.i("MediaPlayer.MEDIA_INFO_UNSUPPORTED_SUBTITLE");
                break;
            case MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START:
                LogUtils.i("MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START");
                break;
            case MediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING:
                LogUtils.i("MediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING");
                break;
            case MediaPlayer.MEDIA_INFO_UNKNOWN:
            default:
                LogUtils.i("MediaPlayer.MEDIA_INFO_UNKNOWN");
                break;
            }
            LogUtils.d("extra: " + extra);
            return false;
        }
    });
    mMediaPlayer.setOnErrorListener(new OnErrorListener() {
        @Override
        public boolean onError(MediaPlayer mp, int what, int extra) {
            switch (what) {
            case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
                LogUtils.e("MediaPlayer.MEDIA_ERROR_SERVER_DIED");
                break;
            case MediaPlayer.MEDIA_ERROR_UNKNOWN:
            default:
                LogUtils.e("MediaPlayer.MEDIA_ERROR_UNKNOWN");
                break;
            }
            switch (extra) {
            case MediaPlayer.MEDIA_ERROR_IO:
                LogUtils.e("MediaPlayer.MEDIA_ERROR_IO");
                break;
            case MediaPlayer.MEDIA_ERROR_MALFORMED:
                LogUtils.e("MediaPlayer.MEDIA_ERROR_MALFORMED");
                break;
            case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
                LogUtils.e("MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK");
                break;
            case MediaPlayer.MEDIA_ERROR_TIMED_OUT:
                LogUtils.e("MediaPlayer.MEDIA_ERROR_TIMED_OUT");
                break;
            case MediaPlayer.MEDIA_ERROR_UNSUPPORTED:
                LogUtils.e("MediaPlayer.MEDIA_ERROR_UNSUPPORTED");
                break;
            default:
                LogUtils.e("extra: " + extra);
                break;
            }
            return false;
        }
    });
    mCallback.onActivityCreated(this);
}

From source file:fm.krui.kruifm.StreamService.java

/**
 * All MediaPlayer errors will call this method with details.
 * @param mp MediaPlayer object that threw the error
 * @param what int identifier of error type
 * @param extra int identifier of error code
 * @return true if error was handled by this method, false if not.
 *///from  www.  ja v  a2 s . c  o m
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {

    this.mp = buildAudioPlayer();

    // Log the error
    Log.e(TAG, "*** MediaPlayer has encountered a fatal error.");
    String errorType = "";
    String errorCode = "";
    if (what == MediaPlayer.MEDIA_ERROR_UNKNOWN) {
        errorType = "UNKNOWN ERROR";
    } else if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
        errorType = "SERVER DIED";
    }
    Log.e(TAG, "*** Error Type: " + errorType);

    if (extra == MediaPlayer.MEDIA_ERROR_IO) {
        errorCode = "IO ERROR";
    } else if (extra == MediaPlayer.MEDIA_ERROR_MALFORMED) {
        errorCode = "MALFORMED MEDIA";
    } else if (extra == MediaPlayer.MEDIA_ERROR_UNSUPPORTED) {
        errorCode = "UNSUPPORTED MEDIA";
    } else if (extra == MediaPlayer.MEDIA_ERROR_TIMED_OUT) {
        errorCode = "MEDIA TIMED OUT";
    }
    Log.e(TAG, "*** Error Code: " + errorCode);
    // FIXME: UGLY. Clean this up.
    updateStreamStatus("Error! Type: " + errorType + " / Code: " + errorCode, false);
    isPrepared = false;
    return false;
}

From source file:com.wwtv.player.mediaplayer.LocalPlayerActivity.java

private void setupControlsCallbacks() {
    mVideoView.setOnErrorListener(new OnErrorListener() {

        @Override//from   w w w.ja v a 2s. 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(true);
            }
            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.google.sample.cast.refplayer.mediaplayer.LocalPlayerActivity.java

private void setupControlsCallbacks() {
    mVideoView.setOnErrorListener(new OnErrorListener() {

        @Override//from   w  w w  . ja  v  a  2 s  . co  m
        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(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(true);
            }
            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(Utils.formatMillis(progress));
        }
    });

    mPlayPause.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mLocation == PlaybackLocation.LOCAL) {
                togglePlayback();
            }
        }
    });
}

From source file:com.sourceauditor.sahomemonitor.MainActivity.java

@Override
public boolean onError(MediaPlayer mp, int what, int extra) {

    StringBuilder sb = new StringBuilder();
    sb.append("Error playing Audio stream from home: ");
    switch (what) {
    case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
        sb.append("Not Valid for Progressive Playback");
        break;//from   www  . jav  a2 s  .c  o m
    case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
        sb.append("Server Died");
        break;
    case MediaPlayer.MEDIA_ERROR_UNKNOWN:
        sb.append("Unknown");
        break;
    default:
        sb.append(" Unknow error (");
        sb.append(what);
        sb.append(")");
    }
    sb.append(extra);
    logAndDisplayError(sb.toString());
    return true;
}

From source file:com.hectorosorio.hosocast.mediaplayer.LocalPlayerActivity.java

private void setupControlsCallbacks() {
    mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {

        @Override/*  ww  w .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 MediaPlayer.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 MediaPlayer.OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
            stopTrickplayTimer();
            Log.d(TAG, "setOnCompletionListener()");
            mPlaybackState = PlaybackState.IDLE;
            updatePlayButton(mPlaybackState);
        }
    });

    mVideoView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!mControllersVisible) {
                updateControllersVisibility(true);
            }
            startControllersTimer();
            return false;
        }
    });

    mSeekbar.setOnSeekBarChangeListener(new SeekBar.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 View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mLocation == PlaybackLocation.LOCAL) {
                togglePlayback();
            }
        }
    });
}