Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe you could try to show your Toast through <a href="http://developer.android.com/reference/android/app/Activity.html#runOnUiThread%28java.lang.Runnable%29" rel="nofollow">runOnUiThread</a> ?</p> <p>Something like:</p> <pre><code> @Override public boolean onError(MediaPlayer arg0, int arg1, int arg2) { Player.this.runOnUiThread(new Runnable() { void run() { Toast.makeText(Player.this, "Sorry, unable to play this video", Toast.LENGTH_LONG).show(); progressDialog.dismiss(); if (mToken != null) { MusicUtils.unbindFromService(mToken); } finish(); } ); return false; } </code></pre> <p><strong>EDIT</strong>:</p> <p>Here is more...below is the code (in Froyo) for the VideoView.</p> <p>Seems like the error comes from the AlertDialog.Builder... but based on your code, it should not even get there since the error should be handled higher when mOnErrorListener is not null...</p> <p>Can you check whether your error handler is being called ? Maybe try to not call finish() there ?</p> <pre><code> private MediaPlayer.OnErrorListener mErrorListener = new MediaPlayer.OnErrorListener() { public boolean onError(MediaPlayer mp, int framework_err, int impl_err) { Log.d(TAG, "Error: " + framework_err + "," + impl_err); mCurrentState = STATE_ERROR; mTargetState = STATE_ERROR; if (mMediaController != null) { mMediaController.hide(); } /* If an error handler has been supplied, use it and finish. */ if (mOnErrorListener != null) { if (mOnErrorListener.onError(mMediaPlayer, framework_err, impl_err)) { return true; } } /* Otherwise, pop up an error dialog so the user knows that * something bad has happened. Only try and pop up the dialog * if we're attached to a window. When we're going away and no * longer have a window, don't bother showing the user an error. */ if (getWindowToken() != null) { Resources r = mContext.getResources(); int messageId; if (framework_err == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) { messageId = com.android.internal.R.string.VideoView_error_text_invalid_progressive_playback; } else { messageId = com.android.internal.R.string.VideoView_error_text_unknown; } new AlertDialog.Builder(mContext) .setTitle(com.android.internal.R.string.VideoView_error_title) .setMessage(messageId) .setPositiveButton(com.android.internal.R.string.VideoView_error_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* If we get here, there is no onError listener, so * at least inform them that the video is over. */ if (mOnCompletionListener != null) { mOnCompletionListener.onCompletion(mMediaPlayer); } } }) .setCancelable(false) .show(); } return true; } }; </code></pre> <p><strong>MORE EDIT:</strong></p> <p>Change the onError handler to <code>return true;</code></p> <p>Then the "default" error handler will not try to build this AlertDialog</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload