https://kotlinlang.org logo
#compose-web
Title
# compose-web
y

Yan Pujante

03/10/2024, 5:46 PM
How would I go about playing a sound (when a button is clicked for example) with compose wasm? Is there an example somewhere?
a

Arjan van Wieringen

03/10/2024, 8:15 PM
If you can access the browser apis you can use Audio API
z

zt

03/11/2024, 1:32 AM
It's very simple,
Copy code
Button(
    onClick = {
        Audio("<https://www.soundjay.com/buttons/beep-01a.wav>").play()
    }
) {
    Text("Hi")
}
y

Yan Pujante

03/11/2024, 1:36 AM
Thank you @zt. Would you know how to use a sound that would be bundled with the app (as a resource)?
t

Tobias

03/15/2024, 12:42 PM
@zt Unable to resolve “Audio”. Any dependency I need to add?
7 Views