control

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package control lets another process on the same machine read and drive a running dotamp: one JSON request per connection on a localhost port, with a token published in control.json beside the config.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRunning = errors.New("dotamp is not running")

Functions

func AlbumID

func AlbumID(a library.Album) string

func PlaylistID

func PlaylistID(p library.Playlist) string

func TrackID

func TrackID(t library.Track) string

Types

type AlbumInfo

type AlbumInfo struct {
	ID         string `json:"id"`
	Title      string `json:"title"`
	Artist     string `json:"artist"`
	Year       int    `json:"year"`
	TrackCount int    `json:"track_count"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client makes one call at a time to the player named by control.json.

func NewClient

func NewClient(path string) *Client

func (*Client) Call

func (c *Client) Call(ctx context.Context, req Request) (Reply, error)

Call sends req with the published token and returns the reply. A missing file or a dead port is ErrNotRunning.

type LaneInfo

type LaneInfo struct {
	Name    string `json:"name"`
	Waiting int    `json:"waiting"`
	Next    string `json:"next"`
}

type Player

type Player interface {
	Status() Status
	Queue() []library.Track
	QueueNames() []string // requester per queue row, "" for the DJ's own
	Lanes() []audio.Lane
	Search(ctx context.Context, q string) (library.SearchResult, []library.Playlist, error)
	AlbumTracks(ctx context.Context, id string) ([]library.Track, error)
	PlaylistTracks(ctx context.Context, id string) ([]library.Track, error)
	Play(ctx context.Context, ts []library.Track) error
	Add(ts []library.Track)
	Request(ctx context.Context, name string, ts []library.Track) (pending int, err error)
	Remove(ctx context.Context, i int) error
	Clear() int
	Next(ctx context.Context) error
	Prev(ctx context.Context) error
	TogglePause()
	Playlists(ctx context.Context) ([]library.Playlist, error)
	CreatePlaylist(ctx context.Context, name string, ts []library.Track) ([]library.Saved, error)
	AddToPlaylist(ctx context.Context, id string, ts []library.Track) error
	Notify(msg string)
}

Player is what the server drives; cmd/dotamp supplies it over the controller, engine and library.

type PlaylistInfo

type PlaylistInfo struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	TrackCount int    `json:"track_count"`
	Server     string `json:"server"`
}

type Reply

type Reply struct {
	OK     bool   `json:"ok"`
	Result any    `json:"result,omitempty"`
	Error  string `json:"error,omitempty"`
}

type Request

type Request struct {
	Token string   `json:"token"`
	Op    string   `json:"op"`
	Q     string   `json:"q,omitempty"`
	ID    string   `json:"id,omitempty"`
	IDs   []string `json:"ids,omitempty"`
	As    string   `json:"as,omitempty"`
	Name  string   `json:"name,omitempty"`
	Index *int     `json:"index,omitempty"`
}

Request is one call. Ids are typed: t:, a: or p: followed by the library's qualified id, as every listing returns them.

type Row

type Row struct {
	Index int `json:"index"`
	TrackInfo
	By string `json:"by"`
}

type SearchInfo

type SearchInfo struct {
	Tracks    []TrackInfo    `json:"tracks"`
	Albums    []AlbumInfo    `json:"albums"`
	Playlists []PlaylistInfo `json:"playlists"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server answers control requests for one running player.

func Listen

func Listen(path string, p Player) (*Server, error)

Listen binds a loopback port, publishes it with a fresh token to path (mode 0600) and serves in the background.

func (*Server) Addr

func (s *Server) Addr() string

func (*Server) Close

func (s *Server) Close() error

Close stops listening, ends calls in flight and removes the file, unless another dotamp has since published its own port there.

type Status

type Status struct {
	Playing  bool       `json:"playing"`
	Paused   bool       `json:"paused"`
	Track    *TrackInfo `json:"track,omitempty"`
	Position float64    `json:"position"` // seconds
	Index    int        `json:"index"`
	QueueLen int        `json:"queue_len"`
	Live     string     `json:"live"`
}

type TrackInfo

type TrackInfo struct {
	ID       string  `json:"id"`
	Title    string  `json:"title"`
	Artist   string  `json:"artist"`
	Album    string  `json:"album"`
	Duration float64 `json:"duration"` // seconds
}

func TrackInfoOf

func TrackInfoOf(t library.Track) TrackInfo

Jump to

Keyboard shortcuts

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