fix: preference to only store watch positions for video doesn't work

This commit is contained in:
Bnyro 2025-01-22 16:21:23 +01:00
parent bbe81ea053
commit 6a8de0dc6d
4 changed files with 11 additions and 3 deletions

View File

@ -166,7 +166,10 @@ object PlayerHelper {
get() = watchPositionsPref in listOf("always", "videos")
val watchPositionsAudio: Boolean
get() = watchPositionsPref == "always"
get() = watchPositionsPref in listOf("always", "audio")
val watchPositionsAny: Boolean
get() = watchPositionsVideo || watchPositionsAudio
val watchHistoryEnabled: Boolean
get() = PreferenceHelper.getBoolean(

View File

@ -313,7 +313,10 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
abstract suspend fun startPlayback()
private fun saveWatchPosition() {
if (isTransitioning || !PlayerHelper.watchPositionsVideo) return
val watchPositionsEnabled =
(PlayerHelper.watchPositionsAudio && isAudioOnlyPlayer) || (PlayerHelper.watchPositionsVideo && !isAudioOnlyPlayer)
if (isTransitioning || !watchPositionsEnabled) return
exoPlayer?.let { PlayerHelper.saveWatchPosition(it, videoId) }
}

View File

@ -141,7 +141,7 @@ class VideoOptionsBottomSheet : BaseBottomSheet() {
}
// show the mark as watched or unwatched option if watch positions are enabled
if (PlayerHelper.watchPositionsVideo || PlayerHelper.watchHistoryEnabled) {
if (PlayerHelper.watchPositionsAny || PlayerHelper.watchHistoryEnabled) {
val watchPositionEntry = runBlocking(Dispatchers.IO) {
DatabaseHolder.Database.watchPositionDao().findById(videoId)
}

View File

@ -439,12 +439,14 @@
<string-array name="watchPosition">
<item>@string/always</item>
<item>@string/videos</item>
<item>@string/audio</item>
<item>@string/never</item>
</string-array>
<string-array name="watchPositionValues">
<item>always</item>
<item>videos</item>
<item>audio</item>
<item>never</item>
</string-array>