[Android] PlayerController: Sanity checks

Geoffrey Métais git at videolan.org
Wed Mar 6 17:19:27 CET 2019


vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar  6 17:01:39 2019 +0100| [fb2e04a45e1f2b871a8efd447fcceb879fde44c1] | committer: Geoffrey Métais

PlayerController: Sanity checks

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

 vlc-android/src/org/videolan/vlc/media/PlayerController.kt | 8 ++++----
 1 file changed, 4 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 818732987..506a66c5f 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -78,8 +78,8 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
         resetPlaybackState(media.duration)
         mediaplayer.setEventListener(null)
         withContext(Dispatchers.IO) { if (!mediaplayer.isReleased) mediaplayer.media = media.apply { if (hasRenderer) parse() } }
+        mediaplayer.setEventListener(this at PlayerController)
         if (!mediaplayer.isReleased) {
-            mediaplayer.setEventListener(this at PlayerController)
             mediaplayer.setEqualizer(VLCOptions.getEqualizerSetFromSettings(context))
             mediaplayer.setVideoTitleDisplay(MediaPlayer.Position.Disable, 0)
             mediaplayer.play()
@@ -175,7 +175,7 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
     }
 
     fun setRenderer(renderer: RendererItem?) {
-        mediaplayer.setRenderer(renderer)
+        if (!mediaplayer.isReleased) mediaplayer.setRenderer(renderer)
         hasRenderer = renderer !== null
     }
 
@@ -186,7 +186,7 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
         launch(Dispatchers.IO) {
             if (BuildConfig.DEBUG) { // Warn if player release is blocking
                 try {
-                    withTimeout(5000, { player.release() })
+                    withTimeout(5000) { player.release() }
                 } catch (exception: TimeoutCancellationException) {
                     launch { Toast.makeText(context, "media stop has timeouted!", Toast.LENGTH_LONG).show() }
                 }
@@ -210,7 +210,7 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
         return MediaPlayer(VLCInstance.get()).apply {
             setAudioDigitalOutputEnabled(VLCOptions.isAudioDigitalOutputEnabled(settings))
             VLCOptions.getAout(settings)?.let { setAudioOutput(it) }
-            setRenderer(PlaybackService.Companion.renderer.value)
+            setRenderer(PlaybackService.renderer.value)
             this.vlcVout.addCallback(this at PlayerController)
         }
     }



More information about the Android mailing list