我使用VideoView,通过调用addSubtitleSource
在其上附加了字幕。有时,应用程序会因以下消息而崩溃:
2018-09-05 15:16:49.603 6078-6078/com.agilix.dawn E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.agilix.dawn, PID: 6078
java.lang.ArithmeticException: divide by zero
at android.media.WebVttRenderingWidget.layoutCue(WebVttRenderer.java:1405)
at android.media.WebVttRenderingWidget.onLayout(WebVttRenderer.java:1371)
at android.view.View.layout(View.java:19602)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.media.WebVttRenderingWidget.setSize(WebVttRenderer.java:1178)
at android.media.WebVttRenderingWidget.setActiveCues(WebVttRenderer.java:1268)
at android.media.WebVttTrack.updateView(WebVttRenderer.java:1104)
at android.media.SubtitleTrack.onTimedEvent(SubtitleTrack.java:234)
at android.media.MediaPlayer$TimeProvider.notifyTimedEvent(MediaPlayer.java:5432)
at android.media.MediaPlayer$TimeProvider.-wrap2(Unknown Source:0)
at android.media.MediaPlayer$TimeProvider$EventHandler.handleMessage(MediaPlayer.java:5513)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
我怀疑这是一个计时问题,因为它大约90%的时间有效,而在尝试调试时的99%的时间有效。文档尚不清楚何时可以调用此方法。有时(但不总是)与在视频上调用seekTo有关。任何的意见都将会有帮助。