error_reporting('E_ALL'); // check current player backend $activePlayer = $redis->get('activePlayer'); if (isset($_GET['cmd']) && !empty($_GET['cmd'])) { switch ($_GET['cmd']) { case 'browse': if (isset($_POST['path']) && $_POST['path'] !== '') { if ($_POST['path'] === 'Albums' or $_POST['path'] === 'Artists' or $_POST['path'] === 'Genres') { echo json_encode(browseDB($mpd, $_POST['browsemode'])); } else { echo json_encode(browseDB($mpd, $_POST['browsemode'], $_POST['path'])); } } else { if ($activePlayer === 'MPD') { // MPD echo json_encode(browseDB($mpd, $_POST['browsemode'])); } elseif ($activePlayer === 'Spotify') { // SPOP echo json_encode('home'); } } break; case 'playlist': // open non blocking socket with mpd daemon // $mpd2 = openMpdSocket('/run/mpd.sock', 2); // getPlayQueue($mpd2); // closeMpdSocket($mpd2); if ($activePlayer === 'MPD') { echo getPlayQueue($mpd); } elseif ($activePlayer === 'Spotify') { echo getSpopQueue($spop);
function randomSelect($sock) { $songs = browseDB($sock, 'globalrandom'); srand((double) microtime() * 10000000); $randkey = array_rand($songs); return $songs[$randkey]['file']; }