Wait user to clic play btn to allow upd position on partition
This commit is contained in:
parent
7bf36f3c66
commit
e02afb3580
1 changed files with 12 additions and 6 deletions
|
|
@ -119,6 +119,9 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
|||
private val _isPlayMid = MutableStateFlow(false)
|
||||
val isPlayMid = _isPlayMid.asStateFlow()
|
||||
|
||||
private val _canUpdPositionFromPartition = MutableStateFlow(false)
|
||||
val canUpdPositionFromPartition = _canUpdPositionFromPartition.asStateFlow()
|
||||
|
||||
|
||||
fun loadNewSong(newMidiFile: String) {
|
||||
_mediaPlayer?.stop()
|
||||
|
|
@ -143,6 +146,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
|||
}
|
||||
|
||||
fun togglePlayPause() {
|
||||
_canUpdPositionFromPartition.value=true
|
||||
_mediaPlayer?.let { player ->
|
||||
if (_isPlay.value) {
|
||||
_isPlay.value = false
|
||||
|
|
@ -196,6 +200,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
|||
var currentNoteIndex by mutableStateOf(0f)
|
||||
|
||||
fun updatePositionFromPartition(index: Int, totalRow: Int) {
|
||||
if(_canUpdPositionFromPartition.value) { /*upd pos part only if midi on playing*/
|
||||
val duration = _duration.value
|
||||
if(totalRow > 0) {
|
||||
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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun appendData(otherData: String) {
|
||||
_nextLabel.value += otherData
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue