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

Refine slaves management on media loading

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