Improve LoadableSource implementation

This commit is contained in:
nemunaire 2024-10-09 09:02:32 +02:00
commit 207a4562e6
4 changed files with 31 additions and 25 deletions

View file

@ -1,6 +1,8 @@
package sources
import ()
import (
"encoding/json"
)
var (
LoadableSources = map[string]LoadaleSource{}
@ -19,4 +21,17 @@ type PlayingSource interface {
CurrentlyPlaying() string
}
type LoadaleSource func(map[string]string) (SoundSource, error)
type LoadaleSource struct {
LoadSource func(map[string]interface{}) (SoundSource, error)
Description string
SourceDefinition interface{}
}
func Unmarshal(in map[string]interface{}, out interface{}) error {
jin, err := json.Marshal(in)
if err != nil {
return err
}
return json.Unmarshal(jin, out)
}