[Android] Check player isn't released w getting tracks count

Geoffrey Métais git at videolan.org
Tue Feb 5 13:48:16 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb  5 13:27:50 2019 +0100| [95fa04ef52447291485d0cf556a2471c9a7e9958] | committer: Geoffrey Métais

Check player isn't released w getting tracks count

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

 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 bf6ef2917..857669cc5 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -119,7 +119,7 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
 
     fun canSwitchToVideo() = mediaplayer.hasMedia() && mediaplayer.videoTracksCount > 0
 
-    fun getVideoTracksCount() = if (mediaplayer.hasMedia()) mediaplayer.videoTracksCount else 0
+    fun getVideoTracksCount() = if (!mediaplayer.isReleased && mediaplayer.hasMedia()) mediaplayer.videoTracksCount else 0
 
     fun getVideoTracks(): Array<out MediaPlayer.TrackDescription>? = mediaplayer.videoTracks
 
@@ -127,7 +127,7 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
 
     fun getCurrentVideoTrack(): Media.VideoTrack? = mediaplayer.currentVideoTrack
 
-    fun getAudioTracksCount() = mediaplayer.audioTracksCount
+    fun getAudioTracksCount() = if (!mediaplayer.isReleased && mediaplayer.hasMedia()) mediaplayer.audioTracksCount else 0
 
     fun getAudioTracks(): Array<out MediaPlayer.TrackDescription>? = mediaplayer.audioTracks
 



More information about the Android mailing list