mpd

package
v0.0.0-...-68e3b61 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2018 License: MIT, MIT Imports: 6 Imported by: 0

README

mpd

This was originally the github.com/fhs/gompd/mpd package. I have since removed most of the stuff not needed for mpdrobble.

Documentation

Overview

Package mpd provides the client side interface to MPD (Music Player Daemon). The protocol reference can be found at http://www.musicpd.org/doc/protocol/index.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attrs

type Attrs map[string]string

Attrs is a set of attributes returned by MPD.

type Client

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

Client represents a client connection to a MPD server.

func Dial

func Dial(network, addr string) (c *Client, err error)

Dial connects to MPD listening on address addr (e.g. "127.0.0.1:6600") on network network (e.g. "tcp").

func DialAuthenticated

func DialAuthenticated(network, addr, password string) (c *Client, err error)

DialAuthenticated connects to MPD listening on address addr (e.g. "127.0.0.1:6600") on network network (e.g. "tcp"). It then authenticates with MPD using the plaintext password password if it's not empty.

func (*Client) Close

func (c *Client) Close() (err error)

Close terminates the connection with MPD.

func (*Client) Command

func (c *Client) Command(format string, args ...interface{}) *Command

Command returns a command that can be sent to MPD sever. It enables low-level access to MPD protocol and should be avoided if the user is not familiar with MPD protocol.

Strings in args are automatically quoted so that spaces are preserved. Pass strings as Quoted type if this is not desired.

func (*Client) CurrentPos

func (c *Client) CurrentPos() (pos Pos, playing bool, err error)

func (*Client) CurrentSong

func (c *Client) CurrentSong() (Song, error)

CurrentSong returns information about the current song in the playlist.

func (*Client) Ping

func (c *Client) Ping() error

Ping sends a no-op message to MPD. It's useful for keeping the connection alive.

func (*Client) PlayTime

func (c *Client) PlayTime() (int, error)

func (*Client) Stats

func (c *Client) Stats() (Attrs, error)

Stats displays statistics (number of artists, songs, playtime, etc)

func (*Client) Status

func (c *Client) Status() (Attrs, error)

Status returns information about the current status of MPD.

type Command

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

A Command represents a MPD command.

func (*Command) Attrs

func (cmd *Command) Attrs() (Attrs, error)

Attrs sends command to server and reads attributes returned in response.

func (*Command) OK

func (cmd *Command) OK() error

OK sends command to server and checks for error.

func (*Command) String

func (cmd *Command) String() string

String returns the encoded command.

func (*Command) Strings

func (cmd *Command) Strings(key string) ([]string, error)

Strings sends command to server and reads a list of strings returned in response. Each string have the key key.

type Pos

type Pos struct {
	Percent float64
	Seconds int // how much we listened of it
	Length  int // total track length
}

type Quoted

type Quoted string

Quoted is a string that do no need to be quoted.

type Song

type Song struct {
	Title       string
	Artist      string
	Album       string
	AlbumArtist string
	Track       string // tracknumber
	File        string // filename
	Duration    string // in seconds, float pt value
}

type Watcher

type Watcher struct {
	Event chan string // event channel
	Error chan error  // error channel
	// contains filtered or unexported fields
}

Watcher represents a MPD client connection that can be watched for events.

func NewWatcher

func NewWatcher(net, addr, passwd string, names ...string) (w *Watcher, err error)

NewWatcher connects to MPD server and watches for changes in subsystems names. If no subsystem is specified, all changes are reported.

See http://www.musicpd.org/doc/protocol/command_reference.html#command_idle for valid subsystem names.

func (*Watcher) Close

func (w *Watcher) Close() error

Close closes Event and Error channels, and the connection to MPD server.

func (*Watcher) Subsystems

func (w *Watcher) Subsystems(names ...string)

Subsystems interrupts watching current subsystems, consumes all outstanding values from Event and Error channels, and then changes the subsystems to watch for to names.

Jump to

Keyboard shortcuts

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