mpd

package
v0.0.0-...-f2f0a72 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2016 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PlaybackStop means that there is no current song.
	PlaybackStop = "stop"
	// PlaybackPlay means that there is a current song in progress.
	PlaybackPlay = "play"
	// PlaybackPause means that there is a current song, but no progress.
	PlaybackPause = "pause"
)

Variables

This section is empty.

Functions

func StateToUnicode

func StateToUnicode(state string) string

StateToUnicode converts `state` into a nicer unicode glyph.

Types

type Client

type Client struct {
	sync.Mutex

	Config    *Config
	MPD       *ReMPD
	LW        *display.LineWriter
	Status    mpd.Attrs
	CurrSong  mpd.Attrs
	Playlists []string
	Callbacks map[string][]func()
	// contains filtered or unexported fields
}

Client is a utility mpd client tailored for the ui's purposes. It draws it's status onto the window `mpd`.

func NewClient

func NewClient(cfg *Config, ctx context.Context) (*Client, error)

NewClient returns a new mpd client that offers a few incomplete, convinience methods for altering MPD's state. It also renders the current state to the "mpd" window.

func (*Client) ActiveOutput

func (cl *Client) ActiveOutput() (string, error)

ActiveOutput returns the currently selected output.

NOTE: MPD supports more than one active, but our software ignroes that.

(German software is excellent at ignoring reality.)

func (*Client) Close

func (cl *Client) Close() error

Close cancels all client operations

func (*Client) CurrentState

func (cl *Client) CurrentState() string

CurrentState returns the current state ("play", "pause" or "stop")

func (*Client) EnableRandom

func (cl *Client) EnableRandom(enable bool) error

EnableRandom sets the random state to `enable`.

func (*Client) IsRandom

func (cl *Client) IsRandom() bool

IsRandom returns true when the playback is randomized.

func (*Client) ListPlaylists

func (cl *Client) ListPlaylists() []string

ListPlaylists returns all stored playlist names.

func (*Client) LoadAndPlayPlaylist

func (cl *Client) LoadAndPlayPlaylist(name string) error

LoadAndPlayPlaylist subsitutes the queue with the stored playlist `name` and immediately starts playing it's first song.

func (*Client) Next

func (cl *Client) Next() error

Next skips to the next song in the queue.

func (*Client) Outputs

func (cl *Client) Outputs() ([]string, error)

Outputs returns a list of outputnames. The index of the names are their ids.

func (*Client) Pause

func (cl *Client) Pause() error

Pause sets the playing state to "pause" or leaves "stop".

func (*Client) Play

func (cl *Client) Play() error

Play unpauses playback or plays the first song if stopped.

func (*Client) Prev

func (cl *Client) Prev() error

Prev goes to the previous song in the queue.

func (*Client) Register

func (cl *Client) Register(signal string, action func())

Register remembers a function that will be called the idle event `signal` is received.

func (*Client) Run

func (cl *Client) Run()

Run starts the client operations by keeping the status up-to-date and drawing it on the `mpd` window.

func (*Client) Stop

func (cl *Client) Stop() error

Stop sets the state to "stop"

func (*Client) SwitchToOutput

func (cl *Client) SwitchToOutput(enableMe string) error

SwitchToOutput enables the output named bt `enableMe`.

func (*Client) TogglePlayback

func (cl *Client) TogglePlayback() error

TogglePlayback toggles between pause and play. If the state is stop, the first queued song is played.

type Config

type Config struct {
	MPDHost     string
	MPDPort     int
	DisplayHost string
	DisplayPort int
}

Config defines the connection details the mpd client will use.

type ReMPD

type ReMPD struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ReMPD is a mpd connection that automatically reconnects itself. Individual actions might still fail, but the next call is supposed to work again (after a possibly long re-connect dance).

func NewReMPD

func NewReMPD(host string, port int, ctx context.Context) *ReMPD

NewReMPD returns a new reconnector watching over `host` and `port`. It will stop re-connecting if ctx was canceled.

func (*ReMPD) Client

func (rc *ReMPD) Client() *mpd.Client

Client returns the currently valid client. If there is none, a new connection is established and the function will block until this happens.

type ReWatcher

type ReWatcher struct {
	sync.Mutex

	Events chan string
	// contains filtered or unexported fields
}

ReWatcher is like ReMPD, but re-connects a gompd.Watcher instance.

func NewReWatcher

func NewReWatcher(host string, port int, ctx context.Context, listenOn ...string) *ReWatcher

NewReWatcher returns a new ReWatcher on `host` and `port`. It will listen on all events in `listenOn`. It will stop watching when `ctx` is canceled.

func (*ReWatcher) Close

func (rw *ReWatcher) Close() error

Close shutsdown the watcher. No events will be delievered afterwards.

Jump to

Keyboard shortcuts

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