Open liwshuo opened 7 years ago
case MEDIA_TIMED_TEXT:
OnTimedTextListener onTimedTextListener = mOnTimedTextListener;
if (onTimedTextListener == null)
return;
if (msg.obj == null) {
onTimedTextListener.onTimedText(mMediaPlayer, null);
} else {
if (msg.obj instanceof Parcel) {
Parcel parcel = (Parcel)msg.obj;
TimedText text = new TimedText(parcel);
parcel.recycle();
onTimedTextListener.onTimedText(mMediaPlayer, text);
}
}
return;
在MediaPlayer的源码里,TimedText参数是可能为null的,在回调的时候还是应该最好判断一下的吧.
public void onTimedText(MediaPlayer mp, TimedText text) {
AndroidMediaPlayer self = (AndroidMediaPlayer)this.mWeakMediaPlayer.get();
if(self != null) {
IjkTimedText ijkText = new IjkTimedText(text.getBounds(), text.getText());
AndroidMediaPlayer.this.notifyOnTimedText(ijkText);
}
}
want to fix it in next version
java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Rect android.media.TimedText.getBounds()' on a null object reference at tv.danmaku.ijk.media.player.AndroidMediaPlayer$AndroidMediaPlayerListenerHolder.onTimedText(AndroidMediaPlayer.java:427) at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:2895) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.os.HandlerThread.run(HandlerThread.java:61) 在AndroidMediaPlayer的AndroidMediaPlayerListenerHolder的onTimedText回调接口中,TimedText可能为空,导致NullPointerException。