Abstract main

This commit is contained in:
Isaac Shoebottom 2024-02-17 00:54:26 -04:00
parent e6c413c020
commit b0ce06efb0

28
main.go
View File

@ -1,32 +1,10 @@
package main package main
import ( import (
"bytes" "gofin/view"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
"github.com/ebitengine/oto/v3"
"os"
) )
func main() { func main() {
var a = app.New() view.CreateView()
var btn = widget.NewButton("Play", func() { view.PopulateView()
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()
} }