37 lines
669 B
Go
37 lines
669 B
Go
package main
|
|
|
|
import (
|
|
"github.com/sirupsen/logrus"
|
|
|
|
bragi "git.maze.io/go/bragi"
|
|
)
|
|
|
|
func main() {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
s := bragi.NewMPD("volumio.local:6600")
|
|
log := logrus.WithField("source", s.Name())
|
|
log.Info("created source")
|
|
for e := range s.Events() {
|
|
switch e := e.(type) {
|
|
case *bragi.ConnectedEvent:
|
|
log.Info("connected")
|
|
|
|
case *bragi.DisconnectedEvent:
|
|
log.Info("disconnected")
|
|
|
|
case *bragi.StatusEvent:
|
|
t := e.Status.Track
|
|
if t != nil {
|
|
logrus.
|
|
WithField("track", t).
|
|
WithField("file", t.Path).
|
|
Info("received track")
|
|
}
|
|
|
|
default:
|
|
log.WithField("event", e).Info("received event")
|
|
}
|
|
}
|
|
}
|