if ($TCMODS_CLOCKRAD_RETRY == 0) { $clock_radio_stoptime = ''; $TCMODS_CLOCKRAD_RETRY = 3; } else { --$TCMODS_CLOCKRAD_RETRY; // decrement } // shutdown requested if ($_tcmods_conf['clock_radio_shutdown'] == "Yes") { sysCmd('poweroff'); } } } // TC (Tim Curtis) 2015-05-30: update playback history log if ($_tcmods_conf['play_history_enabled'] == "Yes" && ($mpd = openMpdSocket(MPD_HOST, 6600))) { $resp = execMpdCommand($mpd, 'currentsong'); closeMpdSocket($mpd); $currentsong = _parseMpdCurrentSong($resp); // TC (Tim Curtis) 2015-07-31: updated logic // Logic modeled after player_lib.js getPlaylist(); // RADIO STATION if (isset($currentsong['Name']) || substr($currentsong['file'], 0, 4) == "http" && !isset($currentsong['Artist'])) { if (!isset($currentsong['Title'])) { $title = "Streaming source"; } else { $title = $currentsong['Title']; $searchStr = str_replace('-', ' ', $title); $searchStr = str_replace('&', ' ', $searchStr); $searchStr = preg_replace('!\\s+!', '+', $searchStr); } $artist = "<i class=\"icon-microphone\"></i>";
function searchDB($sock, $type, $query = '') { if ('' !== $query) { $query = ' "' . html_entity_decode($query) . '"'; } switch ($type) { case "filepath": $resp = execMpdCommand($sock, "lsinfo " . $query); break; case "album": case "artist": case "title": case "file": $resp = execMpdCommand($sock, "search " . $type . $query); break; } return _parseFileListResponse($resp); }
uiSetNotification('Job failed', 'Background worker is busy'); } } else { if (workerPushTask('sourcecfg', $_POST)) { uiSetNotification('Mount point modified', 'MPD database update initiated...'); } else { uiSetNotification('Job failed', 'Background worker is busy'); } } } Session::close(); // wait for worker waitWorker(); // update MPD db after worker finishes if (false !== ($mpd = openMpdSocket(MPD_HOST, 6600))) { execMpdCommand($mpd, 'update'); closeMpdSocket($mpd); } $source = ConfigDB::read('cfg_source'); $_mounts = ''; foreach ($source as $mp) { $icon = wrk_checkStrSysfile('/proc/mounts', $mp['name']) ? "<i class='icon-ok green sx'></i>" : "<i class='icon-remove red sx'></i>"; $_mounts .= "<p><a href=\"sources.php?p=edit&id=" . $mp['id'] . "\" class='btn btn-large' style='width: 240px;'> " . $icon . " " . $mp['name'] . " (" . $mp['address'] . ") </a></p>"; } $tpl = "sources"; if (isset($_GET['p']) && !empty($_GET['p'])) { if (isset($_GET['id']) && !empty($_GET['id'])) { $_id = $_GET['id']; foreach ($source as $mount) { if ($mount['id'] == $_id) { $_name = $mount['name'];
Session::open(); // Fetch MPD status $status = _parseStatusResponse(mpdStatus($mpd)); // Register player state in session $_SESSION['state'] = $status['state']; Session::close(); // Check and compare GUI state with Backend state // MPD idle timeout loop, mpdMonitorState() waits until something changes in MPD then returns status if ($_GET['state'] == $status['state']) { $status = mpdMonitorState($mpd); } // make sure song ist defined $song = isset($status['song']) ? $status['song'] : ''; $status['x_status'] = $status; $status['x_currentsong'] = _parseMpdCurrentSong(execMpdCommand($mpd, 'currentsong')); $status['x_playlistinfo'] = _parseFileListResponse(execMpdCommand($mpd, "playlistinfo " . $song)); // get track info for currently playing track $queue = mpdQueueTrackInfo($mpd, $song); if (isset($queue[0])) { $track = $queue[0]; // TODO check moving this to mpdEnrichItem $status['fileext'] = pathinfo($track['file'], PATHINFO_EXTENSION); // TODO use standard names instead of current xyz $status['currentartist'] = isset($track['Artist']) ? $track['Artist'] : ''; $status['currentsong'] = isset($track['Title']) ? $track['Title'] : ''; $status['currentalbum'] = isset($track['Album']) ? $track['Album'] : ''; // experimental mpdEnrichItemInfo($track); $status = array_merge($status, $track); } closeMpdSocket($mpd);
// nested array execMpdCommand($mpd, 'play ' . $pos); } break; // - library panel Add/replace/playall btn // - library panel Add/replace/playall btn case 'addallreplaceplay': if (null !== $path) { execMpdCommand($mpd, 'clear'); $res = mpdQueueAddMultiple($mpd, array_column($path, 'file')); // nested array execMpdCommand($mpd, 'play'); } break; case 'currentsong': $res = _parseMpdCurrentSong(execMpdCommand($mpd, 'currentsong')); mpdEnrichItemInfo($res); break; case 'playlist': $res = mpdQueueInfo($mpd); foreach ($res as &$song) { mpdEnrichItemInfo($song); } break; default: // execute any mpd command $res = execMpdCommand($mpd, $cmd); } closeMpdSocket($mpd); header('Content-type: application/json'); echo json_encode($res, JSON_PRETTY_PRINT);