Socket

Methods

__construct

Socket::__construct(array $options = []) : mixed

Parameters

Returns mixed

cmd

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.

Socket::cmd(string $command, array $params = [], int $mode = 2, array $list_start = []) : mixed

Parameters

@param string $command The command

@param array $params Parameters, automatically escaped

@param int $mode One of the following constants:

@param array $list_start In combination with $mode = MPD_CMD_READ_LIST indicates on which key a new list starts.

Returns mixed

array|bool False on failure. Array on success. True on success if $mode is MPD_CMD_READ_BOOL

get_socket

Socket::get_socket() : mixed

Parameters

None.

Returns mixed

get_version

Returns MPDs version as string

Socket::get_version() : string

Parameters

None.

Returns string

string

version_bte

Function to compare a given version string with the current version of MPD

Socket::version_bte(string $version) : bool

Parameters

@param string $version

Returns bool

bool Returns true if MPDs version is equal to or newer than the given version. False otherwise.

idle

Waits until there is a noteworthy change in one or more of MPD’s subsystems.

Socket::idle(string $subsystem = '', int $timeout = 60) : mixed

Parameters

@param string $subsystem

@param int $timeout Specifies how long to wait for MPD to return an answer.

Returns mixed

array|false Returns an array of changed subsystems or false on timeout.

close

Close the connection to the MPD socket

Socket::close() : void

Parameters

None.

Returns void

void

kill

Kill MPD.

Socket::kill() : void

Parameters

None.

Returns void

void

get_binarylimit

Returns the current binarylimit

Socket::get_binarylimit() : int

Parameters

None.

Returns int

int

set_error

Function to set the last occurred error. Should only be used inside the library!

Socket::set_error( $err) : bool

Parameters

@param \MPDException|string $err

Returns bool

false

get_last_error

Return an array containing information about the last error

Socket::get_last_error() : array

Parameters

None.

Returns array

array associative array containing the following keys:

[
  "code" => (int),
  "message" => (string),
  "command" => (string),
  "commandlistnum" => (int)
]

connect

Initiate connection to MPD with the parameters given at instantiation.

Socket::connect() : bool

Parameters

None.

Returns bool

bool

disconnect

Disconnect from MPD

Socket::disconnect() : mixed

Parameters

None.

Returns mixed

void

© 2023 Florian Faber