Closed islishude closed 2 years ago
MacOS 12.2.1 Go 1.18
package main import ( "log" "os" "time" "github.com/faiface/beep" "github.com/faiface/beep/mp3" "github.com/faiface/beep/speaker" ) func main() { for i := 0; i < 10; i++ { play() } } func play() { f, err := os.Open("music.mp3") if err != nil { log.Fatal(err) } streamer, format, err := mp3.Decode(f) if err != nil { log.Fatal(err) } defer streamer.Close() _ = speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10)) done := make(chan bool) speaker.Play(beep.Seq(streamer, beep.Callback(func() { done <- true }))) <-done }
MacOS 12.2.1 Go 1.18