The Main MphpD class.
new MphpD(array $config = []) : MphpD
MphpD::__construct(array $options = []) : mixed
Array of options. Documentation
mixed
Return the DB instance
MphpD::db() : FloFaber\MphpD\DB
FloFaber\MphpD\DB
\DB
Return the Player instance
MphpD::player() : FloFaber\MphpD\Player
FloFaber\MphpD\Player
\Player
Return the Queue instance
MphpD::queue() : FloFaber\MphpD\Queue
FloFaber\MphpD\Queue
\Queue
Returns a Playlist instance with the given name or null if the name is empty
MphpD::playlist(string $name) : FloFaber\MphpD\Playlist
The name of the playlist. Must not be empty.
FloFaber\MphpD\Playlist
\Playlist|null
Returns a list of playlists.
MphpD::playlists(bool $metadata = ) : mixed
If true
an array
of associative arrays containing information about the playlists (like last-modified,...) will be returned.
If false
or omitted an array
containing all playlists names is returned.
mixed
array|false array
on success or false
on failure.
Return a new output instance
MphpD::output(int $id) : FloFaber\MphpD\Output
The ID of the output
FloFaber\MphpD\Output
\Output
Returns an Array of associative arrays containing all available outputs
MphpD::outputs() : mixed
mixed
array|false array
on success or false
on failure.
Return neighbors on the network like available SMB servers
MphpD::neighbors() : mixed
mixed
array|false array
on success or false
on failure.
Return a new Partition instance
MphpD::partition(string $name) : FloFaber\MphpD\Partition
The name of the partition
FloFaber\MphpD\Partition
\Partition
Return a list of all available partitions
MphpD::partitions() : mixed
mixed
array|false array
on success or false
on failure.
Return a new Channel instance
MphpD::channel(string $name = '') : FloFaber\MphpD\Channel
The name of the channel
FloFaber\MphpD\Channel
\Channel
Return a list of available channels
MphpD::channels() : mixed
mixed
array|bool array
on success or false
on failure.
Clears the current error
MphpD::clear_error() : bool
bool
bool true
on success or false
on failure.
Returns the value of the specified key(s) from MPD's status.
MphpD::status(array $items = []) : mixed
Optional. Array containing the wanted key(s) like status
, songid
,...
If only one item is given only it's value will be returned instead of an associative array.
If the given item(s) do not exist null
will be set as their value.
If omitted, an associative array
containing all status information will be returned.
mixed
array|false|int|float|null false
on error
string
, int
, float
or null
if $items
contains only one item. If it does not exist null
will be returned instead.
Otherwise, an associative array
containing all available (or specified) keys.
Returns the value of the specified key from MPD's stats.
MphpD::stats(array $items = []) : mixed
Optional. Array containing the wanted stat(s). Example: [ "artists", "uptime", "playtime" ]
If only one item is given only it's value will be returned instead of an associative array.
If the given item(s) do not exist null
will be set as their value.
If omitted, an associative array
containing all stats will be returned.
mixed
array|false|int|null Returns
false
on error
string
, int
or null
if $items contains only one item. If it does not exist null
will be returned instead.
Otherwise, an associative array
containing all available (or specified) stats.
Returns a Sticker instance
MphpD::sticker(string $type, string $uri) : FloFaber\MphpD\Sticker
FloFaber\MphpD\Sticker
\Sticker
Return a list of all mounts.
MphpD::mounts() : mixed
mixed
array|false
Mount $uri
to path
MphpD::mount(string $path, string $uri) : bool
The URI to mount
bool
bool true
on success or false
on failure.
Unmount a path
MphpD::unmount(string $path) : bool
The path to unmount
bool
bool true
on success or false
on failure.
Function to start a command-list.
MphpD::bulk_start() : mixed
mixed
void
Function to end a command-list and execute its commands. The command list is stopped in case an error occurs.
MphpD::bulk_end() : array
array
array|false array
containing the commands responses or false
on failure.
Function to abort the current command list. We can do that because we only start the list at protocol level when bulk_end() is called.
MphpD::bulk_abort() : mixed
mixed
void
Function to add a command to the bulk_list.
MphpD::bulk_add(string $cmd, array $params = [], int $mode = 32) : bool
bool
bool
Return a list of all available tag types.
MphpD::tagtypes() : mixed
mixed
array|false array
on success or false
on failure.
Disable specified tag types.
MphpD::tagtypes_disable(array $tagtypes) : bool
A list of tag types to disable.
bool
bool true
on success or false
on failure.
Enable specified tag types.
MphpD::tagtypes_enable(array $tagtypes) : bool
A list of tag types to enable.
bool
bool true
on success or false
on failure.
Remove all tag types from responses.
MphpD::tagtypes_clear() : bool
bool
bool true
on success or false
on failure.
Enable all available tag types.
MphpD::tagtypes_all() : bool
bool
bool true
on success or false
on failure.
Ping.
MphpD::ping() : bool
bool
bool true
on success or false
on failure.
Returns an associative array of configuration values. This function is only available for client connected via Unix Socket!
MphpD::config() : mixed
mixed
array|false array
containing configuration parameters on success or false
on failure.
Returns a list of all available commands.
MphpD::commands() : mixed
mixed
array|false array
on success or false
on failure.
Returns a list of all not-available commands.
MphpD::notcommands() : mixed
mixed
array|false array
on success or false
on failure.
Returns a list of all available urlhandlers. Like smb://, sftp://, http://. ..
MphpD::urlhandlers() : mixed
mixed
array|false array
on success or false
on failure.
Returns a list of available decoder plugins and their supported suffixes and mimetypes.
MphpD::decoders() : mixed
mixed
array|false array
on success or false
on failure.
Send $command
with $params
to the MPD server.
You, the library's user, are not intended to ever
need this method. If you ever need it because the library does not support
a specific command please file a bug report.
This method also parses MPDs response depending on the chosen mode.
MphpD::cmd(string $command, array $params = [], int $mode = 2, array $list_start = []) : mixed
The command
Parameters, automatically escaped
One of the following constants:
MPD_CMD_READ_NONE - Do not read anything from the answer. Returns an empty array.
MPD_CMD_READ_NORMAL - Parses the answer as a one-dimensional "key=>value" array. If a key already existed its value gets overwritten. Used for commands like "status" where only unique keys are given.
MPD_CMD_READ_GROUP - Used for parsing grouped responses like list album group albumartist
.
Example:
Albumartist: Eternal Decision
Album: E.D.III
Album: Eternal Decision
Album: Ghost in the machine
Albumartist: Black Sabbath
Album: Paranoid
Album: Reunion
Will become
[
"Eternal Decision" => [
"album" => [ "E.D.III", "Eternal Decision", "Ghost in the machine" ]
], "Black Sabbath" => [
"album" => [ "Paranoid", "Reunion" ]
]
]
MPD_CMD_READ_LIST - Parses the answer as a list of "key=>value" arrays. Used for commands like "listplaylists" where keys are not unique.
MPD_CMD_READ_LIST_SINGLE - Parses the answer into a simple "list"-array. Used for commands like "idle" where there is only a single possible "key".
If used for commands where more than a single key is possible e.g. `listplaylists` only the value of the first seen key is added to the returned list.
All other keys are ignored. In this case you probably want to use `MPD_CMD_READ_LIST`.
MPD_CMD_READ_BOOL - Parses the answer into true
on OK and list_OK and false
on ACK
.
Used for commands which do not return anything but OK or ACK.
In combination with $mode = MPD_CMD_READ_LIST
indicates on which key
a new list starts.
mixed
array|bool False on failure.
Array on success.
True on success if $mode
is MPD_CMD_READ_BOOL
.
Returns the socket resource.
MphpD::get_socket() : mixed
mixed
resource
Returns MPDs version as string
MphpD::get_version() : string
string
string
Function to compare a given version string with the current version of MPD
MphpD::version_bte(string $version) : bool
Version to compare to.
bool
bool Returns true if MPDs version is equal to or newer than the given version. False otherwise.
Waits until there is a noteworthy change in one or more of MPD’s subsystems.
MphpD::idle(string $subsystem = '', int $timeout = 60) : mixed
Specifies how long to wait for MPD to return an answer.
mixed
array|false array
of changed subsystems or false
on timeout.
Close the connection to the MPD socket
MphpD::close() : void
void
void
Kill MPD.
MphpD::kill() : void
void
void
Returns the current binarylimit
MphpD::get_binarylimit() : int
int
int The current binarylimit.
Function to set the last occurred error. Should only be used inside the library!
MphpD::set_error( $err) : bool
bool
false
Return an array containing information about the last error.
MphpD::get_last_error() : array
array
array associative array containing the following keys:
[
"code" => (int),
"message" => (string),
"command" => (string),
"commandlistnum" => (int)
]
Initiate connection to MPD with the parameters given at instantiation.
MphpD::connect() : bool
bool
bool true
on success or false
on failure.
Disconnect from MPD
MphpD::disconnect() : mixed
mixed
void