[Android] PlayerController: extract playback reset function

Geoffrey Métais git at videolan.org
Mon Jun 11 11:35:17 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun 11 11:34:37 2018 +0200| [7566c3b012a6a7ef2e78e4e5c59f194a45ef0734] | committer: Geoffrey Métais

PlayerController: extract playback reset function

> https://code.videolan.org/videolan/vlc-android/commit/7566c3b012a6a7ef2e78e4e5c59f194a45ef0734
---

 vlc-android/src/org/videolan/vlc/media/PlayerController.kt | 12 ++++++++----
 1 file changed, 8 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 69ec03f90..8cf5fc977 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -71,10 +71,7 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
     private var mediaplayerEventListener: MediaPLayerEventListener? = null
     internal fun startPlayback(media: Media, listener: MediaPLayerEventListener) {
         mediaplayerEventListener = listener
-        seekable = true
-        pausable = true
-        lastTime = 0L
-        updateProgress(0L, media.duration)
+        resetPlaybackState(media.duration)
         mediaplayer.setEventListener(null)
         mediaplayer.media = media.apply { if (hasRenderer) parse() }
         mediaplayer.setEventListener(this at PlayerController)
@@ -85,6 +82,13 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
             setRate(settings.getFloat(PreferencesActivity.KEY_PLAYBACK_RATE, 1.0f), false)
     }
 
+    private fun resetPlaybackState(duration: Long) {
+        seekable = true
+        pausable = true
+        lastTime = 0L
+        updateProgress(0L, duration)
+    }
+
     @MainThread
     fun restart() {
         val mp = mediaplayer



More information about the Android mailing list