mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-18 21:36:42 +00:00
fix: take user's threshold when calculating post credit scene
This commit is contained in:
parent
a0ee80d9f8
commit
4d811c2071
1 changed files with 25 additions and 4 deletions
|
|
@ -39,11 +39,32 @@ object PlayerNextEpisodeRules {
|
|||
val latestOutroEndMs = (outroSegments.maxOf { it.endTime } * 1_000.0).toLong()
|
||||
val postOutroGapMs = durationMs - latestOutroEndMs
|
||||
|
||||
return if (postOutroGapMs > POST_OUTRO_AUTOPLAY_GAP_MS) {
|
||||
// Post-credits scene: hold prompt until video truly ends.
|
||||
positionMs >= durationMs - END_OF_VIDEO_EPSILON_MS
|
||||
// Calculate the user's configured threshold as milliseconds from end.
|
||||
val userThresholdMs = when (thresholdMode) {
|
||||
NextEpisodeThresholdMode.PERCENTAGE -> {
|
||||
val clampedPercent = thresholdPercent.coerceIn(97f, 100f)
|
||||
((1.0 - clampedPercent / 100.0) * durationMs).toLong()
|
||||
}
|
||||
NextEpisodeThresholdMode.MINUTES_BEFORE_END -> {
|
||||
val clampedMinutes = thresholdMinutesBeforeEnd.coerceIn(0f, 3.5f)
|
||||
(clampedMinutes * 60_000f).toLong()
|
||||
}
|
||||
}
|
||||
|
||||
return if (postOutroGapMs > userThresholdMs) {
|
||||
when (thresholdMode) {
|
||||
NextEpisodeThresholdMode.PERCENTAGE -> {
|
||||
val clampedPercent = thresholdPercent.coerceIn(97f, 100f)
|
||||
(positionMs.toDouble() / durationMs.toDouble()) >= (clampedPercent / 100.0)
|
||||
}
|
||||
NextEpisodeThresholdMode.MINUTES_BEFORE_END -> {
|
||||
val clampedMinutes = thresholdMinutesBeforeEnd.coerceIn(0f, 3.5f)
|
||||
val remainingMs = durationMs - positionMs
|
||||
remainingMs <= (clampedMinutes * 60_000f).toLong()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No post-credits scene: fire as soon as the earliest outro starts.
|
||||
// Outro ends close to the file end — fire at earliest outro start.
|
||||
positionMs / 1_000.0 >= outroSegments.minOf { it.startTime }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue