Video Player crashing when scrolled out of view and then back into view
-
[x] I have verified there are no duplicate active or recent bugs, questions, or requests
-
[x] I have verified that I am using the latest version of Better Video Player.
-
[x] I have given my issue a non-generic title.
-
[x] I have read over the documentation (before asking questions on how to do something).
-
Better Video Player version:
kotlin-SNAPSHOT -
Device OS version:
8.0 -
Device Manufacturer:
LG -
Device Name:
G7
Reproduction Steps
- Put the player in a scrolling view
- scroll the player out of view
- scroll the player back into view
Expected Result
App doesn't crash
Actual Result
App crashes
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.foo.bar.debug, PID: 25435
java.lang.IllegalStateException
at android.media.MediaPlayer.getCurrentPosition(Native Method)
at com.halilibo.bvpkotlin.captions.CaptionsView.run(CaptionsView.kt:34)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6759)
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:770)
I have the player in a RecyclerView, but I have confirmed that the view is not being recycled when this occurs, so I don't believe that it has something specifically to do with RecyclerView. I have noticed that onDetachedFromWindow and onSurfaceTextureDestroyed are being called as I scroll it out of view, so I'm guessing that the media player is being released, and then when it comes back into view the CaptionsView is trying to use the released media player.
Anyway, apologies if this is not a real bug and I am just doing something wrong. If that's the case, if someone could point me in the right direction on how to solve this it would be great.
This is not a very well tested case. I will try to look into it. Thanks for the find 👍
I have resolve this by clone library & remove CaptionView :D
I am facing the same error, @mrkazansky I can not remove CaptionView as I have to use caption from raw.
Let me know if you found any solution
@piyushporiya5 I'm not sure if this will work for your situation, but I ended up using exoplayer directly and it worked well