[vlc-devel] [PATCH 12/14] player: Increase the media playcount when stopping
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Mon Sep 23 11:44:55 CEST 2019
refs #22524
---
src/player/medialib.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/player/medialib.c b/src/player/medialib.c
index 27d8364cd7..579ab4ab07 100644
--- a/src/player/medialib.c
+++ b/src/player/medialib.c
@@ -134,7 +134,23 @@ vlc_player_UpdateMLStates(vlc_player_t *player, struct vlc_player_input* input)
return;
}
- input->ml.states.progress = input->position;
+ /* 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))
+ {
+ vlc_ml_media_increase_playcount(ml, media->i_id);
+ /* 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 )
+ {
+ vlc_ml_media_set_playback_state(ml, media->i_id,
+ VLC_ML_PLAYBACK_STATE_PROGRESS, NULL );
+ input->ml.states.progress = -1.f;
+ }
+ }
+ else
+ input->ml.states.progress = input->position;
/* If the value changed during the playback, update it in the medialibrary.
* If not, set each state to their "unset" values, so that they aren't saved
--
2.20.1
More information about the vlc-devel
mailing list