[vlc-devel] [PATCH 1/2] macosx: extract a helper to test if the position should be saved
Mikhail Gusarov
dottedmag at dottedmag.net
Thu Sep 19 16:33:51 CEST 2019
This refactoring is a prerequisite for the next commit that improves the
decision for long video files.
---
.../playlist/VLCPlaybackContinuityController.m | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m b/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
index 3bfefa4815..f0b02643ba 100644
--- a/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
+++ b/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
@@ -240,6 +240,16 @@
completionBlock:completionBlock];
}
+static const int64_t MinimumDuration = 3 * 60 * 1000;
+static const float MinimumStorePercent = 0.5;
+static const float MaximumStorePercent = 0.95;
+
+BOOL ShouldStorePlaybackPosition(float position, int64_t duration)
+{
+ return duration > MinimumDuration &&
+ position > MinimumStorePercent && position < MaximumStorePercent;
+}
+
- (void)storePlaybackPositionForItem:(VLCInputItem *)inputItem
player:(VLCPlayerController *)playerController
{
@@ -262,9 +272,8 @@
[self storeLegacyPlaybackPositionForInputItem:inputItem withPlayer:playerController];
}
- float position = playerController.position;
- if (position > .05 && position < .95 && libraryMediaItem.duration > 180000) {
- libraryMediaItem.lastPlaybackPosition = position;
+ if (ShouldStorePlaybackPosition(playerController.position, libraryMediaItem.duration)) {
+ libraryMediaItem.lastPlaybackPosition = playerController.position;
}
}
@@ -281,7 +290,7 @@
NSMutableArray *mediaList = [[defaults objectForKey:@"recentlyPlayedMediaList"] mutableCopy];
NSString *mrl = inputItem.MRL;
- 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 numberWithInteger:pos] forKey:inputItem.MRL];
--
2.22.0
More information about the vlc-devel
mailing list