Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

crash log: InternalError in MediaPlayer.setSubtitleAnchor

Seeing the following crash log pop up quite often:

java.lang.InternalError: 
  at java.lang.Thread.nativeCreate (Native Method)
  at java.lang.Thread.start (Thread.java:733)
  at android.media.MediaPlayer.setSubtitleAnchor (MediaPlayer.java:3039)
  at android.media.MediaPlayer.scanInternalSubtitleTracks (MediaPlayer.java:3240)
  at android.media.MediaPlayer.prepare (MediaPlayer.java:1442)
  at android.media.MediaPlayer.create (MediaPlayer.java:1046)
  at android.media.MediaPlayer.create (MediaPlayer.java:1012)
  ...

I call MediaPlayer.create with the context/resource parameters. It works fine for me and for 95% of users. One thing to note is that I do get the dreaded

 E/MediaPlayer: Should have subtitle controller already set

log message which is the topic of many, many StackOverflow questions. I currently have been ignoring it like most answers tell me to - but if scanInternalSubtitleTracks is creating InternalError crashes, maybe I shouldn't?

like image 515
Epaga Avatar asked Aug 24 '18 16:08

Epaga


1 Answers

in the media Player android after MEDIA_PREPARED, Player start search subtitle and any Exception happen during searching subtitle send instead of crashing. you should ignore it or you can use another player like ExoPlayer.

case MEDIA_PREPARED:
    try {
         scanInternalSubtitleTracks();
    } catch (RuntimeException e) {
      // send error message instead of crashing;
      // send error message instead of inlining a call to onError
      // to avoid code duplication.
      Message msg2 = obtainMessage(
                        MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_UNSUPPORTED, null);
      sendMessage(msg2);
    }
    OnPreparedListener onPreparedListener = mOnPreparedListener;
    if (onPreparedListener != null)
         onPreparedListener.onPrepared(mMediaPlayer);
         return;

in android version 28 android let you use .setOnSubtitleDataListener() that could solve your problem on android 28

like image 182
Ali shatergholi Avatar answered Nov 11 '22 11:11

Ali shatergholi