fix(Player): save watch position when playback ends

This fixes an issue, where the watch position would not correctly be
saved as the fully watched video. This could occur when the last part of
a video was skipped by a sponsorblock segment.
This commit is contained in:
FineFindus 2025-02-01 09:24:51 +01:00
parent b4d7a9b8a5
commit 2a2ad88655
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B

View File

@ -94,8 +94,13 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
override fun onPlaybackStateChanged(playbackState: Int) {
super.onPlaybackStateChanged(playbackState)
if (playbackState == Player.STATE_READY) {
isTransitioning = false
when (playbackState) {
Player.STATE_ENDED -> {
exoPlayer?.let { PlayerHelper.saveWatchPosition(it, videoId) }
}
Player.STATE_READY -> {
isTransitioning = false
}
}
}
}