Monday, 29 November 2021

Way to stop any previously playing sounds (base64) in javascript before playing next sound

I have a javascript function that plays a particular sound from base64 plain text. What I am looking for I think is quite simple, but I am not at all familiar with js, as I'm actually using js in R as part of a shiny app. I am simply looking for a way that when this function is called, it will cancel any previously playing sound from the same or a similar function that might already be playing:

shinyjs.soundmaker = function() {
  var snd = new Audio("data:audio/wav;base64,blablablabla");
  snd.play();
}

Any help would be great!



from Way to stop any previously playing sounds (base64) in javascript before playing next sound

No comments:

Post a Comment