Wait user to clic play btn to allow upd position on partition

This commit is contained in:
hasinarak3@gmail.com 2026-02-17 10:58:03 +03:00
parent 7bf36f3c66
commit e02afb3580

View file

@ -119,6 +119,9 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
private val _isPlayMid = MutableStateFlow(false) private val _isPlayMid = MutableStateFlow(false)
val isPlayMid = _isPlayMid.asStateFlow() val isPlayMid = _isPlayMid.asStateFlow()
private val _canUpdPositionFromPartition = MutableStateFlow(false)
val canUpdPositionFromPartition = _canUpdPositionFromPartition.asStateFlow()
fun loadNewSong(newMidiFile: String) { fun loadNewSong(newMidiFile: String) {
_mediaPlayer?.stop() _mediaPlayer?.stop()
@ -143,6 +146,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
} }
fun togglePlayPause() { fun togglePlayPause() {
_canUpdPositionFromPartition.value=true
_mediaPlayer?.let { player -> _mediaPlayer?.let { player ->
if (_isPlay.value) { if (_isPlay.value) {
_isPlay.value = false _isPlay.value = false
@ -196,6 +200,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
var currentNoteIndex by mutableStateOf(0f) var currentNoteIndex by mutableStateOf(0f)
fun updatePositionFromPartition(index: Int, totalRow: Int) { fun updatePositionFromPartition(index: Int, totalRow: Int) {
if(_canUpdPositionFromPartition.value) { /*upd pos part only if midi on playing*/
val duration = _duration.value val duration = _duration.value
if(totalRow > 0) { if(totalRow > 0) {
currentNoteIndex = index.toFloat() currentNoteIndex = index.toFloat()
@ -204,6 +209,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
println("Shared:196 currentNoteIndex $currentNoteIndex, Index $index et curret = ${_currentPos.value}") println("Shared:196 currentNoteIndex $currentNoteIndex, Index $index et curret = ${_currentPos.value}")
} }
} }
}
fun appendData(otherData: String) { fun appendData(otherData: String) {
_nextLabel.value += otherData _nextLabel.value += otherData