Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.

Video Player crashing when scrolled out of view and then back into view #89

Open
4 tasks done
skroth opened this issue Mar 13, 2019 · 4 comments
Open
4 tasks done
Assignees
Labels

Comments

@skroth
Copy link

skroth commented Mar 13, 2019

  • I have verified there are no duplicate active or recent bugs, questions, or requests

  • I have verified that I am using the latest version of Better Video Player.

  • I have given my issue a non-generic title.

  • 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
  1. Put the player in a scrolling view
  2. scroll the player out of view
  3. 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.

@halilozercan halilozercan self-assigned this Mar 13, 2019
@halilozercan
Copy link
Owner

This is not a very well tested case. I will try to look into it. Thanks for the find 👍

@mrkazansky
Copy link

I have resolve this by clone library & remove CaptionView :D

@piyushporiya5
Copy link

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

@skroth
Copy link
Author

skroth commented Sep 4, 2019

@piyushporiya5 I'm not sure if this will work for your situation, but I ended up using exoplayer directly and it worked well

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants