fix watch positions

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

View File

@ -520,13 +520,17 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
// save the watch position if video isn't finished and option enabled
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 {
Database.watchPositionDao().insertAll(WatchPosition(videoId!!, exoPlayer.currentPosition))
Database.watchPositionDao().insertAll(watchPosition)
}
} else if (PlayerHelper.watchPositionsEnabled) {
// delete watch position if video has ended
Database.watchPositionDao().deleteById(videoId!!)
query {
Database.watchPositionDao().deleteById(videoId!!)
}
}
}