mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
release the mediaplayer if something goes wrong at init
This commit is contained in:
parent
99f14bfee1
commit
47ec461139
1 changed files with 8 additions and 4 deletions
|
@ -229,6 +229,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "init media player failed $e")
|
||||
releaseMediaPlayer()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,12 +260,16 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
private fun cleanup() {
|
||||
pauseVideo()
|
||||
mCurrTimeView?.text = 0.getFormattedDuration()
|
||||
mMediaPlayer?.release()
|
||||
mMediaPlayer = null
|
||||
releaseMediaPlayer()
|
||||
mSeekBar?.progress = 0
|
||||
mTimerHandler?.removeCallbacksAndMessages(null)
|
||||
}
|
||||
|
||||
private fun releaseMediaPlayer() {
|
||||
mMediaPlayer?.release()
|
||||
mMediaPlayer = null
|
||||
}
|
||||
|
||||
private fun videoPrepared(mediaPlayer: MediaPlayer) {
|
||||
mDuration = mediaPlayer.duration / 1000
|
||||
addPreviewImage()
|
||||
|
@ -295,8 +300,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||
mMediaPlayer?.release()
|
||||
mMediaPlayer = null
|
||||
releaseMediaPlayer()
|
||||
}
|
||||
|
||||
private fun setVideoSize() {
|
||||
|
|
Loading…
Reference in a new issue