Skip to content

Commit

Permalink
Merge pull request #7041 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: add offline played videos to watch history too
  • Loading branch information
Bnyro authored Jan 29, 2025
2 parents 0cf7abb + 5a6a13c commit 2eaeaa9
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
}

Expand Down Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 2eaeaa9

Please sign in to comment.