Deactivated User
05/06/2019, 8:13 AMruwinmike
12/28/2020, 2:42 PMruwinmike
12/28/2020, 2:44 PMval tone = AudioTone.generate(1.seconds, 440.0)
val sound = tone.toSound()
sound.playAndWait { current, total ->
println("current $current and total $total")
}
But crash with
java.lang.IllegalStateException: Can't find the Android Context on the CoroutineContext. Must call withAndroidContext first
at com.soywiz.korau.sound.AndroidNativeSoundProvider.createAudioStream(AndroidNativeSoundProvider.kt:28)
at com.soywiz.korau.sound.SoundAudioStream.play(SoundAudioStream.kt:24)
at com.soywiz.korau.sound.Sound.playAndWait(Sound.kt:231)
ruwinmike
12/29/2020, 12:44 PMruwinmike
03/28/2021, 2:21 PMaiscy
05/17/2021, 6:17 AMTomasz Krakowiak
08/27/2021, 2:28 PMMisileLab
08/28/2021, 5:02 AMGleb Minaev
06/14/2025, 7:17 PMrunBlocking {
WAV.decode(Res.readBytes("files/mySound.wav"))!!.toSound().play()
}
Here Res.readBytes("files/mySound.wav")
is a usage of Compose Multiplatform Resources to get byte array of the sound I am playing. Despite the fact that runBlocking
finishes its work, the program still is running.