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 ¶
- type Attrs
- type Client
- func (c *Client) Add(uri string) error
- func (c *Client) AddId(uri string, pos int) (int, error)
- func (c *Client) Clear() error
- func (c *Client) Close() (err error)
- func (c *Client) CurrentSong() (Attrs, error)
- func (c *Client) Delete(start, end int) error
- func (c *Client) DeleteId(id int) error
- func (c *Client) GetFiles() (files []string, err error)
- func (c *Client) Next() error
- func (c *Client) Pause(pause bool) error
- func (c *Client) Ping() error
- func (c *Client) Play(pos int) error
- func (c *Client) PlayId(id int) error
- func (c *Client) PlaylistInfo(start, end int) (pls []Attrs, err error)
- func (c *Client) Previous() error
- func (c *Client) Seek(pos, time int) error
- func (c *Client) SeekId(id, time int) error
- func (c *Client) SetVolume(volume int) error
- func (c *Client) Status() (Attrs, error)
- func (c *Client) Stop() error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func Dial ¶
Dial connects to MPD listening on address addr (e.g. "127.0.0.1:6600") on network network (e.g. "tcp").
Example ¶
// Connect to MPD server conn, err := Dial("tcp", "localhost:6600") if err != nil { log.Fatalln(err) } defer conn.Close() line := "" line1 := "" // Loop printing the current status of MPD. for { status, err := conn.Status() if err != nil { log.Fatalln(err) } song, err := conn.CurrentSong() if err != nil { log.Fatalln(err) } if status["state"] == "play" { line1 = fmt.Sprintf("%s - %s", song["Artist"], song["Title"]) } else { line1 = fmt.Sprintf("State: %s", status["state"]) } if line != line1 { line = line1 fmt.Println(line) } time.Sleep(1e9) }
Output:
func DialAuthenticated ¶
func (*Client) AddId ¶
AddId adds the file/directory uri to playlist and returns the identity id of the song added. If pos is positive, the song is added to position pos.
func (*Client) CurrentSong ¶
CurrentSong returns information about the current song in the playlist.
func (*Client) Delete ¶
Delete deletes songs from playlist. If both start and end are positive, it deletes those at positions in range [start, end). If end is negative, it deletes the song at position start.
func (*Client) Ping ¶
Ping sends a no-op message to MPD. It's useful for keeping the connection alive.
func (*Client) Play ¶
Play starts playing the song at playlist position pos. If pos is negative, start playing at the current position in the playlist.
func (*Client) PlayId ¶
PlayId plays the song identified by id. If id is negative, start playing at the currect position in playlist.
func (*Client) PlaylistInfo ¶
PlaylistInfo returns attributes for songs in the current playlist. If both start and end are negative, it does this for all songs in playlist. If end is negative but start is positive, it does it for the song at position start. If both start and end are positive, it does it for positions in range [start, end).
func (*Client) Seek ¶
Seek seeks to the position time (in seconds) of the song at playlist position pos.
func (*Client) SeekId ¶
SeekId is identical to Seek except the song is identified by it's id (not position in playlist).