mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
Merge pull request #7061 from FineFindus/fix/save-watch-position-on-playback-end
fix(player): save watch position on playback end
This commit is contained in:
commit
523a2879be
@ -68,9 +68,6 @@ object DatabaseHelper {
|
||||
getWatchPosition(videoId)
|
||||
}
|
||||
|
||||
fun isVideoWatchedBlocking(videoId: String, duration: Long) =
|
||||
runBlocking { isVideoWatched(videoId, duration) }
|
||||
|
||||
suspend fun isVideoWatched(videoId: String, duration: Long): Boolean =
|
||||
withContext(Dispatchers.IO) {
|
||||
val position = getWatchPosition(videoId) ?: return@withContext false
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user