mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50: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)
|
getWatchPosition(videoId)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isVideoWatchedBlocking(videoId: String, duration: Long) =
|
|
||||||
runBlocking { isVideoWatched(videoId, duration) }
|
|
||||||
|
|
||||||
suspend fun isVideoWatched(videoId: String, duration: Long): Boolean =
|
suspend fun isVideoWatched(videoId: String, duration: Long): Boolean =
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
val position = getWatchPosition(videoId) ?: return@withContext false
|
val position = getWatchPosition(videoId) ?: return@withContext false
|
||||||
|
@ -94,11 +94,16 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
|
|||||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
super.onPlaybackStateChanged(playbackState)
|
super.onPlaybackStateChanged(playbackState)
|
||||||
|
|
||||||
if (playbackState == Player.STATE_READY) {
|
when (playbackState) {
|
||||||
|
Player.STATE_ENDED -> {
|
||||||
|
exoPlayer?.let { PlayerHelper.saveWatchPosition(it, videoId) }
|
||||||
|
}
|
||||||
|
Player.STATE_READY -> {
|
||||||
isTransitioning = false
|
isTransitioning = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCustomCommand(
|
override fun onCustomCommand(
|
||||||
session: MediaSession,
|
session: MediaSession,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user