pms

package
v0.0.0-...-0cbbf0d Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

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

type Connection

type Connection struct {
	Host       string
	Port       string
	Password   string
	Connected  chan struct{}
	IdleEvents chan string
	// contains filtered or unexported fields
}

Connection maintains connections to an MPD server. Two separate connections are made: one for IDLE events, and another as a control connection. The IDLE connection is kept open continuously, while the control connection is allowed to time out.

This class is used by calling the Run method as a goroutine.

func NewConnection

func NewConnection(messages chan message.Message) *Connection

NewConnection returns Connection.

func (*Connection) Close

func (c *Connection) Close()

Close closes any MPD connections.

func (*Connection) Error

func (c *Connection) Error(format string, a ...interface{})

Error sends an error message on the message bus.

func (*Connection) Message

func (c *Connection) Message(format string, a ...interface{})

Message sends a message on the message bus.

func (*Connection) MpdClient

func (c *Connection) MpdClient() (*mpd.Client, error)

MpdClient pings the MPD server and returns the client object if both the IDLE connection and control connection are ready. Otherwise this function returns nil.

func (*Connection) Open

func (c *Connection) Open(host, port, password string)

Open sets the host, port, and password parameters, closes any existing connections, and asynchronously connects to MPD as long as Run() is called.

func (*Connection) Run

func (c *Connection) Run()

Run is the main goroutine of Connection. This thread will maintain an IDLE connection to the MPD server, and reconnect if the connection has errors.

type PMS

type PMS struct {
	CLI *input.CLI

	Options   *options.Options
	Sequencer *keys.Sequencer

	// MPD connection object
	Connection *Connection

	// EventList receives a signal when current songlist has been changed.
	EventList chan int

	// EventLibrary receives a signal when MPD's library has been updated and retrieved.
	EventLibrary chan int

	// EventMessage is used to display text in the statusbar.
	EventMessage chan message.Message

	// EventOption receives a signal when options have been changed.
	EventOption chan string

	// EventPlayer receives a signal when MPD's "player" status changes in an IDLE event.
	EventPlayer chan int

	// EventPlayer receives a signal when MPD's "playlist" status changes in an IDLE event.
	EventQueue chan int

	// EventPlayer receives a signal when PMS should quit.
	QuitSignal chan int
	// contains filtered or unexported fields
}

PMS is a kitchen sink of different objects, glued together as a singleton class.

func New

func New() (*PMS, error)

func (*PMS) API

func (pms *PMS) API() api.API

setupAPI creates an API object

func (*PMS) CurrentMpdClient

func (pms *PMS) CurrentMpdClient() *mpd.Client

CurrentMpdClient ensures there is a valid MPD connection, and returns the MPD client object.

func (*PMS) CurrentSonglistWidget

func (pms *PMS) CurrentSonglistWidget() api.SonglistWidget

CurrentSonglistWidget returns the current songlist.

func (*PMS) Database

func (pms *PMS) Database() *db.Instance

func (*PMS) Error

func (pms *PMS) Error(format string, a ...interface{})

func (*PMS) Execute

func (pms *PMS) Execute(cmd string)

func (*PMS) KeyInput

func (pms *PMS) KeyInput(ev *tcell.EventKey)

KeyInput receives key input signals, checks the sequencer for key bindings, and runs commands if key bindings are found.

func (*PMS) Main

func (pms *PMS) Main()

Main does (eventually) read, evaluate, print, loop

func (*PMS) Message

func (pms *PMS) Message(format string, a ...interface{})

func (*PMS) Multibar

func (pms *PMS) Multibar() api.MultibarWidget

Multibar returns the multibar widget.

func (*PMS) RunTicker

func (pms *PMS) RunTicker()

RunTicker starts a ticker that will increase the elapsed time every second.

func (*PMS) SourceConfig

func (pms *PMS) SourceConfig(reader io.Reader) error

SourceConfig reads, parses, and executes config lines.

func (*PMS) SourceConfigFile

func (pms *PMS) SourceConfigFile(path string) error

SourceConfigFile reads, parses, and executes a config file.

func (*PMS) SourceDefaultConfig

func (pms *PMS) SourceDefaultConfig() error

SourceDefaultConfig reads, parses, and executes the default config.

func (*PMS) Stylesheet

func (pms *PMS) Stylesheet() style.Stylesheet

Stylesheet returns the global stylesheet.

func (*PMS) SyncLibrary

func (pms *PMS) SyncLibrary() error

SyncLibrary retrieves the MPD library and stores it as a Songlist in the PMS.Library variable. Furthermore, the search index is opened, and if it is older than the database version, a reindex task is started.

If the Songlist or Index is cached at the correct version, that part goes untouched.

func (*PMS) SyncQueue

func (pms *PMS) SyncQueue() error

func (*PMS) UI

func (pms *PMS) UI() api.UI

UI returns the tcell UI widget.

func (*PMS) UpdateCurrentSong

func (pms *PMS) UpdateCurrentSong() error

UpdateCurrentSong stores a local copy of the currently playing song.

func (*PMS) UpdatePlayerStatus

func (pms *PMS) UpdatePlayerStatus() error

UpdatePlayerStatus populates pms.mpdStatus with data from the MPD server.

func (*PMS) Wait

func (pms *PMS) Wait()

Jump to

Keyboard shortcuts

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