コード例 #1
0
ファイル: index.php プロジェクト: jbandhauer/Volumio-WebUI
                                    $sSpopCommand = "";
                                } else {
                                    if (strcmp($sRawCommand, "play") == 0 || strcmp($sRawCommand, "next") == 0 || strcmp($sRawCommand, "stop") == 0 || strcmp(substr($sRawCommand, 0, 4), "seek") == 0) {
                                        $sSpopCommand = $sRawCommand;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (isset($sSpopCommand)) {
            // If command is to be passed to spop
            if (strcmp($sSpopCommand, "") != 0) {
                sendSpopCommand($spop, $sSpopCommand);
            }
        } else {
            // Else pass command to MPD
            sendMpdCommand($mpd, $sRawCommand);
        }
    }
} else {
    echo json_encode(['service' => 'MPD COMMAND INTERFACE', 'disclaimer' => 'INTERNAL USE ONLY!', 'hosted_on' => gethostname() . ":" . $_SERVER['SERVER_PORT']]);
}
if ($mpd) {
    closeMpdSocket($mpd);
}
if ($spop) {
    closeSpopSocket($spop);
}
コード例 #2
0
ファイル: index.php プロジェクト: Naghasan/Volumio-WebUI
            case 'spop-addtrackuri':
                if (isset($_POST['path']) && $_POST['path'] != '') {
                    echo sendSpopCommand($spop, "uadd " . $_POST['path']);
                }
                break;
            case 'spop-playplaylistindex':
                if (isset($_POST['path']) && $_POST['path'] != '') {
                    $sSpopPlaylistIndex = end(explode("@", $_POST['path']));
                    sendMpdCommand($mpd, 'stop');
                    echo sendSpopCommand($spop, "play " . $sSpopPlaylistIndex);
                }
                break;
            case 'spop-addplaylistindex':
                if (isset($_POST['path']) && $_POST['path'] != '') {
                    $sSpopPlaylistIndex = end(explode("@", $_POST['path']));
                    echo sendSpopCommand($spop, "add " . $sSpopPlaylistIndex);
                }
                break;
        }
    }
} else {
    echo json_encode(['service' => 'MPD DB INTERFACE', 'disclaimer' => 'INTERNAL USE ONLY!', 'hosted_on' => gethostname() . ":" . $_SERVER['SERVER_PORT']]);
}
if ($mpd) {
    closeMpdSocket($mpd);
}
if ($spop) {
    closeSpopSocket($spop);
}
?>
コード例 #3
0
ファイル: index.php プロジェクト: jrenton/Volumio-WebUI
            default:
                $spopCommandPos = strpos($commandName, "spop-");
                if ($spopCommandPos != -1) {
                    $spopCommand = trim(substr($commandName, 5, strlen($commandName) - 5));
                    if (isset($_POST['path']) && $_POST['path'] != '') {
                        $spopCommand .= " " . $_POST['path'];
                    }
                    if (isset($_POST['p2']) && $_POST['p2'] != '') {
                        $spopCommand .= " " . $_POST['p2'];
                    }
                    // stop any mpd playback
                    $playBackCommands = array("play", "stop", "next", "prev", "goto", "add", "uplay", "uadd");
                    if (in_array($spopCommand, $playBackCommands)) {
                        sendMpdCommand($mpd, "stop");
                    }
                    echo json_encode(sendSpopCommand($spop, $spopCommand));
                }
                break;
        }
    }
} else {
    echo json_encode(['service' => 'MPD DB INTERFACE', 'disclaimer' => 'INTERNAL USE ONLY!', 'hosted_on' => gethostname() . ":" . $_SERVER['SERVER_PORT']]);
}
if ($mpd) {
    closeMpdSocket($mpd);
}
if ($spop) {
    closeSpopSocket($spop);
}
?>
コード例 #4
0
function _getSpopListing($sock, $queryString)
{
    $arrayReturn = array();
    if (strcmp($queryString, "") == 0) {
        // The SPOTIFY root item is requested
        $arrayRootItem = array();
        $arrayRootItem["directory"] = "SPOTIFY";
        $arrayRootItem["Type"] = "SpopDirectory";
        $arrayRoot = array(0 => $arrayRootItem);
        $arrayReturn = $arrayRoot;
    } else {
        if (strncmp($queryString, "SPOTIFY", 7) == 0) {
            // Looking into the SPOTIFY folder
            $arrayResponse = sendSpopCommand($sock, "ls");
            $arrayQueryStringParts = preg_split("(@|/)", $queryString);
            $nQueryStringParts = count($arrayQueryStringParts);
            $sCurrentDirectory = "SPOTIFY";
            $sCurrentDisplayPath = "SPOTIFY";
            $i = 1;
            while ($i < $nQueryStringParts) {
                $sCurrentDirectory = $sCurrentDirectory . "/" . $arrayQueryStringParts[$i];
                if (isset($arrayResponse["playlists"][$arrayQueryStringParts[$i]]["index"]) && $arrayResponse["playlists"][$arrayQueryStringParts[$i]]["index"] == 0) {
                    $sCurrentDisplayPath = $sCurrentDisplayPath . "/" . "Starred";
                } else {
                    $sCurrentDisplayPath = $sCurrentDisplayPath . "/" . $arrayResponse["playlists"][$arrayQueryStringParts[$i]]["name"];
                }
                if (strcmp($arrayResponse["playlists"][$arrayQueryStringParts[$i]]["type"], "playlist") == 0) {
                    // This is a playlist, navigate into it and stop
                    $arrayResponse = sendSpopCommand($sock, "ls " . $arrayResponse["playlists"][$arrayQueryStringParts[$i]]["index"]);
                    break;
                } else {
                    // Index further into the directory listing
                    $arrayResponse = $arrayResponse["playlists"][$arrayQueryStringParts[$i]];
                }
                $i++;
            }
            $arrayCurrentEntry = array();
            $arrayCurrentEntry["DisplayPath"] = $sCurrentDisplayPath;
            array_push($arrayReturn, $arrayCurrentEntry);
            $i = 0;
            if (isset($arrayResponse["tracks"])) {
                // This is a tracklist within a playlist
                $nItems = sizeof($arrayResponse["tracks"]);
                while ($i < $nItems) {
                    $arrayCurrentEntry = array();
                    $arrayCurrentEntry["Type"] = "SpopTrack";
                    $arrayCurrentEntry["SpopTrackUri"] = (string) $arrayResponse["tracks"][$i]["uri"];
                    $arrayCurrentEntry["Title"] = $arrayResponse["tracks"][$i]["title"];
                    $arrayCurrentEntry["Artist"] = $arrayResponse["tracks"][$i]["artist"];
                    $arrayCurrentEntry["Album"] = $arrayResponse["tracks"][$i]["album"];
                    array_push($arrayReturn, $arrayCurrentEntry);
                    $i++;
                }
            } else {
                if (isset($arrayResponse["playlists"])) {
                    // This is a browsable listing
                    $nItems = sizeof($arrayResponse["playlists"]);
                    while ($i < $nItems) {
                        $arrayCurrentEntry = array();
                        $arrayCurrentEntry["Type"] = "SpopDirectory";
                        $sItemDisplayName = $arrayResponse["playlists"][$i]["name"];
                        if (strcmp($arrayResponse["playlists"][$i]["type"], "playlist") == 0) {
                            // This is a browsable playlist
                            $arrayCurrentEntry["SpopPlaylistIndex"] = $arrayResponse["playlists"][$i]["index"];
                            $sItemDirectory = $sCurrentDirectory . "/" . $i . "@" . $arrayResponse["playlists"][$i]["index"];
                            if ($arrayResponse["playlists"][$i]["index"] == 0) {
                                $sItemDisplayName = "Starred";
                            }
                        } else {
                            // This is a Spotify folder
                            $sItemDirectory = $sCurrentDirectory . "/" . $i;
                        }
                        $arrayCurrentEntry["directory"] = $sItemDirectory;
                        $arrayCurrentEntry["DisplayName"] = $sItemDisplayName;
                        array_push($arrayReturn, $arrayCurrentEntry);
                        $i++;
                    }
                }
            }
        }
    }
    return $arrayReturn;
}
コード例 #5
0
ファイル: index.php プロジェクト: jreinert/RuneUI
         sendSpopCommand($spop, 'goto ' . $trackid);
     }
     break;
 case 'spaddreplaceplay':
     if ($activePlayer === 'Spotify') {
         sendSpopCommand($spop, 'qclear');
         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, 'play');
     }
     break;
 case 'addradio':
     if ($activePlayer === 'MPD') {
         // input array= $_POST['radio']['label'] $_POST['radio']['url']
         wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'webradio', 'action' => 'add', 'args' => $_POST['radio']));
     }
     break;
 case 'editradio':
     if ($activePlayer === 'MPD') {
         // input array= $_POST['radio']['label'] $_POST['radio']['newlabel'] $_POST['radio']['url']
         wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'webradio', 'action' => 'edit', 'args' => $_POST['radio']));
     }
     break;
 case 'readradio':
コード例 #6
0
ファイル: index.php プロジェクト: adam-fonseca/RuneUI
                $_GET['cmd'] = 'shuffle';
            }
            if (strpos($_GET['cmd'], 'seek') === 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') {
コード例 #7
0
ファイル: runeaudio.php プロジェクト: adam-fonseca/RuneUI
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;
    }
}
コード例 #8
0
ファイル: coverart_ctl.php プロジェクト: adam-fonseca/RuneUI
        runelog("coverart match: cover-default");
        header('Cache-Control: no-cache, no-store, must-revalidate');
        // 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.