gofin/main.go

33 lines
678 B
Go
Raw Normal View History

2024-02-16 10:42:14 -04:00
package main
2024-02-16 09:33:31 -04:00
2024-02-16 12:15:25 -04:00
import (
"bytes"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
"github.com/ebitengine/oto/v3"
"os"
)
2024-02-16 09:33:31 -04:00
func main() {
2024-02-16 10:07:47 -04:00
var a = app.New()
2024-02-16 12:15:25 -04:00
var btn = widget.NewButton("Play", func() {
var b, _ = os.ReadFile("sample.wav")
// create reader from bytes
var reader = bytes.NewReader(b)
var ctxOptions = oto.NewContextOptions{
SampleRate: 44100,
ChannelCount: 2,
Format: oto.FormatSignedInt16LE,
BufferSize: 0,
}
var ctx, ready, _ = oto.NewContext(&ctxOptions)
<-ready // Wait for the context to be ready
var player = ctx.NewPlayer(reader)
player.Play()
},
)
var w = a.NewWindow("Hello")
w.SetContent(btn)
w.ShowAndRun()
2024-02-16 09:33:31 -04:00
}