diff --git a/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt b/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt index 09ec247ac..6855eaab4 100644 --- a/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt +++ b/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt @@ -13,7 +13,7 @@ interface WatchPositionDao { fun getAll(): List @Query("SELECT * FROM watchPosition WHERE videoId LIKE :videoId LIMIT 1") - fun findById(videoId: String): WatchPosition + fun findById(videoId: String): WatchPosition? @Insert(onConflict = OnConflictStrategy.REPLACE) fun insertAll(vararg watchPositions: WatchPosition) diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index daea985dd..41534f0d5 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -866,7 +866,8 @@ class PlayerFragment : BaseFragment() { var position: Long? = null Thread { try { - position = Database.watchPositionDao().findById(videoId!!).position + val watchPosition = Database.watchPositionDao().findById(videoId!!) + position = if (watchPosition != null) watchPosition.position else null // position is almost the end of the video => don't seek, start from beginning if (position!! > streams.duration!! * 1000 * 0.9) position = null } catch (e: Exception) { diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index 181d47588..ecc5d6e9d 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -1,5 +1,8 @@ package com.github.libretube.util +import android.util.Log +import com.github.libretube.extensions.TAG + object PlayingQueue { private val queue = mutableListOf() private var currentVideoId: String? = null @@ -21,6 +24,7 @@ object PlayingQueue { fun getNext(): String? { val currentIndex = queue.indexOf(currentVideoId) + Log.e(TAG(), queue.toString()) return if (currentIndex > queue.size) { null } else {