[Android] PlayerController: player actions in proper context

Geoffrey Métais git at videolan.org
Wed Jan 31 13:06:49 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 31 13:05:48 2018 +0100| [c998ba586a0e1403617acdac1ef954fc161a89f6] | committer: Geoffrey Métais

PlayerController: player actions in proper context

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

 .../src/org/videolan/vlc/media/PlayerController.kt | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
index f10a4372d..c24bd931b 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -61,19 +61,19 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
 
     private var mediaplayerEventListener: MediaPlayer.EventListener? = null
     internal suspend fun startPlayback(media: Media, listener: MediaPlayer.EventListener) {
-        mediaplayer.setEventListener(null)
         mediaplayerEventListener = listener
         seekable = true
         pausable = true
         launch(playerContext+exceptionHandler) {
+            mediaplayer.setEventListener(null)
             mediaplayer.media = media
+            mediaplayer.setEventListener(this at PlayerController)
+            mediaplayer.setEqualizer(VLCOptions.getEqualizerSetFromSettings(VLCApplication.getAppContext()))
+            mediaplayer.setVideoTitleDisplay(MediaPlayer.Position.Disable, 0)
+            mediaplayer.play()
         }.join()
-        mediaplayer.setEventListener(this at PlayerController)
-        mediaplayer.setEqualizer(VLCOptions.getEqualizerSetFromSettings(VLCApplication.getAppContext()))
-        mediaplayer.setVideoTitleDisplay(MediaPlayer.Position.Disable, 0)
         if (mediaplayer.rate == 1.0f && settings.getBoolean(PreferencesActivity.KEY_PLAYBACK_SPEED_PERSIST, true))
             setRate(settings.getFloat(PreferencesActivity.KEY_PLAYBACK_RATE, 1.0f), false)
-        mediaplayer.play()
     }
 
     @MainThread
@@ -235,11 +235,13 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
 
     suspend fun expand(): MediaList? {
         return mediaplayer.media?.let {
-            mediaplayer.setEventListener(null)
-            val ml = async(playerContext+exceptionHandler) { it.subItems() }.await()
-            it.release()
-            mediaplayer.setEventListener(this at PlayerController)
-            return ml
+            return async(playerContext) {
+                mediaplayer.setEventListener(null)
+                val items = it.subItems()
+                it.release()
+                mediaplayer.setEventListener(this at PlayerController)
+                items
+            }.await()
         }
     }
 



More information about the Android mailing list