mpd v0.1.0 Mpd.Player View Source

The Mpd.Player genserver can be used to monitor the player's states. It contains the current playing song and the player status and listens to idles to update itself when it changes.

You can add the Player to you Application's supervisor or start manually like

Mpd.Player.start_link([])

Then you can play around with your mpd server and check it's current state with Mpd.Player.state/0

Events

When starting the process, you can give an on_update argument as a function. This function will be called on every player changes.

You could then use it with Phoenix's broadcast/subscribe:

Mpd.Player.start_link([on_update: fn state ->
  MyAppWeb.Endpoint.broadcast("mpd:update", state)
end)])

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the genserver linked

Gets the player's state

Force the player to update it's state with the mpd server

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

handle_change(idle, state)

View Source

Specs

start_link(any()) :: :ignore | {:error, any()} | {:ok, pid()}

Starts the genserver linked

Specs

state() :: Mpd.Player.State.t()

Gets the player's state

Specs

update() :: :ok

Force the player to update it's state with the mpd server