mklimek / frame-video-view

Less issues with VideoView
Other
63 stars 19 forks source link

IllegalStateException when removing FrameVideoView from the layout #22

Open jauneshortcut opened 6 years ago

jauneshortcut commented 6 years ago

I have a chat where I use FrameVideoView to animate the writing state of the chat bubble (three dots moving up and down). When I remove the FrameVideoView to replace it with the static text chat bubble, an IllegalStateException is thrown. Before I remove the FrameVideoView, I check that the mediaPlayer = null but when it comes toTextureViewImpl.release(), the MediaPlayer is not null and the exception is thrown.

Stack trace is the following:

    java.lang.IllegalStateException
        at android.media.MediaPlayer._stop(Native Method)
        at android.media.MediaPlayer.stop(MediaPlayer.java:1231)
        at com.mklimek.frameviedoview.TextureViewImpl.release(TextureViewImpl.java:138)
        at com.mklimek.frameviedoview.TextureViewImpl.removeVideo(TextureViewImpl.java:150)
        at com.mklimek.frameviedoview.TextureViewImpl.onSurfaceTextureDestroyed(TextureViewImpl.java:103)
        at android.view.TextureView.destroySurface(TextureView.java:237)
        at android.view.TextureView.onDetachedFromWindowInternal(TextureView.java:227)
        at android.view.View.dispatchDetachedFromWindow(View.java:14556)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3063)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3063)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4603)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4576)
        at android.view.ViewGroup.removeView(ViewGroup.java:4507)
        at xxxx.welcome.fragment.NonOnboardingPostAuthFragment$1.onAnimationStart(NonOnboardingPostAuthFragment.java:65)
        at android.view.animation.Animation$1.run(Animation.java:362)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Any suggestions how to make it work? PS: it worked six months ago.