[Android] Player: release media immediately

Geoffrey Métais git at videolan.org
Mon Jun 11 14:50:18 CEST 2018


vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun 11 14:46:08 2018 +0200| [d2cbd83c735d978f2574ca651e6eb21a6cbab6dd] | committer: Geoffrey Métais

Player: release media immediately

> https://code.videolan.org/videolan/vlc-android/commit/d2cbd83c735d978f2574ca651e6eb21a6cbab6dd
---

 vlc-android/src/org/videolan/vlc/media/PlayerController.kt | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
index 2f079b3f3..bab7a0df2 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -181,14 +181,15 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
     }
 
     fun setSlaves(media: Media, mw: MediaWrapper) = launch(UI, CoroutineStart.UNDISPATCHED) {
+        val slaves = mw.slaves
+        slaves?.let { for (slave in it) media.addSlave(slave) }
+        media.release()
         val list = withContext(CommonPool) {
-            mw.slaves?.let {
-                for (slave in it) media.addSlave(slave)
-                MediaDatabase.getInstance().saveSlaves(mw)
+            MediaDatabase.getInstance().run {
+                if (slaves != null) saveSlaves(mw)
+                getSlaves(mw.location)
             }
-            MediaDatabase.getInstance().getSlaves(mw.location)
         }
-        media.release()
         for (slave in list) mediaplayer.addSlave(slave.type, Uri.parse(slave.uri), false)
     }
 



More information about the Android mailing list