Compare commits
1 commit
15b638c93b
...
64c94b4064
| Author | SHA1 | Date | |
|---|---|---|---|
| 64c94b4064 |
4 changed files with 166 additions and 8 deletions
|
|
@ -68,6 +68,17 @@ object ScreenSolfa : Screen {
|
|||
var isScanning by remember { mutableStateOf(false) }
|
||||
var qrCodeResult by remember { mutableStateOf("Aucun code scanné") }
|
||||
|
||||
/* if (isScanning) {
|
||||
ScannerScreen(
|
||||
onScanComplete = { result ->
|
||||
qrCodeResult = result
|
||||
isScanning = false
|
||||
},
|
||||
onClose = {
|
||||
isScanning = false
|
||||
}
|
||||
)
|
||||
} else {*/
|
||||
|
||||
MainScreenWithDrawer(
|
||||
solfaScreenModel,
|
||||
|
|
@ -154,6 +165,17 @@ object ScreenSolfa : Screen {
|
|||
Text(nextLabel)
|
||||
}
|
||||
MGButton(onClick = {
|
||||
/*println("Load btn clicked")
|
||||
launchFilePicker(
|
||||
mimeTypes = arrayOf("text/plain"),
|
||||
onFileSelected = { path ->
|
||||
if (path != null) {
|
||||
println("fichier $path");
|
||||
} else {
|
||||
println("Pas de dichier")
|
||||
}
|
||||
}
|
||||
)*/
|
||||
solfaScreenModel.loadCustomFile()
|
||||
}) {
|
||||
val loadFile: String by sharedScreenModel.loadFile.collectAsState()
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ import mg.dot.feufaro.data.DrawerItem
|
|||
import mg.dot.feufaro.data.getDrawerItems
|
||||
import mg.dot.feufaro.getPlatform
|
||||
import mg.dot.feufaro.midi.MediaPlayer
|
||||
//import mg.dot.feufaro.midi.MidiPlayer
|
||||
//import mg.dot.feufaro.midi.StopMidi
|
||||
import mg.dot.feufaro.solfa.Solfa
|
||||
import mg.dot.feufaro.viewmodel.SolfaScreenModel
|
||||
import java.io.File
|
||||
|
|
@ -72,7 +74,11 @@ fun MainScreenWithDrawer(
|
|||
|
||||
|
||||
|
||||
//var isDragging by remember { mutableStateOf(false) }
|
||||
//var isPlay by remember { mutableStateOf(false) }
|
||||
//var isPos by remember { mutableStateOf(true) }
|
||||
var isPlayMid by remember { mutableStateOf(false) }
|
||||
//var currentPos by remember { mutableStateOf(0f) }
|
||||
val isPlay by sharedScreenModel.isPlay.collectAsState()
|
||||
val isPos by sharedScreenModel.isPos.collectAsState()
|
||||
var isDragging = sharedScreenModel.isDragging
|
||||
|
|
@ -84,9 +90,19 @@ var refreshTrigeer by remember { mutableStateOf(0)}
|
|||
val volumelevel by sharedScreenModel.volumeLevel.collectAsState()
|
||||
|
||||
val player = sharedScreenModel.mediaPlayer
|
||||
/*val mediaPlayer = remember(refreshTrigeer) {
|
||||
MediaPlayer(filename = midiFile, onFinished = {
|
||||
isPos = true
|
||||
isPlay = false
|
||||
currentPos = 0f
|
||||
// isPlayMid = true
|
||||
println("fin de lecture du whawyd3.mid")
|
||||
|
||||
}).apply { setVolume(volumelevel) }
|
||||
}*/
|
||||
LaunchedEffect(isPlay, isPos) {
|
||||
if (isPlay && !isPos) {
|
||||
// while (isPlay && !isPos) {
|
||||
while (true) {
|
||||
sharedScreenModel.updateProgress()
|
||||
delay(100)
|
||||
|
|
@ -94,6 +110,20 @@ LaunchedEffect(isPlay, isPos) {
|
|||
}
|
||||
}
|
||||
|
||||
/*LaunchedEffect(isPlay, isPos, mediaPlayer) {
|
||||
if (isPlay && !isPos) {
|
||||
val d = mediaPlayer.getDuration().toFloat()
|
||||
if (d > 0) duration = d
|
||||
while (isPlay && !isPos) {
|
||||
if(!isDragging) {
|
||||
val p = mediaPlayer.getCurrentPosition().toFloat()
|
||||
if (p >= 0) currentPos = p
|
||||
}
|
||||
delay(100)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
LaunchedEffect(isSearchActive) {
|
||||
if (isSearchActive) {
|
||||
focusRequester.requestFocus()
|
||||
|
|
@ -115,7 +145,12 @@ LaunchedEffect(isPlay, isPos) {
|
|||
onScannerButtonClick()
|
||||
},
|
||||
onSongSelected = { newSong ->
|
||||
// mediaPlayer?.stop()
|
||||
// isPos = true
|
||||
// isPlay = false
|
||||
// currentPos = 0f
|
||||
sharedScreenModel.loadNewSong("whawyd3.mid")
|
||||
// refreshTrigeer++
|
||||
}
|
||||
)
|
||||
}, content = {
|
||||
|
|
@ -139,7 +174,15 @@ LaunchedEffect(isPlay, isPos) {
|
|||
}) {
|
||||
Icon(Icons.Filled.Menu, contentDescription = "Ouvrir Menu")
|
||||
}
|
||||
}, actions = {
|
||||
}, actions = {/* Text(
|
||||
text = measure,
|
||||
modifier = Modifier.weight(1f, fill = false),
|
||||
fontSize = 20.sp,
|
||||
maxLines = 2,
|
||||
softWrap = false,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
Spacer(Modifier.width(8.dp))*/
|
||||
Text(
|
||||
text = songKey,
|
||||
fontSize = 25.sp,
|
||||
|
|
@ -207,6 +250,11 @@ LaunchedEffect(isPlay, isPos) {
|
|||
FloatingActionButton(
|
||||
onClick = {
|
||||
isPlayMid = !isPlayMid
|
||||
// if(isPlayMid) sharedScreenModel.stopMidi()
|
||||
// if(mediaPlayer.getCurrentPosition() != 0L) {
|
||||
// mediaPlayer?.seekTo(0)
|
||||
// mediaPlayer?.stop()
|
||||
// }
|
||||
}, modifier = Modifier.alpha(0.45f)
|
||||
) {
|
||||
Icon(
|
||||
|
|
@ -246,8 +294,45 @@ LaunchedEffect(isPlay, isPos) {
|
|||
volume = volumelevel,
|
||||
duration = duration,
|
||||
onPlayPauseClick = {
|
||||
sharedScreenModel.togglePlayPause()
|
||||
onSeek = { newPos ->
|
||||
sharedScreenModel.togglePlayPause()/*if(isPlay){
|
||||
mediaPlayer?.pause()
|
||||
isPlay = false
|
||||
isPos = true
|
||||
} else {
|
||||
if(currentPos == 0f) {
|
||||
mediaPlayer?.seekTo(0)
|
||||
}
|
||||
mediaPlayer?.play()
|
||||
mediaPlayer?.setVolume(volumelevel)
|
||||
isPlay = true
|
||||
isPos = false*/
|
||||
},
|
||||
/* if(!isPlay) {
|
||||
if (currentPos == 0f) mediaPlayer.seekTo(0)
|
||||
mediaPlayer?.play()
|
||||
isPlay = true
|
||||
isPos = false
|
||||
} else {
|
||||
mediaPlayer?.stop()
|
||||
isPlay = false
|
||||
isPos = true
|
||||
}*/
|
||||
|
||||
// println("je clique pause = ${sharedScreenModel.isPlay} play = ${sharedScreenModel.isPos}")
|
||||
// if(isPos) {
|
||||
// mediaPlayer.play()
|
||||
// isPos = false
|
||||
// } else {
|
||||
// mediaPlayer.pause()
|
||||
// isPos = true
|
||||
// }
|
||||
/*if (isPlayMid) {
|
||||
// mediaPlayer.seekTo(0f.toLong())
|
||||
mediaPlayer.play()
|
||||
isPlayMid = false
|
||||
}
|
||||
}*/
|
||||
onSeek = { newPos -> // currentPos = newPos
|
||||
sharedScreenModel.setDragging(true)
|
||||
sharedScreenModel.seekTo(newPos)
|
||||
scope.launch {
|
||||
|
|
@ -257,7 +342,7 @@ LaunchedEffect(isPlay, isPos) {
|
|||
println("DrawerUI:335: mihetsika $newPos")
|
||||
},
|
||||
mediaPlayer = player,
|
||||
onVolumeChange = { newVolume ->
|
||||
onVolumeChange = { newVolume -> // volumelevel = newVolume
|
||||
sharedScreenModel.setVolume(newVolume)
|
||||
println("Changement volume $newVolume -l $volumelevel")
|
||||
},
|
||||
|
|
@ -265,6 +350,29 @@ LaunchedEffect(isPlay, isPos) {
|
|||
} else {
|
||||
Text("Sélectionner un morceau")
|
||||
}
|
||||
/*Row(
|
||||
modifier = Modifier.align(Alignment.Center).padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Slider(
|
||||
value = currentPos,
|
||||
onValueChange = { newPos ->
|
||||
currentPos = newPos
|
||||
mediaPlayer?.seekTo(newPos.toLong())
|
||||
},
|
||||
valueRange = 0f..duration
|
||||
)
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
isPos = !isPos
|
||||
if(isPlay) mediaPlayer?.pause() else mediaPlayer?.play()
|
||||
if(isPos) mediaPlayer?.pause() else mediaPlayer?.play()
|
||||
}
|
||||
) {
|
||||
Text(if (isPos) "Pause" else "play Midi")
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -336,6 +444,13 @@ LaunchedEffect(isPlay, isPos) {
|
|||
placeholder = {
|
||||
Text("... ...")
|
||||
},
|
||||
/*leadingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Search,
|
||||
contentDescription = "Icône de recherche",
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
},*/
|
||||
textStyle = MaterialTheme.typography.titleLarge.copy(
|
||||
fontSize = 17.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
|
|
@ -381,3 +496,22 @@ LaunchedEffect(isPlay, isPos) {
|
|||
}
|
||||
})
|
||||
}
|
||||
/*
|
||||
|
||||
var isPlay by mutableStateOf(false)
|
||||
private set
|
||||
|
||||
fun playMidi() {
|
||||
if(!isPlay) {
|
||||
isPlay = true
|
||||
MidiPlayer("whawyd3.mid") {
|
||||
isPlay = false
|
||||
}
|
||||
}
|
||||
}
|
||||
fun stopMidi() {
|
||||
if(isPlay) {
|
||||
StopMidi()
|
||||
isPlay = false
|
||||
}
|
||||
}*/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.AvTimer
|
||||
import androidx.compose.material.icons.filled.Church
|
||||
import androidx.compose.material.icons.filled.Clear
|
||||
import androidx.compose.material.icons.filled.ClearAll
|
||||
|
|
@ -340,7 +339,7 @@ fun MidiControlPanel(
|
|||
onClick = {
|
||||
showBPMTools = !showBPMTools
|
||||
}) {
|
||||
Icon(imageVector = Icons.Default.AvTimer, contentDescription = "Tempo")
|
||||
Icon(imageVector = Icons.Default.MusicNote, contentDescription = "Tempo")
|
||||
}
|
||||
AnimatedVisibility(visible = showBPMTools){
|
||||
Box(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// commonMain/kotlin/mg/dot/feufaro/viewmodel/SharedScreenModel.kt
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
|
|
@ -132,6 +133,7 @@ class SharedScreenModel() : ScreenModel {
|
|||
})
|
||||
println("New media Player crée $newMidiFile")
|
||||
}
|
||||
// val mediaPlayer =
|
||||
|
||||
fun togglePlayPause() {
|
||||
_mediaPlayer?.let { player ->
|
||||
|
|
@ -149,6 +151,7 @@ class SharedScreenModel() : ScreenModel {
|
|||
}
|
||||
}
|
||||
println("128: Status de isPlay ${_isPlay.value} \nisPos ${_isPos.value} \ncurrentPos ${_currentPos.value} \n volume ${_volumeLevel.value}")
|
||||
// _isPlay.value = !_isPlay.value
|
||||
}
|
||||
}
|
||||
fun stopMidi() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue