fix watch positions

This commit is contained in:
Bnyro 2022-11-19 15:06:41 +01:00
parent 5518de4176
commit 47fccb760a

View File

@ -520,15 +520,19 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
// save the watch position if video isn't finished and option enabled // save the watch position if video isn't finished and option enabled
private fun saveWatchPosition() { private fun saveWatchPosition() {
if (PlayerHelper.watchPositionsEnabled && exoPlayer.currentPosition != exoPlayer.duration) { if (!PlayerHelper.watchPositionsEnabled) return
if (exoPlayer.currentPosition != exoPlayer.duration) {
val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition)
query { query {
Database.watchPositionDao().insertAll(WatchPosition(videoId!!, exoPlayer.currentPosition)) Database.watchPositionDao().insertAll(watchPosition)
} }
} else if (PlayerHelper.watchPositionsEnabled) { } else if (PlayerHelper.watchPositionsEnabled) {
// delete watch position if video has ended // delete watch position if video has ended
query {
Database.watchPositionDao().deleteById(videoId!!) Database.watchPositionDao().deleteById(videoId!!)
} }
} }
}
private fun checkForSegments() { private fun checkForSegments() {
if (!exoPlayer.isPlaying || !PlayerHelper.sponsorBlockEnabled) return if (!exoPlayer.isPlaying || !PlayerHelper.sponsorBlockEnabled) return