change color of color source based on album art

This commit is contained in:
Octopus Octopus 2025-02-24 20:26:37 -06:00
parent 792a6ac4a1
commit 4e4c6b3d69
1 changed files with 20 additions and 7 deletions

27
main.go
View File

@ -12,12 +12,10 @@ import (
) )
/* /*
TODO: TODO:
1. Transition effect when swapping songs
1. Color backdrop to album cover (some sort of sampling?) 2. Has/Get code in parse could probably be done with an interface instead? (is it worth it?)
2. Transition effect when swapping songs 3. Document functions
3. Has/Get code in parse could probably be done with an interface instead? (is it worth it?)
4. Document functions
*/ */
var password string var password string
@ -77,7 +75,19 @@ func main() {
} }
art, err := retrieveArt(path) art, err := retrieveArt(path)
if err != nil {
log.Fatal(err)
}
artFile, err := writeArtFile(art) artFile, err := writeArtFile(art)
if err != nil {
log.Printf("could not parse the art file, using default.jpg unprocessed.")
artFile = "./default.jpg"
}
color, err := processBGColor(artFile)
if err != nil {
log.Printf("Could not determine color, setting to default color.\n%v", err)
color = 0xff424242
}
for i := range scil.SceneItems { for i := range scil.SceneItems {
if scil.SceneItems[i].SourceName == "Artist" { if scil.SceneItems[i].SourceName == "Artist" {
updateItem(client, scil.SceneItems[i], artist, "text") updateItem(client, scil.SceneItems[i], artist, "text")
@ -91,6 +101,9 @@ func main() {
if scil.SceneItems[i].SourceName == "Art" { if scil.SceneItems[i].SourceName == "Art" {
updateItem(client, scil.SceneItems[i], artFile, "file") updateItem(client, scil.SceneItems[i], artFile, "file")
} }
if scil.SceneItems[i].SourceName == "Color" {
updateItem(client, scil.SceneItems[i], color, "color")
}
} }
} }
time.Sleep(time.Duration(sleepTime) * time.Second) time.Sleep(time.Duration(sleepTime) * time.Second)
@ -98,7 +111,7 @@ func main() {
} }
} }
func updateItem(client *goobs.Client, sI *typedefs.SceneItem, value string, key string) { func updateItem(client *goobs.Client, sI *typedefs.SceneItem, value any, key string) {
params := inputs.NewSetInputSettingsParams().WithInputName(sI.SourceName).WithInputUuid(sI.SourceUuid) params := inputs.NewSetInputSettingsParams().WithInputName(sI.SourceName).WithInputUuid(sI.SourceUuid)
params.InputSettings = make(map[string]any) params.InputSettings = make(map[string]any)
params.InputSettings[key] = value params.InputSettings[key] = value