コード例 #1
0
ファイル: index.php プロジェクト: jreinert/RuneUI
     break;
 case 'spadd':
     if ($activePlayer === 'Spotify') {
         if ($_POST['querytype'] === 'spotify-playlist') {
             sendSpopCommand($spop, 'add ' . $_POST['path']);
         } else {
             $path = explode('-', $_POST['path']);
             sendSpopCommand($spop, 'add ' . $path[0] . ' ' . $path[1]);
         }
         $redis->hSet('spotify', 'lastcmd', 'add');
         $redis->hIncrBy('spotify', 'plversion', 1);
     }
     break;
 case 'spaddplay':
     if ($activePlayer === 'Spotify') {
         $status = _parseSpopStatusResponse(SpopStatus($spop));
         $trackid = $status['playlistlength'] + 1;
         if ($_POST['querytype'] === 'spotify-playlist') {
             sendSpopCommand($spop, 'add ' . $_POST['path']);
         } else {
             $path = explode('-', $_POST['path']);
             sendSpopCommand($spop, 'add ' . $path[0] . ' ' . $path[1]);
         }
         $redis->hSet('spotify', 'lastcmd', 'add');
         $redis->hIncrBy('spotify', 'plversion', 1);
         usleep(300000);
         sendSpopCommand($spop, 'goto ' . $trackid);
     }
     break;
 case 'spaddreplaceplay':
     if ($activePlayer === 'Spotify') {
コード例 #2
0
ファイル: runeaudio.php プロジェクト: adam-fonseca/RuneUI
function wrk_togglePlayback($redis, $activePlayer)
{
    $stoppedPlayer = $redis->get('stoppedPlayer');
    // debug
    runelog('stoppedPlayer = ', $stoppedPlayer);
    runelog('activePlayer = ', $activePlayer);
    if ($stoppedPlayer !== '') {
        if ($stoppedPlayer === 'MPD') {
            // connect to MPD daemon
            $sock = openMpdSocket('/run/mpd.sock', 0);
            $status = _parseStatusResponse(MpdStatus($sock));
            runelog('MPD status', $status);
            if ($status['state'] === 'pause') {
                $redis->set('stoppedPlayer', '');
            }
            sendMpdCommand($sock, 'pause');
            closeMpdSocket($sock);
            // debug
            runelog('sendMpdCommand', 'pause');
        } elseif ($stoppedPlayer === 'Spotify') {
            // connect to SPOPD daemon
            $sock = openSpopSocket('localhost', 6602, 1);
            $status = _parseSpopStatusResponse(SpopStatus($sock));
            runelog('SPOP status', $status);
            if ($status['state'] === 'pause') {
                $redis->set('stoppedPlayer', '');
            }
            sendSpopCommand($sock, 'toggle');
            closeSpopSocket($sock);
            // debug
            runelog('sendSpopCommand', 'toggle');
        }
        $redis->set('activePlayer', $stoppedPlayer);
    } else {
        $redis->set('stoppedPlayer', $activePlayer);
        wrk_togglePlayback($redis, $activePlayer);
    }
    runelog('endFunction!!!', $stoppedPlayer);
}