mpd

package
v0.0.0-...-a141a25 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2013 License: MIT Imports: 4 Imported by: 0

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attrs

type Attrs map[string]string

type Client

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

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").

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 DialAuthenticated(network, addr, password string) (c *Client, err error)

func (*Client) Add

func (c *Client) Add(uri string) error

Add adds the file/directory uri to playlist. Directories add recursively.

func (*Client) AddId

func (c *Client) AddId(uri string, pos int) (int, error)

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) Clear

func (c *Client) Clear() error

Clear clears the current playlist.

func (*Client) Close

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

Close terminates the connection with MPD.

func (*Client) CurrentSong

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

CurrentSong returns information about the current song in the playlist.

func (*Client) Delete

func (c *Client) Delete(start, end int) error

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) DeleteId

func (c *Client) DeleteId(id int) error

DeleteId deletes the song identified by id.

func (*Client) GetFiles

func (c *Client) GetFiles() (files []string, err error)

Retrieve the entire list of files

func (*Client) Next

func (c *Client) Next() error

Next plays next song in the playlist.

func (*Client) Pause

func (c *Client) Pause(pause bool) error

Pause pauses playback if pause is true; resumes playback otherwise.

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) Play

func (c *Client) Play(pos int) error

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

func (c *Client) PlayId(id int) error

PlayId plays the song identified by id. If id is negative, start playing at the currect position in playlist.

func (*Client) PlaylistInfo

func (c *Client) PlaylistInfo(start, end int) (pls []Attrs, err error)

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) Previous

func (c *Client) Previous() error

Previous plays previous song in the playlist.

func (*Client) Seek

func (c *Client) Seek(pos, time int) error

Seek seeks to the position time (in seconds) of the song at playlist position pos.

func (*Client) SeekId

func (c *Client) SeekId(id, time int) error

SeekId is identical to Seek except the song is identified by it's id (not position in playlist).

func (*Client) SetVolume

func (c *Client) SetVolume(volume int) error

func (*Client) Status

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

Status returns information about the current status of MPD.

func (*Client) Stop

func (c *Client) Stop() error

Stop stops playback.

Jump to

Keyboard shortcuts

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