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()); } }