[Android] Flush only when needed

Thomas Guillem git at videolan.org
Fri Mar 31 17:04:32 CEST 2017


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Mar 31 17:00:23 2017 +0200| [c3c50c563023ca2a87b538392be650b599a5903c] | committer: Thomas Guillem

Flush only when needed

Don't do the hack from LibVLC, but from VideoPlayerActivity and PopupManger
when switching to Video. This fixes a restart in loop when playing multi part
mkvs.

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

 libvlc/src/org/videolan/libvlc/MediaPlayer.java               |  7 -------
 vlc-android/src/org/videolan/vlc/PlaybackService.java         | 11 +++++++++++
 vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java  |  2 ++
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java   |  2 ++
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 43c6888..8967a36 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -820,13 +820,6 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
                 for (MediaPlayer.TrackDescription track : tracks) {
                     if (track.id != -1) {
                         setVideoTrack(track.id);
-                        /* HACK: flush when activating a video track. This will force an
-                         * I-Frame to be displayed right away. */
-                        if (isSeekable()) {
-                            long time = getTime();
-                            if (time > 0)
-                                setTime(time);
-                        }
                         break;
                     }
                 }
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 56b94b0..2ec0e10 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1972,6 +1972,17 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
         playIndex(index, 0);
     }
 
+    @MainThread
+    public void flush() {
+        /* HACK: flush when activating a video track. This will force an
+         * I-Frame to be displayed right away. */
+        if (isSeekable()) {
+            long time = getTime();
+            if (time > 0 )
+                setTime(time);
+        }
+    }
+
     /**
      * Use this function to show an URI in the audio interface WITHOUT
      * interrupting the stream.
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
index 11762b9..41cc9da 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
@@ -112,6 +112,8 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
         mService.setVideoTrackEnabled(true);
         if (!mService.isPlaying())
             mService.playIndex(mService.getCurrentMediaPosition());
+        else
+            mService.flush();
         mService.startService(new Intent(mService, PlaybackService.class));
         showNotification();
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index eb49a03..6c931bb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -3058,6 +3058,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             itemTitle = openedMedia.getTitle();
             updateSeekable(mService.isSeekable());
             updatePausable(mService.isPausable());
+
+            mService.flush();
         }
 
         if (mUri != null) {



More information about the Android mailing list