[vlc-commits] macosx: widen stored playback position for longer videos

Mikhail Gusarov git at videolan.org
Wed Sep 25 20:17:35 CEST 2019


vlc | branch: master | Mikhail Gusarov <dottedmag at dottedmag.net> | Thu Sep 19 14:33:52 2019 +0000| [be727c15a67e632adff3c33af8a79af3df2dfade] | committer: Felix Paul Kühne

macosx: widen stored playback position for longer videos

Existing logic of storing playback position for macOS excludes positions within
first/last 5%.

This heuristic is fine for short videos, but for a longer one, say a 6-hour one,
it means the position is not stored for the first/last 18 minutes, which is a
nuisance.

This change adds an upper limit for the size of excluded positions.

Signed-off-by: Felix Paul Kühne <felix at feepk.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=be727c15a67e632adff3c33af8a79af3df2dfade
---

 .../playlist/VLCPlaybackContinuityController.m       | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m b/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
index f0b02643ba..7c0049554c 100644
--- a/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
+++ b/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
@@ -243,11 +243,27 @@
 static const int64_t MinimumDuration = 3 * 60 * 1000;
 static const float MinimumStorePercent = 0.5;
 static const float MaximumStorePercent = 0.95;
+static const int64_t MinimumStoreTime = 60 * 1000;
+static const int64_t MinimumStoreRemainingTime = 60 * 1000;
 
 BOOL ShouldStorePlaybackPosition(float position, int64_t duration)
 {
-    return duration > MinimumDuration &&
-        position > MinimumStorePercent && position < MaximumStorePercent;
+    int64_t positionTime = position * duration;
+    int64_t remainingTime = duration - positionTime;
+
+    if (duration < MinimumDuration) {
+        return NO;
+    }
+
+    if (position < MinimumStorePercent && positionTime < MinimumStoreTime) {
+        return NO;
+    }
+
+    if (position > MaximumStorePercent && remainingTime < MinimumStoreRemainingTime) {
+        return NO;
+    }
+
+    return YES;
 }
 
 - (void)storePlaybackPositionForItem:(VLCInputItem *)inputItem



More information about the vlc-commits mailing list