mpd

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParse                = errors.New("parse error")
	ErrParseNoStartResponse = fmt.Errorf("%w: no start response", ErrParse)
	ErrParseNoEndResponse   = fmt.Errorf("%w: no end response", ErrParse)
	ErrParseNoKey           = fmt.Errorf("%w: no key and colon", ErrParse)
)

parser errors.

View Source
var (
	// ErrClosed is returned when connection is closed by client.
	ErrClosed = errors.New("mpd: connection closed")
)

Functions

func CommandListEqual added in v0.12.0

func CommandListEqual(a, b *CommandList) bool

CommandListEqual compares command list a and b.

Types

type AckError added in v0.10.3

type AckError int

AckError is the numeric value in CommandError.

const (
	ErrNotList AckError = 1

	ErrArg        AckError = 2
	ErrPassword   AckError = 3
	ErrPermission AckError = 4
	ErrUnknown    AckError = 5

	ErrNoExist       AckError = 50
	ErrPlaylistMax   AckError = 51
	ErrSystem        AckError = 52
	ErrPlaylistLoad  AckError = 53
	ErrUpdateAlready AckError = 54
	ErrPlayerSync    AckError = 55
	ErrExist         AckError = 56
)

Predefined error codes in https://github.com/MusicPlayerDaemon/MPD/blob/master/src/protocol/Ack.hxx

func (AckError) Error added in v0.10.3

func (a AckError) Error() string

type Client

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

Client is a mpd client.

func Dial added in v0.11.0

func Dial(proto, addr string, opts *ClientOptions) (*Client, error)

Dial connects to mpd server.

func (*Client) AlbumArt

func (c *Client) AlbumArt(ctx context.Context, uri string) ([]byte, error)

AlbumArt locates album art for the given song.

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close closes mpd connection.

func (*Client) Commands added in v0.8.0

func (c *Client) Commands(ctx context.Context) ([]string, error)

Commands returns which commands the current user has access to.

func (*Client) Config

func (c *Client) Config(ctx context.Context) (map[string]string, error)

Config dumps configuration values that may be interesting for the client. This command is only permitted to “local” clients (connected via local socket).

func (*Client) Consume

func (c *Client) Consume(ctx context.Context, state bool) error

Consume sets consume state.

func (*Client) Crossfade

func (c *Client) Crossfade(ctx context.Context, t time.Duration) error

Crossfade sets crossfading between song

func (*Client) CurrentSong

func (c *Client) CurrentSong(ctx context.Context) (map[string][]string, error)

CurrentSong displays the song info of the current song

func (*Client) DisableOutput

func (c *Client) DisableOutput(ctx context.Context, id string) error

DisableOutput turns an output off.

func (*Client) EnableOutput

func (c *Client) EnableOutput(ctx context.Context, id string) error

EnableOutput turns an output on.

func (*Client) ExecCommandList added in v0.8.0

func (c *Client) ExecCommandList(ctx context.Context, cl *CommandList) error

ExecCommandList executes commandlist.

func (*Client) ListAllInfo

func (c *Client) ListAllInfo(ctx context.Context, uri string) ([]map[string][]string, error)

ListAllInfo lists all songs and directories in uri.

func (*Client) ListMounts added in v0.10.0

func (c *Client) ListMounts(ctx context.Context) ([]map[string]string, error)

ListMounts queries a list of all mounts.

func (*Client) ListNeighbors added in v0.12.0

func (c *Client) ListNeighbors(ctx context.Context) ([]map[string]string, error)

ListNeighbors queries a list of “neighbors” (e.g. accessible file servers on the local net).

func (*Client) Mount added in v0.10.0

func (c *Client) Mount(ctx context.Context, path, url string) error

Mount the specified storage uri at the given path.

func (*Client) Next

func (c *Client) Next(ctx context.Context) error

Next plays next song in the playlist.

func (*Client) OneShot

func (c *Client) OneShot(ctx context.Context) error

OneShot sets single state to oneshot.

func (*Client) OutputSet added in v0.9.0

func (c *Client) OutputSet(ctx context.Context, id, name, value string) error

OutputSet sets a runtime attribute.

func (*Client) Outputs

func (c *Client) Outputs(ctx context.Context) ([]*Output, error)

Outputs shows information about all outputs.

func (*Client) Pause

func (c *Client) Pause(ctx context.Context, state bool) error

Pause toggles pause/resumes playing

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping tests connection.

func (*Client) Play

func (c *Client) Play(ctx context.Context, pos int) error

Play Begins playing the playlist at song number pos

func (*Client) PlaylistInfo

func (c *Client) PlaylistInfo(ctx context.Context) ([]map[string][]string, error)

PlaylistInfo displays a list of all songs in the playlist.

func (*Client) Previous

func (c *Client) Previous(ctx context.Context) error

Previous plays next song in the playlist.

func (*Client) Random

func (c *Client) Random(ctx context.Context, state bool) error

Random sets random state.

func (*Client) ReadPicture added in v0.11.0

func (c *Client) ReadPicture(ctx context.Context, uri string) ([]byte, error)

ReadPicture locates picture for the given song. If song has no picture, returns nil, nil.

func (*Client) Repeat

func (c *Client) Repeat(ctx context.Context, state bool) error

Repeat sets repeat state.

func (*Client) ReplayGainMode added in v0.8.0

func (c *Client) ReplayGainMode(ctx context.Context, mode string) error

ReplayGainMode sets the replay gain mode.

func (*Client) ReplayGainStatus added in v0.8.0

func (c *Client) ReplayGainStatus(ctx context.Context) (map[string]string, error)

ReplayGainStatus prints replay gain options.

func (*Client) SeekCur

func (c *Client) SeekCur(ctx context.Context, t float64) error

SeekCur seeks to the position t within the current song

func (*Client) SetVol

func (c *Client) SetVol(ctx context.Context, vol int) error

SetVol sets the volume to vol.

func (*Client) Single

func (c *Client) Single(ctx context.Context, state bool) error

Single sets single state.

func (*Client) Stats

func (c *Client) Stats(ctx context.Context) (map[string]string, error)

Stats displays statistics.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (map[string]string, error)

Status reports the current status of the player and the volume level.

func (*Client) Unmount added in v0.10.0

func (c *Client) Unmount(ctx context.Context, path string) error

Unmount the specified path.

func (*Client) Update

func (c *Client) Update(ctx context.Context, uri string) (map[string]string, error)

Update updates the music database.

func (*Client) Version

func (c *Client) Version() string

Version returns mpd server version.

type ClientOptions added in v0.11.0

type ClientOptions struct {
	Password string
	// Timeout is the maximum amount of time a dial will wait for a connect to complete.
	Timeout              time.Duration
	HealthCheckInterval  time.Duration
	ReconnectionInterval time.Duration
	// BinaryLimit sets maximum binary response size.
	BinaryLimit int
	// CacheCommandsResult caches mpd command "commands" result
	CacheCommandsResult bool
}

ClientOptions contains options for mpd client connection.

type CommandError

type CommandError struct {
	ID      AckError
	Index   int
	Command string
	Message string
}

CommandError represents mpd command error.

func (*CommandError) Error

func (f *CommandError) Error() string

func (*CommandError) Is added in v0.10.3

func (f *CommandError) Is(target error) bool

Is returns true if pointer or all values are same.

func (*CommandError) Unwrap added in v0.10.3

func (f *CommandError) Unwrap() error

Unwrap returns AckError.

type CommandList

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

CommandList represents Client commandlist.

func (*CommandList) Add

func (cl *CommandList) Add(uri string)

Add adds uri to playlist.

func (*CommandList) Clear

func (cl *CommandList) Clear()

Clear clears playlist

func (*CommandList) Play

func (cl *CommandList) Play(pos int)

Play begins playing the playlist at song number pos.

type Config added in v0.8.0

type Config struct {
	MusicDirectory string
	AudioOutputs   []*ConfigAudioOutput
}

Config represents MPD config struct

func ParseConfig added in v0.8.0

func ParseConfig(file string) (*Config, error)

ParseConfig parses mpd.conf

type ConfigAudioOutput added in v0.8.0

type ConfigAudioOutput struct {
	Type string
	Name string
	Port string
}

ConfigAudioOutput represents MPD audio_output struct.

type Output added in v0.9.0

type Output struct {
	ID         string
	Name       string
	Enabled    bool
	Plugin     string
	Attributes map[string]string
}

Output represents mpd output struct.

type Watcher

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

Watcher is the mpd idle command watcher.

func NewWatcher added in v0.11.0

func NewWatcher(proto, addr string, opts *WatcherOptions) (*Watcher, error)

NewWatcher connects to mpd server

func (*Watcher) Close

func (w *Watcher) Close(ctx context.Context) error

Close closes connection

func (*Watcher) Event added in v0.8.0

func (w *Watcher) Event() <-chan string

Event returns event channel which sends idle command outputs.

type WatcherOptions added in v0.11.0

type WatcherOptions struct {
	Password             string
	Timeout              time.Duration
	ReconnectionInterval time.Duration
	// SubSystems are list of recieve events. Watcher recieves all events if SubSystems are empty.
	SubSystems []string
}

WatcherOptions contains options for mpd idle command connection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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