yqritc / Android-ScalableVideoView

Android Texture VideoView having a variety of scale types like the scale types of ImageView such as fitCenter, centerCrop, centerTopCrop and more
Apache License 2.0
1.09k stars 223 forks source link

fix IllegalStateException in onDetachedFromWindow #12

Closed Piasy closed 8 years ago

Piasy commented 8 years ago

fix IllegalStateException when release called release before onDetachedFromWindow.

Details: In my HM note(China Xiaomi Inc), I use ScalableVideoView in fragment, I init ScalableVideoView in onViewCreated method, and when I destroy this fragment and recreate it again, the video could not be played, when I call ScalableVideoView.release() in onDestroyView method, the video could be played again in the condition above, but my app will crash with IllegalStateException, when the fragment is destroyed again.

I think set mMediaPlayer = null; in release() method could be solve this problem, and it does in my project (I introduce this repo's source into my project and set mMediaPlayer = null;, and the crash goes off).

yqritc commented 8 years ago

@Piasy

I init ScalableVideoView in onViewCreated method, and when I destroy this fragment and recreate it again, the video could not be played

I don't understand why this happens. It would be great if u can see me ur sample project. But setting mMediaPlayer = null; in release() seems better implementation. Thanks for you PR.