[Android] Player controller: avoid IllegalStateException

Geoffrey Métais git at videolan.org
Thu Oct 17 12:09:14 CEST 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 17 10:13:40 2019 +0200| [7658431556cbf6cd72307018012b72719816bc6f] | committer: Geoffrey Métais

Player controller: avoid IllegalStateException

(cherry picked from commit 9aecf984df5b68fa45587133b222cb2794be6ca9)

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

 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 96fb1d541..39dd69859 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -103,11 +103,11 @@ class PlayerController(val context: Context) : IVLCVout.Callback, MediaPlayer.Ev
     }
 
     fun setPosition(position: Float) {
-        if (seekable) mediaplayer.position = position
+        if (seekable && mediaplayer.hasMedia() && !mediaplayer.isReleased) mediaplayer.position = position
     }
 
     fun setTime(time: Long) {
-        if (seekable) mediaplayer.time = time
+        if (seekable && mediaplayer.hasMedia() && !mediaplayer.isReleased) mediaplayer.time = time
     }
 
     fun isPlaying() = playbackState == PlaybackStateCompat.STATE_PLAYING



More information about the Android mailing list