[vlc-devel] [PATCH 11/12] player: Increase the media playcount when stopping

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Jul 31 11:20:40 CEST 2019


refs #22524
---
 src/input/player.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/input/player.c b/src/input/player.c
index 451f16ee4f..e772ebaa87 100644
--- a/src/input/player.c
+++ b/src/input/player.c
@@ -962,7 +962,18 @@ static void vlc_player_UpdateML(vlc_player_t *player,
             return;
     }
 
-    input->prefs.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 don't store the position to allow this media to restart
+         * from its begining */
+        input->prefs.progress = .0f;
+    }
+    else
+        input->prefs.progress = input->position;
     input->prefs.current_title = input->title_selected;
     if (input->rate != input->prefs.rate)
         input->prefs.rate = input->rate;
-- 
2.20.1



More information about the vlc-devel mailing list