I have a shiny app that is kind of like a Piano keyboard. I press a button and it plays a sound. It looks something like this:
if (input$down[1] == 65){
tags$audio(src = "Low_C.wav", type = "audio/wav", autoplay = NA, controls = FALSE)}
else if(input$down[1] == 87){
tags$audio(src = "Low_C_Sharp.wav", type = "audio/wav", autoplay = NA, controls = NA)}
Every time I press 65 (letter a on my keyboard), it plays low c. But when I press 87 (letter w) it stops playing low c and plays low c sharp.
I want to be able to press 65, so that it plays low c until the end of "Low_C.wav" even if I press 87 before then end, then it should play them together.
Okay, so I figured it out and thought I'd share.
Instead of tags$audio, I used
tags$script('new Audio ("Low_C.wav").play()')
and
tags$script('new Audio ("Low_C_Sharp.wav").play()')
It can play multiple sounds at once this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With