Closed zapic0 closed 6 years ago
Yes, it is possible and you don't even have to sleep for the right amount of time (which would be imprecise anyway). Just for the info, you can get the duration of an audio file by taking its streamer and calling the Len
method. That returns you back the number of samples, which you can convert to time.Duration
using the format.D
method.
A better way to achieve what you want is to use beep.Callback
. The method is nicely described in the README, so check it out there.
Thanks @faiface, my fault I didn't see the Callback doc, sorry and thanks for the library!
If I call speaker.Play() inside a loop, for example, it is just played for a little fraction of time (if I set a Sleep the sound is playing for as long as the sleep). Is there any way to know a file duration?