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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With