avoid intializing mediaplayer with invalid surface

This commit is contained in:
tibbi 2017-04-12 21:35:51 +02:00
parent a93d4be112
commit 671e10087a

View File

@ -275,11 +275,11 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
}
override fun surfaceCreated(holder: SurfaceHolder) {
initMediaPlayer()
}
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
setVideoSize()
}
override fun surfaceDestroyed(holder: SurfaceHolder) {
@ -288,7 +288,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
}
private fun setVideoSize() {
if (activity == null)
if (activity == null || !mSurfaceHolder!!.surface.isValid)
return
initMediaPlayer()