Checkpoint

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:41 +01:00
1 parent 85a9ec684c
commit c5d6137fab
160 files changed
+76293 -387

No files matched your search

+34 -49
View File
@@ -9,7 +9,7 @@ import (
"periph.io/x/conn/v3/physic"
"go.maze.io/harmon/hardware"
"github.com/BeatGlow/beatglow/hardware"
)
// Player controls music playback.
@@ -25,12 +25,24 @@ type Player interface {
// Status of the player
Status() *Status
// ChangeVolume changes the relative volume of the player.
ChangeVolume(delta int) error
// SetVolume changes the volume of the player.
SetVolume(level int) error
// ToggleMute toggles mute.
ToggleMute() error
// Player controls
Play() error
Pause() error
Next() error
Previous() error
Seek(time.Duration) error
// Playlist controls.
Playlist() ([]*Track, error)
}
type AlbumArt interface {
@@ -82,11 +94,11 @@ type Status struct {
// Player instance.
Player Player
// Source format
Source AudioFormat
// Format of the stream.
Format AudioFormat
// Output format
Output AudioFormat
// Duration of the current track.
Duration time.Duration
// Elapsed time playing the current track.
Elapsed time.Duration
@@ -117,51 +129,24 @@ type Status struct {
}
func (s *Status) String() string {
return fmt.Sprintf("source=%s output=%s elapsed=%s play=%t", s.Source, s.Output, s.Elapsed, s.Playing)
return fmt.Sprintf("format=%s elapsed=%s/%d play=%t", s.Format, s.Elapsed, s.Duration, s.Playing)
}
// Track represents an audio track.
type Track struct {
// Artist is the performing artist.
Artist string
// Title of the track.
Title string
// Album the track appears on.
Album string
// Label the album is released on.
Label string
// Date the track was published.
Date time.Time
// Track number.
Track int
// Disc number.
Disc int
// Duration is the track length.
Duration time.Duration
// Format is the audio format.
Format string
// Genre names.
Genre []string
// Path is the file path of the track.
Path string
// Image is the track or album art.
Image image.Image
}
func (t *Track) String() string {
if t == nil {
return "nil"
func (s *Status) Eq(o *Status) bool {
if s == nil || o == nil {
return false
}
return fmt.Sprintf("%s - %s (%d on %s, %s)", t.Artist, t.Title, t.Track, t.Album, t.Duration)
return s.Playing == o.Playing && s.Paused == o.Paused
}
type EventObserver interface {
PlayerEvent(Event)
}
type StatusObserver interface {
StatusChanged(*Status)
}
type TrackObserver interface {
TrackChanged(Player, *Track)
}