[Android] Simplify video loading

Geoffrey Métais git at videolan.org
Mon Mar 21 10:56:40 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar 21 10:56:11 2016 +0100| [9b0862d251836118e93681061dcf68b49696c6ec] | committer: Geoffrey Métais

Simplify video loading

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

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java   | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

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 783e34c..e288d27 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2781,21 +2781,20 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             mService.addCallback(this);
             if (mService.isPlaying() && mService.getCurrentMediaWrapper().hasFlag(MediaWrapper.MEDIA_VIDEO)) {
                 onPlaying();
-            } else if (positionInPlaylist == -1) {
+            } else {
                 /* prepare playback */
-                mService.stop();
-                final MediaWrapper mw = new MediaWrapper(mUri);
+                boolean hasMedia = mService.hasMedia();
+                final MediaWrapper mw = hasMedia ? mService.getCurrentMediaWrapper() :new MediaWrapper(mUri);
                 if (mWasPaused)
                     mw.addFlags(MediaWrapper.MEDIA_PAUSED);
                 if (mHardwareAccelerationError || intent.hasExtra(PLAY_DISABLE_HARDWARE))
                     mw.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
                 mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                 mw.addFlags(MediaWrapper.MEDIA_VIDEO);
-                mService.load(mw);
-            } else {
-                mService.getCurrentMediaWrapper().addFlags(MediaWrapper.MEDIA_VIDEO);
-                // AudioService-transitioned playback for item after sleep and resume
-                if(!mService.isPlaying())
+                // PlaybackService-transitioned playback for item after sleep and resume
+                if (!hasMedia)
+                    mService.load(mw);
+                else if (!mService.isPlaying())
                     mService.playIndex(positionInPlaylist);
                 else
                     onPlaying();



More information about the Android mailing list