[vlc-commits] macosx: extract a helper to test if the position should be saved
Mikhail Gusarov
git at videolan.org
Fri Sep 27 21:00:20 CEST 2019
vlc/vlc-3.0 | branch: master | Mikhail Gusarov <dottedmag at dottedmag.net> | Wed Sep 25 19:40:24 2019 +0000| [4c225861f61b663aebd86bc837c1813e61db571d] | committer: Felix Paul Kühne
macosx: extract a helper to test if the position should be saved
This refactoring is a prerequisite for the next commit that improves the
decision for long video files.
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=4c225861f61b663aebd86bc837c1813e61db571d
---
modules/gui/macosx/VLCInputManager.m | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/modules/gui/macosx/VLCInputManager.m b/modules/gui/macosx/VLCInputManager.m
index 3dd9f371dc..c418510aea 100644
--- a/modules/gui/macosx/VLCInputManager.m
+++ b/modules/gui/macosx/VLCInputManager.m
@@ -618,6 +618,16 @@ 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;
+
+BOOL ShouldStorePlaybackPosition(float position, int64_t duration)
+{
+ return duration > MinimumDuration &&
+ position > MinimumStorePercent && position < MaximumStorePercent;
+}
+
- (void)storePlaybackPositionForItem:(input_thread_t *)p_input_thread
{
if (!var_InheritBool(getIntf(), "macosx-recentitems"))
@@ -645,7 +655,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
NSMutableArray *mediaList = [[defaults objectForKey:@"recentlyPlayedMediaList"] mutableCopy];
- if (relativePos > .05 && relativePos < .95 && dur > 180) {
+ if (ShouldStorePlaybackPosition(relativePos, dur*1000)) {
msg_Dbg(getIntf(), "Store current playback position of %f", relativePos);
[mutDict setObject:[NSNumber numberWithInt:pos] forKey:url];
More information about the vlc-commits
mailing list