From dbaf7bdda6bd3e1bd91c0d4cf215c5de0bf8bbc1 Mon Sep 17 00:00:00 2001 From: hasina Date: Mon, 2 Feb 2026 14:20:03 +0300 Subject: [PATCH] put midi file to the app folder --- .../src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt | 9 +++++---- .../desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt index 32adb23..874c490 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt @@ -36,6 +36,7 @@ import androidx.compose.ui.platform.* import kotlinx.coroutines.* import mg.dot.feufaro.data.DrawerItem import mg.dot.feufaro.data.getDrawerItems +import mg.dot.feufaro.getConfigDirectoryPath import mg.dot.feufaro.getPlatform import mg.dot.feufaro.midi.MediaPlayer import mg.dot.feufaro.solfa.Solfa @@ -78,7 +79,7 @@ val isPos by sharedScreenModel.isPos.collectAsState() var isDragging = sharedScreenModel.isDragging val currentPos by sharedScreenModel.currentPos.collectAsState() val duration by sharedScreenModel.duration.collectAsState() -var midiFile = "whawyd3.mid" +val midiFile = "whawyd3.mid" var refreshTrigeer by remember { mutableStateOf(0)} val volumelevel by sharedScreenModel.volumeLevel.collectAsState() @@ -99,7 +100,7 @@ LaunchedEffect(isPlay, isPos) { } } LaunchedEffect(Unit) { - sharedScreenModel.loadNewSong("whawyd3.mid") + sharedScreenModel.loadNewSong("${getConfigDirectoryPath()}$midiFile") } ModalNavigationDrawer(drawerState = drawerState, drawerContent = { SimpleDrawerContent( @@ -114,7 +115,7 @@ LaunchedEffect(isPlay, isPos) { onScannerButtonClick() }, onSongSelected = { newSong -> - sharedScreenModel.loadNewSong("whawyd3.mid") + sharedScreenModel.loadNewSong("${getConfigDirectoryPath()}$midiFile") } ) }, content = { @@ -223,7 +224,7 @@ LaunchedEffect(isPlay, isPos) { onClick = { isExpanded = !isExpanded refreshTrigeer++ - sharedScreenModel.loadNewSong("whawyd3.mid") + sharedScreenModel.loadNewSong("${getConfigDirectoryPath()}$midiFile") }, modifier = Modifier.alpha(0.45f) ) { Icon( diff --git a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt index 771e54e..212b546 100644 --- a/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt +++ b/composeApp/src/desktopMain/kotlin/mg/dot/feufaro/midi/MidiPlayer.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.delay import kotlinx.coroutines.launch import mg.dot.feufaro.FileRepository +import mg.dot.feufaro.getConfigDirectoryPath import java.io.ByteArrayInputStream import java.io.File import java.util.prefs.Preferences @@ -67,6 +68,10 @@ actual class MediaPlayer actual constructor( onFinished() } } + } else { + // Créeons une fichier vide au 1er lancement de l'application, après MidiWriterKotlin l'écrasera + val f0file = File("${getConfigDirectoryPath()}whawyd3.mid") + f0file.createNewFile() } }