doError("No vote specified"); } $vote = $_GET["vote"] == "true"; $r = doVotePlaylist($_SERVER['REMOTE_ADDR'], $_GET["name"], $vote); doOutput(null, "votePlaylist"); break; case "getmyvotes": $r = doGetmyvotes(); if ($r === false) { doError("Error while getting your votes"); } else { doOutput($r, "getmyvotes"); } break; case "getnextsong": doOutput(getNextsongInHighscore(), "getnextsong"); break; case "mpdcurrent": $r = getMpdCurrentSong(); if ($r === false) { doError("mpdcurrent failed"); } else { doOutput($r, "mpdcurrent"); } break; case "getfolderpic": if (!isset($_GET["id"])) { doError("No id specified"); } $folder = getFolderPic($_GET["id"]); header('Content-type:image/png');
function addOneFileToMpdQueue($first = false) { checkForSavePlaylog(); $mpd = new MPD(); $voted = false; $tmp = doShowhighscore(true); if ($tmp !== false && $tmp !== null && count($tmp) >= 1) { $voted = true; } $hn = getNextsongInHighscore(true); if ($hn !== null) { $path = getFilepathForFileid($hn->id); $mpd->cmd('add "' . $path . '"'); $state = getMpdValue("status", "state"); if ($state != "play") { $mpd->cmd("play"); } if ($first) { $timeToAction = intval($hn->length) - 4; } else { $timeTotal = getMpdValue("currentsong", "Time"); $timeCurrent = getMpdCurrentTime(); $timeToAction = intval($hn->length) + (intval($timeTotal) - intval($timeCurrent)) - 4; } Tasker::add($timeToAction, 'addOneFileToMpdQueue'); if ($voted) { $stmt = $GLOBALS["db"]->prepare("UPDATE votes set played=1 WHERE fileid=:fileid"); if (!$stmt->execute(array(":fileid" => $hn->id))) { echo "error"; } $stmt = $GLOBALS["db"]->prepare("INSERT INTO playlog (fileid,date) VALUES (:fileid,NOW())"); if (!$stmt->execute(array(":fileid" => $hn->id))) { echo "error"; } } Tasker::add(5, 'checkForSkipSong'); } else { Tasker::add(5, 'daemonCallInit', array()); } }