function mpd_connect()
{
    global $mpd;
    if (getSystemSetting("jukemode") == "mpd") {
        if ($mpd == null) {
            $server = getSystemSetting("mpdserver");
            $port = getSystemSetting("mpdport");
            $mpd = new mpd($server, $port);
            if ($mpd->connected == FALSE) {
                return 0;
            } else {
                return 1;
            }
        } else {
            if (feof($mpd->mpd_sock)) {
                // got disconnected... reconnect
                $mpd->Disconnect();
                $server = getSystemSetting("mpdserver");
                $port = getSystemSetting("mpdport");
                $mpd = new mpd($server, $port);
                if ($mpd->connected == FALSE) {
                    return 0;
                } else {
                    return 1;
                }
            } else {
                return 1;
            }
        }
    }
}
Esempio n. 2
0
    }
}
$me = basename($_SERVER['PHP_SELF']);
$rnd = substr(md5(rand()), 0, 8);
// having trouble with refreshes. this should convince the browser that everything's unique
print "<p><a href=\"playlist.php?{$rnd}\" accesskey=\"*\">*. Refresh</a> | ";
print "<a href=\"index.php?{$rnd}\" accesskey=\"#\">#. Back</a></p>\n";
print "<p><a href=\"{$me}?clear={$rnd}\">Clear Playlist</a></p>\n";
print "<h3>Available Playlists</h3>\n<p>";
foreach ($pl['playlist'] as $key => $val) {
    print "<a href=\"{$me}?setTo={$val}&{$rnd}\">{$val}</a><br />\n";
}
print "</p>\n\n<h3>Current Playlist</h3>\n<p>\n";
$pl = $mpd->playlist;
//GetPlayList();
foreach ($pl as $key => $val) {
    $b1 = $b2 = '';
    if ($mpd->current_track_id == $key) {
        $b1 = '<b>';
        $b2 = '</b>';
    }
    if (is_numeric($key)) {
        print "<a href=\"{$me}?play={$key}&{$rnd}\">{$b1}{$key} - " . $pl[$key]["Artist"] . " - " . $pl[$key]['Title'] . "{$b2}</a> | <a href=\"{$me}?del={$key}&{$rnd}\">del</a><br />\n";
    }
}
print "</p>\n<p><a href=\"index.php\">Back</a></p>\n";
$mpd->Disconnect();
?>
</body>
</html>