Example #1
0
<?php

require_once "../lib/mpd.php";
require_once "../config.php";
$mpd = new MPD(SERVER, PORT);
$mpd->connect();
if (isset($_GET['enable'])) {
    $id = intval($_GET['enable']);
} else {
    if (isset($_GET['disable'])) {
        $id = intval($_GET['disable']);
    } else {
        echo json_encode($mpd->outputs());
    }
}
$mpd->disconnect();
Example #2
0
<?php

require_once "../lib/mpd.php";
require_once "../config.php";
$mpd = new MPD(SERVER, PORT);
$commands = array();
$commands['volume='] = "setVolume";
$commands['pause='] = "setPause";
$mpd->connect();
$command = $commands[$_GET['command']];
if (!isset($commands[$_GET['command']])) {
    $command = $_GET['command'];
}
$result = 0;
if ($_GET['args'] != "undefined") {
    $_GET['args'] = str_replace(";amp;", "&", $_GET['args']);
    $result = $mpd->{$command}($_GET['args']);
} else {
    $result = $mpd->{$command}();
}
print_r($result);
$mpd->disconnect();
Example #3
0
<?php

require_once '../lib/mpd.php';
require_once '../config.php';
$mpd = new MPD(SERVER, PORT);
$mpd->connect();
$path = str_replace(";amp;", "&", $_GET['path']);
$list = $mpd->ls($path);
$mpd->disconnect();
foreach ($list as $line) {
    $keyval = explode(": ", $line);
    $keyval[1] = addslashes(stripslashes($keyval[1]));
    $keyval[1] = preg_split("/[^\\]]\\//", $keyval[1]);
    $keyval[1] = $keyval[1][count($keyval[1]) - 1];
    $pretty_val = str_replace(" & ", " ;amp_r; ", $keyval[1]);
    $keyval[1] = str_replace(" & ", " ;amp; ", $keyval[1]);
    $pretty = stripslashes($pretty_val);
    if ($keyval[0] == "file") {
        echo "<li><a onclick=\"addToPlaylist('{$path}/{$keyval[1]}'); return false;\" href=\"#\">";
        echo "<img style=\"padding-right: 4px;\" alt=\"[add]\" title=\"Add to Playlist\" src=\"images/file_add.png\" /></a>";
        echo "<a onclick=\"addToPlaylist('{$path}/{$keyval[1]}'); return false;\" href=\"#\">{$pretty}</a></li>";
    } elseif ($keyval[0] == "directory") {
        echo "<li><a onclick=\"addToPlaylist('{$path}/{$keyval[1]}'); return false;\" href=\"#\">";
        echo "<img style=\"padding-right: 4px;\" alt=\"[add]\" title=\"Add to Playlist\" src=\"images/folder_add.png\" /></a>";
        echo "<a onclick=\"replaceCurrentPlaylist('{$path}/{$keyval[1]}'); return false;\" href=\"#\">";
        echo "<img style=\"padding-right: 4px;\" alt=\"[add]\" title=\"Replace Current Playlist\" src=\"images/replace.png\" /></a>";
        echo "<a onclick=\"down_directory('{$keyval[1]}'); return false;\" href=\"#\">{$pretty}</a></li>";
    }
}
Example #4
0
<?php

require '../MPD.php';
$mpd = new MPD();
print_r($mpd->status());
Example #5
0
<?php

require_once "../lib/mpd.php";
require_once "../config.php";
// Unit test
header("Content-type: text/plain");
$mpd = new MPD(SERVER, PORT);
$mpd->connect();
$status = $mpd->getCurrentSong();
if (empty($status)) {
    $status = array();
}
$status = array_merge($status, $mpd->getStatus());
$status['repeat'] = $status['repeat'] == 1 ? true : false;
$status['random'] = $status['random'] == 1 ? true : false;
$mpd->disconnect();
echo json_encode($status);
Example #6
0
<?php

require_once "../lib/mpd.php";
require_once "../config.php";
$mpd = new MPD(SERVER, PORT);
$mpd->connect();
if (isset($_GET['cmd'])) {
    if (isset($_GET['args'])) {
        $results = $mpd->{$_GET}['cmd']($_GET['args']);
    } else {
        $results = $mpd->{$_GET}['cmd']();
    }
} else {
    $results = $mpd->send($_GET['msg']);
}
$mpd->disconnect();
echo json_encode($results);
Example #7
0
<?php

require_once "../lib/mpd.php";
require_once "../config.php";
$mpd = new MPD(SERVER, PORT);
$property = $_GET['property'];
$mpd->connect();
$status = $mpd->getStatus();
$bool = $status[$property];
$mpd->send($property . " " . ($bool == 0 ? 1 : 0));
$mpd->disconnect();
Example #8
0
function mpdScan($filepath)
{
    $mpd = new MPD();
    $r = $mpd->cmd('update "' . $filepath . '"');
}
Example #9
0
<?php

require_once "../lib/mpd.php";
require_once "../config.php";
// Unit test
header("Content-type: text/plain");
$mpd = new MPD(SERVER, PORT);
$mpd->connect();
$status['playlist'] = $mpd->getCurrentPlaylist();
$mpd->disconnect();
echo json_encode($status);