Closed drgrib closed 1 year ago
I had to create a global variable in the package to not call speaker.Init
. It would be nice to have an example of the best way to implement a simple play
function in the example code.
Here was my workaround for anyone else stuck with this:
if !initialized {
err = speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
if err != nil {
return errors.WithStack(err)
}
initialized = true
}
Thanks. I also encountered this issue. The second call to the speaker.Play() freezes.
I am trying to create the simplest possible use of
beep
by creating aPlay
function that plays an MP3 using the tutorial code. I don't need any complex controllers or resampling. I just want to play the MP3. However when I call this code with a second MP3 (or the same MP3 a second time), the code freezes at the spot I have marked in the function.How can I modify this code so that it doesn't freeze when called a second time?