Commit 68f2cbb3 authored by Geoffrey Métais's avatar Geoffrey Métais

Refine slaves management on media loading

parent d5747b73
......@@ -180,8 +180,14 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
setPlaybackStopped()
}
fun setSlaves(media: MediaWrapper) = launch {
val list = MediaDatabase.getInstance().getSlaves(media.location)
suspend fun setSlaves(media: Media, mw: MediaWrapper) {
val list = withContext(CommonPool) {
mw.slaves?.let {
for (slave in it) media.addSlave(slave)
MediaDatabase.getInstance().saveSlaves(mw)
}
MediaDatabase.getInstance().getSlaves(mw.location)
}
for (slave in list) mediaplayer.addSlave(slave.type, Uri.parse(slave.uri), false)
}
......
......@@ -263,12 +263,8 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
isHardware = false
}
}
mw.slaves?.let {
for (slave in it) media.addSlave(slave)
launch { MediaDatabase.getInstance().saveSlaves(mw) }
}
media.setEventListener(this@PlaylistManager)
player.setSlaves(mw)
player.setSlaves(media, mw)
player.startPlayback(media, mediaplayerEventListener)
media.release()
if (savedTime <= 0L && mw.time >= 0L && mw.isPodcast) savedTime = mw.time
......
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