[Android] Simplify load media algo
Geoffrey Métais
git at videolan.org
Tue Apr 5 18:55:03 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr 5 18:50:00 2016 +0200| [3013dff6fce557f0253424df341ab46f1df5e938] | committer: Geoffrey Métais
Simplify load media algo
> https://code.videolan.org/videolan/vlc-android/commit/3013dff6fce557f0253424df341ab46f1df5e938
---
.../vlc/gui/video/VideoPlayerActivity.java | 37 +++++++++++-----------
1 file changed, 18 insertions(+), 19 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 690556f..ef54460 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2811,26 +2811,25 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
// Start playback & seek
mService.addCallback(this);
- if (mService.isPlaying() && mService.getCurrentMediaWrapper().hasFlag(MediaWrapper.MEDIA_VIDEO)) {
+ /* prepare playback */
+ 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);
+
+ // Handle playback
+ if (!hasMedia)
+ mService.load(mw);
+ else if (!mService.isPlaying())
+ mService.playIndex(positionInPlaylist);
+ else
onPlaying();
- } else {
- /* prepare playback */
- 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);
- // PlaybackService-transitioned playback for item after sleep and resume
- if (!hasMedia)
- mService.load(mw);
- else if (!mService.isPlaying())
- mService.playIndex(positionInPlaylist);
- else
- onPlaying();
- }
+
+ // Set time
long resumeTime = intentPosition;
if (intentPosition <= 0 && media != null && media.getTime() > 0l)
resumeTime = media.getTime();
More information about the Android
mailing list