Merge pull request #7041 from Bnyro/master

fix: add offline played videos to watch history too
This commit is contained in:
Bnyro 2025-01-29 16:07:50 +01:00 committed by GitHub
commit 2eaeaa98c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,6 +47,15 @@ open class OfflinePlayerService : AbstractPlayerService() {
if (playbackState == Player.STATE_ENDED && PlayerHelper.isAutoPlayEnabled()) {
playNextVideo(PlayingQueue.getNext() ?: return)
}
if (playbackState == Player.STATE_READY) {
scope.launch(Dispatchers.IO) {
val watchHistoryItem = downloadWithItems?.download?.toStreamItem()?.toWatchHistoryItem(videoId)
if (watchHistoryItem != null) {
DatabaseHelper.addToWatchHistory(watchHistoryItem)
}
}
}
}
}
@ -95,7 +104,11 @@ open class OfflinePlayerService : AbstractPlayerService() {
if (watchPositionsEnabled) {
DatabaseHelper.getWatchPosition(videoId)?.let {
if (!DatabaseHelper.isVideoWatched(it, downloadWithItems.download.duration)) exoPlayer?.seekTo(it)
if (!DatabaseHelper.isVideoWatched(
it,
downloadWithItems.download.duration
)
) exoPlayer?.seekTo(it)
}
}
}