PHP code example of kolbasyatin / php-mpd-client

1. Go to this page and download the library: Download kolbasyatin/php-mpd-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kolbasyatin / php-mpd-client example snippets


use Kolbasyatin\MPD\MPD\MPDClient;
use Kolbasyatin\MPD\MPD\MPDConnection;


$connection = new MPDConnection('localhost:6600', 'yourpassword');
$client = new MPDClient($connection);

$client->play(); // Send the command
$answer = $client->status(); // Get the result


use Kolbasyatin\MPD\MPD\MPDClient;
use Kolbasyatin\MPD\MPD\MPDConnection;
use Kolbasyatin\MPD\MPD\Answers\SimpleAnswer;


$connection = new MPDConnection('localhost:6600', 'yourpassword');
$answer = new SimpleAnswer();
$client = new MPDClient($connection, $answer);

$client->play();

/** @var SimpleAnswer $answer */
$answer = $client->status(); // $answer is instance of SimpleAnswer.
$answer->getAnswerAsRaw(); // You also can get a raw answer from a server.
$answer->getState(); // state


use Kolbasyatin\MPD\MPD\MPDConnection;

$connection = new MPDConnection('localhost:6600', 'yourpassword');
$connection->setSocketTimeOut(1);

$answer->getStatus();
$answer->getError();