[Android] Check media resume point only on loading
Geoffrey Métais
git at videolan.org
Thu Dec 21 17:28:33 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Dec 21 10:50:08 2017 +0100| [dfeda1282d1dbfda10a2657fc36a282d5490474f] | committer: Geoffrey Métais
Check media resume point only on loading
(cherry picked from commit 353d92f1877821bede685f3fb97b647a62dcb3c5)
> https://code.videolan.org/videolan/vlc-android/commit/dfeda1282d1dbfda10a2657fc36a282d5490474f
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 531cea69e..29b363b17 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -212,6 +212,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
private int mRepeating = REPEAT_NONE;
private Random mRandom = null; // Used in shuffling process
private long mSavedTime = 0L;
+ private boolean mNewMedia;
private boolean mHasAudioFocus = false;
// RemoteControlClient-related
/**
@@ -645,7 +646,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mStopped = false;
final MediaWrapper mw = getCurrentMediaWrapper();
loadMediaMeta();
- seekToResume(mw);
+ if (mNewMedia) seekToResume(mw);
+ mNewMedia = false;
Log.i(TAG, "MediaPlayer.Event.Playing");
executeUpdate();
@@ -733,8 +735,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
private void seekToResume(MediaWrapper mw) {
if (mSavedTime > 0L) {
- if (mSavedTime < 0.95*getLength())
- seek(mSavedTime);
+ if (mSavedTime < 0.95*getLength()) seek(mSavedTime);
mSavedTime = 0L;
} else {
final long length = getLength();
@@ -742,8 +743,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mw = mMedialibrary.findMedia(mw);
if (mw.getId() != 0L) {
mw.setTime((long) (mw.getMetaLong(MediaWrapper.META_PROGRESS) * (double) length) / 100L);
- if (mw.getTime() > 0L)
- seek(mw.getTime());
+ if (mw.getTime() > 0L) seek(mw.getTime());
}
}
}
@@ -2108,6 +2108,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
setRate(mSettings.getFloat(PreferencesActivity.KEY_PLAYBACK_RATE, 1.0F), false);
if (mSavedTime <= 0L && mw.getTime() >= 0L && mw.isPodcast())
mSavedTime = mw.getTime();
+ mNewMedia = true;
mMediaPlayer.play();
determinePrevAndNextIndices();
More information about the Android
mailing list