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

Mikhail Gusarov git at videolan.org
Fri Sep 27 21:00:21 CEST 2019


vlc/vlc-3.0 | branch: master | Mikhail Gusarov <dottedmag at dottedmag.net> | Wed Sep 25 19:40:24 2019 +0000| [e3e32ab0119edfd762718ecd9a084aeaef873e2f] | 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: Mikhail Gusarov <dottedmag at dottedmag.net>
Signed-off-by: Felix Paul Kühne <felix at feepk.net>

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

 modules/gui/macosx/VLCInputManager.m | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/VLCInputManager.m b/modules/gui/macosx/VLCInputManager.m
index c418510aea..f4ada0f9a3 100644
--- a/modules/gui/macosx/VLCInputManager.m
+++ b/modules/gui/macosx/VLCInputManager.m
@@ -621,11 +621,27 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 static const int64_t MinimumDuration = 3 * 60 * 1000;
 static const float MinimumStorePercent = 0.05;
 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:(input_thread_t *)p_input_thread



More information about the vlc-commits mailing list