From 9f907d34b5b0a68d6304e029880999d91ddfd18e Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 7 Jul 2022 15:58:51 +0200 Subject: [PATCH] fix watch positions --- .../com/github/libretube/fragments/PlayerFragment.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 94338f2de..b211e483c 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -514,14 +514,16 @@ class PlayerFragment : Fragment() { private fun seekToWatchPosition() { // seek to saved watch position if available val watchPositions = PreferenceHelper.getWatchPositions(requireContext()) + var position: Long? = null watchPositions.forEach { - if (it.videoId == videoId) exoPlayer.seekTo(it.position) + if (it.videoId == videoId) position = it.position } // support for time stamped links - if (arguments?.getLong("timeStamp") != null) { - val position = arguments?.getLong("timeStamp")!! * 1000 - exoPlayer.seekTo(position) + val timeStamp: Long? = arguments?.getLong("timeStamp") + if (timeStamp != null && timeStamp != 0L) { + position = timeStamp * 1000 } + if (position != null) exoPlayer.seekTo(position!!) } // the function is working recursively