Example usage for android.media MediaPlayer MEDIA_ERROR_UNKNOWN

List of usage examples for android.media MediaPlayer MEDIA_ERROR_UNKNOWN

Introduction

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

Prototype

int MEDIA_ERROR_UNKNOWN

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

Click Source Link

Document

Unspecified media player error.

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;
            }//  w  ww . jav  a2 s .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;/*from   ww w .  j av  a2 s.  co  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:com.reallynourl.nourl.fmpfoldermusicplayer.backend.MediaService.java

@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
    mIsPreparedToPlay = false;//from   www.  j av  a 2  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();//from w  w w  . j  av a 2 s.  co 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:CookieVideoView.java

private void openVideo() {
    if (mUri == null || mSurfaceHolder == null) {
        // not ready for playback just yet, will try again later
        return;/*w  w w  .j  a v  a2  s  .  co m*/
    }
    // Tell the music playback service to pause
    // TODO: these constants need to be published somewhere in the framework.
    Intent i = new Intent("com.android.music.musicservicecommand");
    i.putExtra("command", "pause");
    mContext.sendBroadcast(i);

    // we shouldn't clear the target state, because somebody might have
    // called start() previously
    release(false);
    try {
        mMediaPlayer = new MediaPlayer();
        mMediaPlayer.setOnPreparedListener(mPreparedListener);
        mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
        mMediaPlayer.setOnCompletionListener(mCompletionListener);
        mMediaPlayer.setOnErrorListener(mErrorListener);
        mMediaPlayer.setOnInfoListener(mOnInfoListener);
        mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
        mCurrentBufferPercentage = 0;
        mMediaPlayer.setDataSource(mContext, mUri, mHeaders);
        mMediaPlayer.setDisplay(mSurfaceHolder);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.setScreenOnWhilePlaying(true);
        mMediaPlayer.prepareAsync();
        // we don't set the target state here either, but preserve the
        // target state that was there before.
        mCurrentState = STATE_PREPARING;
        attachMediaController();
    } catch (IOException ex) {
        Log.w(TAG, "Unable to open content: " + mUri, ex);
        mCurrentState = STATE_ERROR;
        mTargetState = STATE_ERROR;
        mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
        return;
    } catch (IllegalArgumentException ex) {
        Log.w(TAG, "Unable to open content: " + mUri, ex);
        mCurrentState = STATE_ERROR;
        mTargetState = STATE_ERROR;
        mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
        return;
    }
}

From source file:com.android.onemedia.playback.LocalRenderer.java

@Override
public boolean onError(MediaPlayer player, int what, int extra) {
    if (!isCurrentPlayer(player)) {
        return false;
    }/*from w  w  w. j a  va  2  s.  c  o m*/
    if (DEBUG) {
        Log.d(TAG, mDebugId + ": Entered error state, what: " + what + " extra: " + extra);
    }
    synchronized (mErrorLock) {
        ++mErrorId;
        mError = new PlaybackError();
        mError.type = what;
        mError.extra = extra;
    }

    if (what == MediaPlayer.MEDIA_ERROR_UNKNOWN && extra == MediaPlayer.MEDIA_ERROR_IO && mContent != null
            && mContent.source.startsWith("http")) {
        HttpGet request = new HttpGet(mContent.source);
        if (mContent.headers != null) {
            for (String key : mContent.headers.keySet()) {
                request.addHeader(key, mContent.headers.get(key));
            }
        }
        synchronized (mErrorLock) {
            if (mErrorRetriever != null) {
                mErrorRetriever.cancelRequestLocked(false);
            }
            mErrorRetriever = new AsyncErrorRetriever(mErrorId);
            mErrorRetriever.execute(request);
        }
    } else {
        setError(what, extra, null, null);
    }
    return true;
}

From source file:com.xnxs.mediaplayer.widget.media.VRVideoView.java

@TargetApi(Build.VERSION_CODES.M)
private void openVideo() {
    if ((mUri == null && mIMediaDataSource == null) || mSurfaceHolder == null) {
        // not ready for playback just yet, will try again later
        return;/*  w w  w  .  j a v  a  2s  . c o m*/
    }
    // we shouldn't clear the target state, because somebody might have
    // called start() previously
    release(false);

    AudioManager am = getAudioManager();
    am.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);

    try {
        mMediaPlayer = createPlayer(Settings.PV_PLAYER__IjkMediaPlayer);
        // TODO: create SubtitleController in MediaPlayer, but we need
        // a context for the subtitle renderers
        final Context context = getContext();
        // REMOVED: SubtitleController

        // REMOVED: mAudioSession
        mMediaPlayer.setOnPreparedListener(mPreparedListener);
        mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
        mMediaPlayer.setOnCompletionListener(mCompletionListener);
        mMediaPlayer.setOnErrorListener(mErrorListener);
        mMediaPlayer.setOnInfoListener(mInfoListener);
        mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
        mCurrentBufferPercentage = 0;

        if (mUri != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                mMediaPlayer.setDataSource(mAppContext, mUri, mHeaders);
            } else {
                mMediaPlayer.setDataSource(mUri.toString());
            }
        } else {
            mMediaPlayer.setDataSource(mIMediaDataSource);
        }
        bindSurfaceHolder(mMediaPlayer, mSurfaceHolder);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.setScreenOnWhilePlaying(true);
        mMediaPlayer.prepareAsync();
        // REMOVED: mPendingSubtitleTracks

        // we don't set the target state here either, but preserve the
        // target state that was there before.
        mCurrentState = STATE_PREPARING;
        attachMediaController();
    } catch (IOException ex) {
        Log.w(TAG, "Unable to open content: " + mUri, ex);
        mCurrentState = STATE_ERROR;
        mTargetState = STATE_ERROR;
        mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
    } catch (IllegalArgumentException ex) {
        Log.w(TAG, "Unable to open content: " + mUri, ex);
        mCurrentState = STATE_ERROR;
        mTargetState = STATE_ERROR;
        mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
    } finally {
        // REMOVED: mPendingSubtitleTracks.clear();
    }
}

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   w w w  .ja  v a  2 s  . c om
@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.lybeat.lilyplayer.widget.media.IjkVideoView.java

@TargetApi(Build.VERSION_CODES.M)
private void openVideo() {
    if (mUri == null || mSurfaceHolder == null) {
        // not ready for playback just yet, will try again later
        return;//w ww .j a  v  a  2  s . c  o  m
    }
    // we shouldn't clear the target state, because somebody might have
    // called start() previously
    release(false);

    AudioManager am = (AudioManager) mAppContext.getSystemService(Context.AUDIO_SERVICE);
    am.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);

    try {
        mMediaPlayer = createPlayer(mSettings.getPlayer());

        // TODO: create SubtitleController in MediaPlayer, but we need
        // a context for the subtitle renderers
        final Context context = getContext();
        // REMOVED: SubtitleController

        // REMOVED: mAudioSession
        mMediaPlayer.setOnPreparedListener(mPreparedListener);
        mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
        mMediaPlayer.setOnCompletionListener(mCompletionListener);
        mMediaPlayer.setOnErrorListener(mErrorListener);
        mMediaPlayer.setOnInfoListener(mInfoListener);
        mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
        mCurrentBufferPercentage = 0;
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            mMediaPlayer.setDataSource(mAppContext, mUri, mHeaders);
        } else {
            mMediaPlayer.setDataSource(mUri.toString());
        }
        bindSurfaceHolder(mMediaPlayer, mSurfaceHolder);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.setScreenOnWhilePlaying(true);
        mMediaPlayer.prepareAsync();
        if (mHudViewHolder != null)
            mHudViewHolder.setMediaPlayer(mMediaPlayer);

        // REMOVED: mPendingSubtitleTracks

        // we don't set the target state here either, but preserve the
        // target state that was there before.
        mCurrentState = STATE_PREPARING;
        attachMediaController();
    } catch (IOException ex) {
        Log.w(TAG, "Unable to open content: " + mUri, ex);
        mCurrentState = STATE_ERROR;
        mTargetState = STATE_ERROR;
        mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
        return;
    } catch (IllegalArgumentException ex) {
        Log.w(TAG, "Unable to open content: " + mUri, ex);
        mCurrentState = STATE_ERROR;
        mTargetState = STATE_ERROR;
        mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
        return;
    } finally {
        // REMOVED: mPendingSubtitleTracks.clear();
    }
}

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;// w ww  .j a v  a2 s .c  om
    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;
}