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
import (
"bytes"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
"github.com/ebitengine/oto/v3"
"os"
"gofin/view"
)
func main() {
var a = app.New()
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()
view.CreateView()
view.PopulateView()
}