Commit 8a0b6dde authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Safer media & player releasing order

parent d103df73
...@@ -60,7 +60,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener { ...@@ -60,7 +60,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
setPlaybackStopped() setPlaybackStopped()
} }
fun releaseMedia() = mediaplayer.media?.let { private fun releaseMedia() = mediaplayer.media?.let {
it.setEventListener(null) it.setEventListener(null)
it.release() it.release()
} }
...@@ -172,6 +172,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener { ...@@ -172,6 +172,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
fun release(player: MediaPlayer = mediaplayer) { fun release(player: MediaPlayer = mediaplayer) {
player.setEventListener(null) player.setEventListener(null)
if (isVideoPlaying()) player.vlcVout.detachViews() if (isVideoPlaying()) player.vlcVout.detachViews()
releaseMedia()
launch(newSingleThreadContext("vlc-player-release")) { launch(newSingleThreadContext("vlc-player-release")) {
if (BuildConfig.DEBUG) { // Warn if player release is blocking if (BuildConfig.DEBUG) { // Warn if player release is blocking
try { try {
......
...@@ -194,13 +194,12 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList ...@@ -194,13 +194,12 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
savePosition() savePosition()
saveMediaMeta() saveMediaMeta()
} }
player.releaseMedia()
mediaList.removeEventListener(this) mediaList.removeEventListener(this)
previous.clear() previous.clear()
currentIndex = -1 currentIndex = -1
mediaList.clear()
if (systemExit) player.release() if (systemExit) player.release()
else player.restart() else player.restart()
mediaList.clear()
showAudioPlayer.value = false showAudioPlayer.value = false
service.onPlaybackStopped(systemExit) service.onPlaybackStopped(systemExit)
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment