[Android] PlayerController: Prevent IllegalStateException

Geoffrey Métais git at videolan.org
Wed Mar 6 15:43:02 CET 2019


vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar  1 15:54:40 2019 +0100| [4432151eee061346075f87f7d590ddc7b7ae46d6] | committer: Geoffrey Métais

PlayerController: Prevent IllegalStateException

(cherry picked from commit 71d43fe5e2934b18503720371ef681af9a148dc1)

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

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

diff --git a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
index d1dd484dd..135863f09 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -115,9 +115,9 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
 
     fun isPlaying() = playbackState == PlaybackStateCompat.STATE_PLAYING
 
-    fun isVideoPlaying() = mediaplayer.vlcVout.areViewsAttached()
+    fun isVideoPlaying() = !mediaplayer.isReleased && mediaplayer.vlcVout.areViewsAttached()
 
-    fun canSwitchToVideo() = mediaplayer.hasMedia() && mediaplayer.videoTracksCount > 0
+    fun canSwitchToVideo() = getVideoTracksCount() > 0
 
     fun getVideoTracksCount() = if (!mediaplayer.isReleased && mediaplayer.hasMedia()) mediaplayer.videoTracksCount else 0
 



More information about the Android mailing list