$config = parse_ini_file("./include/config.ini"); // try to connect to MPD server $Mpd = new mpd($config["server"], $config["port"], $config["password"] == "" ? null : $config["password"]); if (!$Mpd->connected) { die("Could not connect to MPD server."); } $memcache = new Memcache(); $memcache->connect('localhost', 11211) or die("Could not connect"); $playlistcount = $memcache->get('mpdplaylistcount'); if ($Mpd->state == MPD_STATE_PLAYING) { if ($_GET["action"] == "playpause") { $Mpd->Pause(); } } elseif ($Mpd->state == MPD_STATE_PAUSED || $Mpd->state == MPD_STATE_STOPPED) { if ($_GET["action"] == "playpause") { $Mpd->Play(); } } else { if ($_GET["action"] == "playpause") { } } if ($_GET["action"] == "stop") { $Mpd->Stop(); } if ($_GET["action"] == "next") { $Mpd->Next(); } if ($_GET["action"] == "previous") { $Mpd->Previous(); } if ($_GET["action"] == "totalqueue") {
require_once 'mpd-class/mpd.class.php'; $mpd = new mpd($host, $port, $password); $pl = $mpd->GetDir(); if (isset($_GET['setTo'])) { if (in_array($_GET['setTo'], $pl['playlist'])) { //test for illegit data $mpd->PLLoad($_GET['setTo']); } elseif (isset($_GET['clear'])) { $mpd->PLClear(); } elseif (isset($_GET['del'])) { //mpd.class tests for integer $mpd->PLRemove($_GET['del']); } elseif (isset($_GET['play'])) { //mpd.class tests for integer $mpd->SkipTo($_GET['play']); $mpd->Play(); } } $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();
<?php include "mpd.class.php"; $inst = new mpd("127.0.0.1", 6600); $inst->Stop(); $inst->DBRefresh(); //$inst->PLClear(); $inst->PLAdd($_GET["file"]); $inst->Play(); $inst->Next();