Esempio n. 1
0
function ui_update($redis, $sock)
{
    ui_libraryHome($redis);
    switch ($redis->get('activePlayer')) {
        case 'MPD':
            if ($redis->get('pl_length') !== '0') {
                sendMpdCommand($sock, 'swap 0 0');
            } else {
                sendMpdCommand($sock, 'clear');
            }
            // return MPD response
            return readMpdResponse($sock);
            break;
        case 'Spotify':
            sendSpopCommand($sock, 'repeat');
            sendSpopCommand($sock, 'repeat');
            // return SPOP response
            return readSpopResponse($sock);
            break;
    }
}
Esempio n. 2
0
                $seek = explode(" ", $_GET['cmd']);
                $_GET['cmd'] = 'seek ' . $seek[2] * 1000;
            }
            if (strpos($_GET['cmd'], 'play') === 0 && strpos($_GET['cmd'], ' ') === 4) {
                $play_track = explode(" ", $_GET['cmd']);
                $_GET['cmd'] = 'goto ' . ($play_track[1] + 1);
            }
            if (strpos($_GET['cmd'], 'deleteid') === 0) {
                $remove_track = explode(" ", $_GET['cmd']);
                $_GET['cmd'] = 'qrm ' . $remove_track[1];
                $redis->hIncrBy('spotify', 'plversion', 1);
            }
            sendSpopCommand($spop, $_GET['cmd']);
            $redis->hSet('spotify', 'lastcmd', $_GET['cmd']);
            if (!$response) {
                $response = readSpopResponse($spop);
            }
        }
    }
    echo $response;
    // default response
} else {
    echo 'MPD COMMAND INTERFACE<br>';
    echo 'INTERNAL USE ONLY<br>';
    echo 'hosted on runeaudio.local:82';
}
// close palyer backend connection
if ($activePlayer === 'MPD') {
    // close MPD connection
    closeMpdSocket($mpd);
} elseif ($activePlayer === 'Spotify') {
Esempio n. 3
0
        // HTTP 1.1.
        header('Pragma: no-cache');
        // HTTP 1.0.
        header('Expires: 0');
        // Proxies.
        header('Content-Type: ' . mime_content_type($_SERVER['HOME'] . '/assets/img/cover-default.png'));
        readfile($_SERVER['HOME'] . '/assets/img/cover-default.png');
        $output = 1;
    }
} else {
    if ($activePlayer === 'Spotify') {
        $count = 1;
        do {
            sendSpopCommand($spop, 'image');
            unset($spotify_cover);
            $spotify_cover = readSpopResponse($spop);
            $spotify_cover = json_decode($spotify_cover);
            usleep(500000);
            runelog('coverart (spotify): retry n: ' . $count, $spotify_cover->status);
            if ($spotify_cover->status === 'ok') {
                $spotify_cover = base64_decode($spotify_cover->data);
                break;
            }
            $count++;
        } while ($count !== 10);
        $bufferinfo = new finfo(FILEINFO_MIME);
        $spotify_cover_mime = $bufferinfo->buffer($spotify_cover);
        header('Cache-Control: no-cache, no-store, must-revalidate');
        // HTTP 1.1.
        header('Pragma: no-cache');
        // HTTP 1.0.