Fix! grid idx handling to prevent activeIdx reset to 0 on midiPlaying - Android
This commit is contained in:
parent
640be8edb5
commit
8b171fceaf
1 changed files with 8 additions and 3 deletions
|
|
@ -424,11 +424,11 @@ actual class FMediaPlayer actual constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
val currentGrid = (currentTickPos / resolution).toLong()
|
||||
if (boundModel?.activeIndex?.value != currentGrid.toInt()) {
|
||||
boundModel?.updateActiveIndex(currentGrid)
|
||||
boundModel?.updateActiveIndexByIndex(currentGrid.toInt())
|
||||
}
|
||||
//println("C= ${currentGrid.toInt()} et shrd ${boundModel?.activeIndex?.value}")
|
||||
idx++
|
||||
}
|
||||
}
|
||||
|
|
@ -802,13 +802,18 @@ actual class FMediaPlayer actual constructor(
|
|||
private fun startSyncLoop(sharedScreenModel: SharedScreenModel) {
|
||||
syncJob?.cancel()
|
||||
syncJob = playerScope.launch(Dispatchers.Default) {
|
||||
var lastSentGrid = -1
|
||||
while (isActive) {
|
||||
if (isRunning && !isHolding) {
|
||||
val elapsedNano = System.nanoTime() - lastEventNano
|
||||
val extraTicks = (elapsedNano / (usPerTick * 1000)).toLong().coerceAtLeast(0L)
|
||||
val interpolated = (currentTickPos + extraTicks) / resolution
|
||||
val rawGrid = interpolated.toInt().coerceAtLeast(0)
|
||||
sharedScreenModel.updateActiveIndexByIndex(rawGrid)
|
||||
//sharedScreenModel.updateActiveIndexByIndex(rawGrid)
|
||||
if (interpolated.toInt() >= lastSentGrid) {
|
||||
lastSentGrid = interpolated.toInt()
|
||||
sharedScreenModel.updateActiveIndexByIndex(interpolated.toInt())
|
||||
}
|
||||
}
|
||||
delay(16)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue