[vlc-commits] medialib: Widen stored playback position for long videos
Mikhail Gusarov
git at videolan.org
Thu Dec 19 18:01:16 CET 2019
vlc | branch: master | Mikhail Gusarov <dottedmag at dottedmag.net> | Sun Dec 15 19:21:52 2019 +0100| [a3840f69bc732a0493bf8ac060413b2ef07986f8] | committer: Hugo Beauzée-Luyssen
medialib: Widen stored playback position for long videos
Existing logic of storing playback position excludes positions within last 5%.
This heuristic is fine for short videos, but for a longer, say 6-hour hones, it
means that the position is not stored for the last 18 minutes, which is a
nuisance.
This change adds an upper limit for the size of excluded positions and makes it
symmetric, so that a video that was stopped just after the start will be
restarted from the beginning.
This is a continuation of a macOS-specific patch that landed as
e3e32ab0119edfd762718ecd9a084aeaef873e2f in branch 3.0
Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a3840f69bc732a0493bf8ac060413b2ef07986f8
---
src/player/medialib.c | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/player/medialib.c b/src/player/medialib.c
index c079870ab1..35cce91f2c 100644
--- a/src/player/medialib.c
+++ b/src/player/medialib.c
@@ -109,6 +109,26 @@ vlc_player_input_RestoreMlStates(struct vlc_player_input* input,
vlc_ml_release(media);
}
+static const float beginning_of_media_percent = .5f;
+static const int64_t beginning_of_media_sec = 60;
+
+static int
+beginning_of_media(struct vlc_player_input *input)
+{
+ return input->position <= beginning_of_media_percent &&
+ input->time < VLC_TICK_FROM_SEC(beginning_of_media_sec);
+}
+
+static const float end_of_media_percent = .95f;
+static const int64_t end_of_media_sec = 60;
+
+static int
+end_of_media(struct vlc_player_input *input)
+{
+ return input->position >= end_of_media_percent &&
+ input->length - input->time < VLC_TICK_FROM_SEC(end_of_media_sec);
+}
+
void
vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input* input)
{
@@ -134,12 +154,13 @@ vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input* input)
return;
}
- /* If we reached 95% of the media or have less than 10s remaining, bump the
- * play count & the media in the history */
- if (input->position >= .95f ||
- input->length - input->time < VLC_TICK_FROM_SEC(10))
- {
+ /* If we reached end of the media, bump the play count & the media in the
+ * history */
+ if (end_of_media(input))
vlc_ml_media_increase_playcount(ml, media->i_id);
+
+ if (beginning_of_media(input) || end_of_media(input))
+ {
/* Ensure we remove any previously saved position to allow the playback
* of this media to restart from the begining */
if (input->ml.states.progress >= .0f )
More information about the vlc-commits
mailing list