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 {
setPlaybackStopped()
}
fun releaseMedia() = mediaplayer.media?.let {
private fun releaseMedia() = mediaplayer.media?.let {
it.setEventListener(null)
it.release()
}
......@@ -172,6 +172,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
fun release(player: MediaPlayer = mediaplayer) {
player.setEventListener(null)
if (isVideoPlaying()) player.vlcVout.detachViews()
releaseMedia()
launch(newSingleThreadContext("vlc-player-release")) {
if (BuildConfig.DEBUG) { // Warn if player release is blocking
try {
......
......@@ -194,13 +194,12 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
savePosition()
saveMediaMeta()
}
player.releaseMedia()
mediaList.removeEventListener(this)
previous.clear()
currentIndex = -1
mediaList.clear()
if (systemExit) player.release()
else player.restart()
mediaList.clear()
showAudioPlayer.value = false
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