[vlc-devel] [PATCH 2/2] macosx: widen stored playback position for longer videos

Mikhail Gusarov dottedmag at dottedmag.net
Thu Sep 19 16:33:52 CEST 2019


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.
---
 .../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
-- 
2.22.0



More information about the vlc-devel mailing list