[Android] Player controller: avoid IllegalStateException

Geoffrey Métais git at videolan.org
Thu Oct 17 11:55:23 CEST 2019


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

Player controller: avoid IllegalStateException

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

 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