go-roflcopter/roflcopter/roflcopter.go

33 lines
567 B
Go
Raw Normal View History

2021-12-12 02:12:56 +03:00
package roflcopter
import (
"bytes"
_ "embed"
"fmt"
"io"
"log"
"sync"
"time"
"github.com/faiface/beep/mp3"
"github.com/faiface/beep/speaker"
)
//go:embed embed\swah.mp3
var swah []byte
func Sound(wg *sync.WaitGroup) {
wg.Add(1)
fmt.Println("SWAH")
t := 1*time.Second + 390*time.Millisecond
streamer, format, err := mp3.Decode(io.NopCloser(bytes.NewReader(swah)))
if err != nil {
log.Fatal(err)
}
defer streamer.Close()
speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
speaker.Play(streamer)
time.Sleep(t * 1)
wg.Done()
}