From 62ff36b77cefc59203ad330b91c91cb98bdac771 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 10 Sep 2023 12:28:20 +0200 Subject: [PATCH] fix: videos played with background player not added to watch history --- .../com/github/libretube/services/OnlinePlayerService.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt index 011542ded..99318f244 100644 --- a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt +++ b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt @@ -275,6 +275,13 @@ class OnlinePlayerService : LifecycleService() { Player.STATE_BUFFERING -> {} Player.STATE_READY -> { isTransitioning = false + + // save video to watch history when the video starts playing or is being resumed + // waiting for the player to be ready since the video can't be claimed to be watched + // while it did not yet start actually, but did buffer only so far + lifecycleScope.launch(Dispatchers.IO) { + streams?.let { DatabaseHelper.addToWatchHistory(videoId, it) } + } } } }