[Android] PlayerController: Check mediaplayer isn't released

Geoffrey Métais git at videolan.org
Mon Feb 18 18:15:47 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 18 18:07:41 2019 +0100| [109e9ed5578f22cd18fe3cc6d5e8f1fabaea5bb7] | committer: Geoffrey Métais

PlayerController: Check mediaplayer isn't released

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

 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 971b11261..e73ea2a07 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -46,7 +46,7 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
 
     fun getVout(): IVLCVout? = mediaplayer.vlcVout
 
-    fun canDoPassthrough() = mediaplayer.canDoPassthrough()
+    fun canDoPassthrough() = mediaplayer.hasMedia() && !mediaplayer.isReleased && mediaplayer.canDoPassthrough()
 
     fun getMedia(): Media? = mediaplayer.media
 
@@ -143,7 +143,7 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
 
     fun getSpuDelay() = mediaplayer.spuDelay
 
-    fun getRate() = if (mediaplayer.hasMedia() && playbackState != PlaybackStateCompat.STATE_STOPPED) mediaplayer.rate else 1.0f
+    fun getRate() = if (mediaplayer.hasMedia() && !mediaplayer.isReleased && playbackState != PlaybackStateCompat.STATE_STOPPED) mediaplayer.rate else 1.0f
 
     fun setSpuDelay(delay: Long) = mediaplayer.setSpuDelay(delay)
 
@@ -252,9 +252,9 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
 
     fun navigate(where: Int) = mediaplayer.navigate(where)
 
-    fun getChapters(title: Int): Array<out MediaPlayer.Chapter>? = mediaplayer.getChapters(title)
+    fun getChapters(title: Int): Array<out MediaPlayer.Chapter>? = if (!mediaplayer.isReleased) mediaplayer.getChapters(title) else emptyArray()
 
-    fun getTitles(): Array<out MediaPlayer.Title>? = mediaplayer.titles
+    fun getTitles(): Array<out MediaPlayer.Title>? = if (!mediaplayer.isReleased) mediaplayer.titles else emptyArray()
 
     fun getChapterIdx() = mediaplayer.chapter
 



More information about the Android mailing list