[Android] Fix slaves loaded twice
Geoffrey Métais
git at videolan.org
Thu Feb 7 17:01:20 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 7 16:53:51 2019 +0100| [adeb0a0b6e3174915ffce7693ff1206cd8bff922] | committer: Geoffrey Métais
Fix slaves loaded twice
> https://code.videolan.org/videolan/vlc-android/commit/adeb0a0b6e3174915ffce7693ff1206cd8bff922
---
vlc-android/src/org/videolan/vlc/media/PlayerController.kt | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
index baa9fbce4..f3fc47d98 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -199,12 +199,10 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
val slaves = mw.slaves
slaves?.let { it.forEach { slave -> media.addSlave(slave) } }
media.release()
- slaves?.let {
- slaveRepository.saveSlaves(mw)?.forEach { it.join() }
- }
slaveRepository.getSlaves(mw.location).forEach { slave ->
- mediaplayer.addSlave(slave.type, Uri.parse(slave.uri), false)
+ if (!slaves.contains(slave)) mediaplayer.addSlave(slave.type, Uri.parse(slave.uri), false)
}
+ slaves?.let { slaveRepository.saveSlaves(mw) }
}
private fun newMediaPlayer() : MediaPlayer {
@@ -335,4 +333,10 @@ class Progress(var time: Long = 0L, var length: Long = 0L)
internal interface MediaPlayerEventListener {
suspend fun onEvent(event: MediaPlayer.Event)
+}
+
+private fun Array<Media.Slave>?.contains(item: Media.Slave) : Boolean {
+ if (this == null) return false
+ for (slave in this) if (slave.uri == item.uri) return true
+ return false
}
\ No newline at end of file
More information about the Android
mailing list