core

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	ID       string     `json:"id"`
	Name     string     `json:"name"`
	Type     DeviceType `json:"type"`
	Platform Platform   `json:"platform"`
	IsActive bool       `json:"is_active"`
	Account  string     `json:"account"`
}

Device represents a playback device.

type DeviceType

type DeviceType string

DeviceType indicates the kind of playback device.

const (
	DeviceTypeSpeaker  DeviceType = "speaker"
	DeviceTypeComputer DeviceType = "computer"
	DeviceTypePhone    DeviceType = "phone"
	DeviceTypeTV       DeviceType = "tv"
	DeviceTypeSoundbar DeviceType = "soundbar"
)

type Platform

type Platform string

Platform indicates the device's platform.

const (
	PlatformSpotify Platform = "spotify"
	PlatformSonos   Platform = "sonos"
)

type PlaybackState

type PlaybackState struct {
	Track     *Track        `json:"track"`
	Device    *Device       `json:"device"`
	Account   string        `json:"account"`
	IsPlaying bool          `json:"is_playing"`
	Progress  time.Duration `json:"progress"`
	Volume    int           `json:"volume"`
}

PlaybackState represents the current playback state.

func (*PlaybackState) HasTrack

func (s *PlaybackState) HasTrack() bool

HasTrack returns true if there is an active track.

func (*PlaybackState) ProgressPercent

func (s *PlaybackState) ProgressPercent() float64

ProgressPercent returns playback progress as a percentage (0-100).

type Player

type Player interface {
	// Playback control
	Play(ctx context.Context) error
	Pause(ctx context.Context) error
	Next(ctx context.Context) error
	Prev(ctx context.Context) error
	Seek(ctx context.Context, positionMs int) error

	// Volume control
	Volume(ctx context.Context, percent int) error

	// State queries
	GetState(ctx context.Context) (*PlaybackState, error)
	GetQueue(ctx context.Context) (*Queue, error)

	// Queue manipulation
	AddToQueue(ctx context.Context, trackURI string) error
}

Player defines the interface for music playback control.

type Queue

type Queue struct {
	Tracks       []Track `json:"tracks"`
	CurrentIndex int     `json:"current_index"`
}

Queue represents a playback queue.

func (*Queue) Current

func (q *Queue) Current() *Track

Current returns the currently playing track, or nil if the queue is empty.

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

IsEmpty returns true if the queue has no tracks.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the total number of tracks in the queue.

func (*Queue) Upcoming

func (q *Queue) Upcoming() []Track

Upcoming returns tracks after the current position.

type Source

type Source string

Source indicates the origin platform of a track.

const (
	SourceSpotify Source = "spotify"
	SourceSonos   Source = "sonos"
)

type Track

type Track struct {
	ID       string        `json:"id"`
	URI      string        `json:"uri"`
	Title    string        `json:"title"`
	Artist   string        `json:"artist"`
	Artists  []string      `json:"artists"`
	Album    string        `json:"album"`
	Duration time.Duration `json:"duration"`
	Source   Source        `json:"source"`
}

Track represents a playable audio track.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL