first commit

This commit is contained in:
Drew Weymouth
2022-12-17 16:52:13 -08:00
parent cd1f795bb4
commit c21d7d03eb
16 changed files with 2069 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
package main
import (
"context"
"fmt"
"gomuse/backend"
"gomuse/player"
"gomuse/ui"
"net/http"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"github.com/dweymouth/go-subsonic"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
myApp := app.New()
myWindow := myApp.NewWindow("gomuse")
p := player.NewWithClientName("gomuse")
fmt.Println(p.Init())
s := &subsonic.Client{
Client: &http.Client{},
BaseUrl: "***REMOVED***",
User: "drew",
ClientName: "gomuse",
}
lm := backend.NewLibraryManager(s)
pm := backend.NewPlaybackManager(ctx, s, p)
im := backend.NewImageManager(s)
if err := s.Authenticate("***REMOVED***"); err != nil {
fmt.Printf("error authenticating: %v\n", err)
}
/*
if len(os.Args) > 1 {
// search albums by args[1] and load first matching album
log.Printf("Searching for %q\n", os.Args[1])
if res, err := s.Search3(os.Args[1], map[string]string{}); err == nil {
if len(res.Album) > 0 {
log.Println("Got album search result")
album := res.Album[0]
pm.LoadAlbum(album.ID)
}
}
}
*/
b := ui.NewBottomPanel(p, pm, im)
ag := ui.NewAlbumGrid(lm.RecentlyAddedIter(), pm, im)
c := container.NewBorder(nil, b, nil, nil, ag)
pm.OnSongChange(func(song *subsonic.Child) {
if song == nil {
myWindow.SetTitle("gomuse")
return
}
myWindow.SetTitle(song.Title)
})
myWindow.SetContent(c)
myWindow.Resize(fyne.NewSize(1350, 1000))
myWindow.Show()
myApp.Run()
cancel()
p.Destroy()
}