Skip to content
Snippets Groups Projects
Commit 4d14ea86 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Restart player properly

Fixes #409
parent cc60d767
No related branches found
No related tags found
1 merge request!629Restart player properly
Pipeline #18747 passed with stage
in 2 minutes and 22 seconds
......@@ -1028,7 +1028,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
@MainThread
fun removeCallback(cb: Callback) = cbActor.safeOffer(CbRemove(cb))
fun restartMediaPlayer() = playlistManager.player.restart()
fun restartMediaPlayer() = playlistManager.restart()
fun saveMediaMeta() = playlistManager.saveMediaMeta()
......
......@@ -12,6 +12,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
import okhttp3.internal.waitMillis
import org.videolan.libvlc.FactoryManager
import org.videolan.libvlc.MediaPlayer
import org.videolan.libvlc.RendererItem
......@@ -216,6 +217,12 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
launch { playIndex(currentIndex) }
}
fun restart() {
val isPlaying = player.isPlaying() && isAudioList()
stop()
if (isPlaying) PlaybackService.loadLastAudio(service)
}
fun stop(systemExit: Boolean = false, video: Boolean = false) {
clearABRepeat()
stopAfter = -1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment