Example usage for android.media MediaPlayer MEDIA_INFO_BUFFERING_START

List of usage examples for android.media MediaPlayer MEDIA_INFO_BUFFERING_START

Introduction

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

Prototype

int MEDIA_INFO_BUFFERING_START

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

Click Source Link

Document

MediaPlayer is temporarily pausing playback internally in order to buffer more data.

Usage

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

private void initMediaPlayer() {
    LogUtils.i();/*from ww  w .j  av a  2  s.c  o  m*/
    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:org.y20k.transistor.PlayerService.java

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

    switch (what) {
    case MediaPlayer.MEDIA_INFO_UNKNOWN:
        Log.i(LOG_TAG, "Unknown media info");
        break;/*from ww  w  .  j  a v a  2 s.com*/
    case MediaPlayer.MEDIA_INFO_BUFFERING_START:
        Log.i(LOG_TAG, "Buffering started");
        break;
    case MediaPlayer.MEDIA_INFO_BUFFERING_END:
        Log.i(LOG_TAG, "Buffering finished");
        break;
    case MediaPlayer.MEDIA_INFO_METADATA_UPDATE:
        Log.i(LOG_TAG, "New metadata available");
        break;
    default:
        Log.i(LOG_TAG, "other case of media info");
        break;
    }

    return true;
}

From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java

public boolean onInfo(MediaPlayer mediaPlayer, int what, int extra) {
    if (LOCAL_LOGV)
        log("onInfo()", "v");
    if (what == MediaPlayer.MEDIA_INFO_BUFFERING_END) {
        if (LOCAL_LOGV)
            log("done buffering", "v");

        updateNotification(getResources().getString(R.string.status_playing),
                getResources().getString(R.string.stop), true);
        mCurrentPlayerState = ServiceRadioPlayer.STATE_PLAYING;
        return true;

    } else if (what == MediaPlayer.MEDIA_INFO_BUFFERING_START) {

        if (LOCAL_LOGV)
            log("start buffering", "v");
        //Log.i(getPackageName(), "start buffering");
        //status.setText("Buffering...");

        updateNotification(getResources().getString(R.string.status_buffering),
                getResources().getString(R.string.cancel), true);

        mCurrentPlayerState = ServiceRadioPlayer.STATE_BUFFERING;
        return true;
    } else if (what == 703) {
        if (LOCAL_LOGV)
            log("bandwidth:" + extra, "v");

        //Log.i(getPackageName(), str);
    } else {//w  w  w  .j  ava  2  s.  co  m
        if (LOCAL_LOGV)
            log("media player info", "v");
        //Log.i(getPackageName(), "media player info");
    }
    /*String statusString = "\nInfo: ";
    statusString += what;
    statusString += ":";
    statusString += extra;
    status.append(statusString);*/
    return false;
}