Skip to content

Commit 81e1ed8

Browse files
committed
fixes
1 parent d5d2c1b commit 81e1ed8

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

composeApp/src/commonMain/kotlin/neth/iecal/trease/ui/components/TreeGrowthPlayer.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import neth.iecal.trease.PlatformVideoPlayer
3030
import neth.iecal.trease.models.TimerStatus
3131
import neth.iecal.trease.models.TreeData
3232
import neth.iecal.trease.utils.getCachedVideoPath
33+
import neth.iecal.trease.utils.mmssToSeconds
3334
import neth.iecal.trease.viewmodels.HomeScreenViewModel
3435

3536
// Helper for animation state
@@ -72,12 +73,11 @@ fun TreeGrowthPlayer(
7273
statePlayer.play()
7374
delay(600) // Let engine warm up
7475

75-
val videoDurationMs = 30_000L // 30 seconds
76+
val videoDurationMs = mmssToSeconds(statePlayer.durationText) * 1000
7677
val targetDurationMs = (selectedMinutes ?: 1) * 60_000L // e.g., 25 mins -> 1,500,000ms
77-
7878
val stretchFactor = (targetDurationMs.toDouble() / videoDurationMs).coerceAtLeast(1.0)
7979

80-
val playChunk = 200L
80+
val playChunk = 50L
8181
// Formula: TotalStepTime = Play * Factor. Pause = Total - Play.
8282
val pauseChunk = ((playChunk * stretchFactor) - playChunk).toLong().coerceAtLeast(0L)
8383

composeApp/src/commonMain/kotlin/neth/iecal/trease/utils/Misc.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ fun randomBiased(y: Int, bias: Double = 1.0): Int {
1313
return ((biased * y).toInt())
1414
.coerceIn(0, y - 1)
1515
}
16-
16+
fun mmssToSeconds(time: String): Int {
17+
val (mm, ss) = time.split(":").map { it.toInt() }
18+
return mm * 60 + ss
19+
}

0 commit comments

Comments
 (0)