Skip to content
Snippets Groups Projects
Commit 08f44135 authored by Mikhail Gusarov's avatar Mikhail Gusarov Committed by Felix Paul Kühne
Browse files

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: default avatarFelix Paul Kühne <felix@feepk.net>
parent 026ad891
No related branches found
No related tags found
No related merge requests found
......@@ -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];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment