* version: 1.0 * */ // common include include '../inc/connection.php'; error_reporting(ERRORLEVEL); header('Content-Type: application/json'); if (isset($_GET['cmd']) && $_GET['cmd'] != '') { if (!$mpd) { echo json_encode(['error' => 'Error Connecting to MPD daemon']); } else { $sRawCommand = $_GET['cmd']; $sSpopCommand = NULL; if ($spop) { // If Spop daemon connected $stringSpopState = getSpopState($spop, "CurrentState")['state']; if (strcmp($stringSpopState, 'play') == 0 || strcmp($stringSpopState, 'pause') == 0) { // If spotify playback mode if (strcmp($sRawCommand, "previous") == 0) { $sSpopCommand = "prev"; } else { if (strcmp($sRawCommand, "pause") == 0) { $sSpopCommand = "toggle"; } else { if (strcmp(substr($sRawCommand, 0, 6), "random") == 0) { $sSpopCommand = "shuffle"; } else { if (strcmp(substr($sRawCommand, 0, 6), "repeat") == 0) { $sSpopCommand = "repeat"; } else { if (strcmp(substr($sRawCommand, 0, 6), "single") == 0 || strcmp(substr($sRawCommand, 0, 7), "consume") == 0) {
<?php // Open socket include 'inc/connection.php'; if (!$spop) { echo ''; } else { // Get the current status array $status = getSpopState($spop, "CurrentState"); if ($_GET['state'] == $status['state']) { // If the playback state is the same as specified in the ajax call // Wait until the status changes and then return new status $status = getSpopState($spop, "NextState"); } // Return data in json format to ajax requester and close socket header('Content-Type: application/json'); echo json_encode($status); closeSpopSocket($spop); }