Yokan / rebuild
Course 1 8624561

PlayerPositionPolicy.kt

composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/ui/screens/player/PlayerPositionPolicy.kt

implementation35 lines
1package eu.friedcutlet.yokan.ui.screens.player23internal fun savedVideoPositionMs(4    lastPageRead: String,5    isRead: Boolean,6    incognitoMode: Boolean,7): Long {8    if (isRead || incognitoMode) return 0L9    return lastPageRead.toLongOrNull()?.coerceAtLeast(0L) ?: 0L10}1112internal fun shouldSaveVideoPosition(13    isRead: Boolean,14    incognitoMode: Boolean,15    positionMs: Long,16): Boolean = !isRead && !incognitoMode && positionMs > 0L1718internal fun isVideoPositionComplete(19    positionMs: Long,20    durationMs: Long,21    seenThresholdPercent: Int,22): Boolean {23    if (durationMs <= 0L || positionMs <= 0L) return false24    val percent = ((positionMs.toDouble() / durationMs.toDouble()) * 100.0)25        .toInt().coerceIn(0, 100)26    return percent >= seenThresholdPercent27}2829internal data class VideoHandoff(30    val startPositionMs: Long,31    val autoplay: Boolean,32)3334internal fun qualityVideoHandoff(currentPositionMs: Long, isPlaying: Boolean): VideoHandoff =35    VideoHandoff(currentPositionMs.coerceAtLeast(0L), isPlaying)36

Search chapters, reference and source filenames.