public static function settingsTest($app) { $socket = openMpdSocket('/run/mpd.sock'); sendMpdCommand($socket, 'status'); $song = readMpdResponse($socket); // var_dump(self::parsePlaylist($song)); echo json_encode(playerController::parsePlaylist($song)); }
function waitWorker($sleeptime, $section) { if ($_SESSION['w_active'] == 1) { do { sleep($sleeptime); session_start(); session_write_close(); } while ($_SESSION['w_active'] != 0); switch ($section) { case 'sources': $mpd = openMpdSocket('localhost', 6600); sendMpdCommand($mpd, 'update'); closeMpdSocket($mpd); break; } } }
fwrite($fp, implode("", $newArray)); fclose($fp); // Start minidlna service sysCmd('/usr/bin/minidlna -f /run/minidlna.conf'); } // check /etc/network/interfaces integrity hashCFG('check_net', $db); // check /etc/mpd.conf integrity hashCFG('check_mpd', $db); // check /etc/auto.nas integrity // hashCFG('check_source',$db); // unlock session files playerSession('unlock', $db, '', ''); // Cmediafix startup check if (isset($_SESSION['cmediafix']) && $_SESSION['cmediafix'] == 1) { $mpd = openMpdSocket('localhost', 6600); sendMpdCommand($mpd, 'cmediafix'); closeMpdSocket($mpd); } // Utilities to start with Volumio // Shairport for Airplay Capability //Retrieve Output Device $dbh = cfgdb_connect($db); $query_cfg = "SELECT param,value_player FROM cfg_mpd WHERE value_player!=''"; $mpdcfg = sdbquery($query_cfg, $dbh); $dbh = null; foreach ($mpdcfg as $cfg) { if ($cfg['param'] == 'audio_output_format' && $cfg['value_player'] == 'disabled') { $output .= ''; } else { if ($cfg['param'] == 'device') {
* http://www.tsunamp.com * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TsunAMP; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * * * UI-design/JS code by: Andrea Coiutti (aka ACX) * PHP/JS code by: Simone De Gregori (aka Orion) * * file: connection.php * version: 1.0 * */ require 'config.inc'; error_reporting(ERRORLEVEL); // include player library include ROOTPATH . 'inc/player_lib.php'; // configuro parametri di connessione con demone MPD $mpd = openMpdSocket(DAEMONIP, 6600);
// retry stop cmd to improve robustness 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); }
$libs = APP . 'libs/vendor'; set_include_path(get_include_path() . PATH_SEPARATOR . $libs); // RuneAudio Library include include APP . 'libs/runeaudio.php'; // Connect to Redis backend $redis = new Redis(); $redis->pconnect('127.0.0.1'); //$redis->pconnect('/tmp/redis.sock'); $devmode = $redis->get('dev'); $activePlayer = $redis->get('activePlayer'); // LogSettings if ($redis->get('debug') > 0) { $activeLog = 1; } else { $activeLog = 0; } ini_set('log_errors', $activeLog); ini_set('error_log', '/var/log/runeaudio/runeui.log'); ini_set('display_errors', $activeLog); // connect to MPD daemon if ($_SERVER["SCRIPT_FILENAME"] === '/var/www/command/index.php' && $activePlayer === 'MPD') { // debug runelog('[connection.php] >>> OPEN MPD SOCKET [NORMAL MODE [0] (blocking)] <<<', ''); $mpd = openMpdSocket('/run/mpd.sock', 0); } elseif ($activePlayer === 'MPD') { // debug runelog('[connection.php] >>> OPEN MPD SOCKET [BURST MODE [1] (blocking)] <<<', ''); $mpd = openMpdSocket('/run/mpd.sock', 1); } elseif ($redis->hGet('spotify', 'enable') === '1' && $activePlayer === 'Spotify') { $spop = openSpopSocket('localhost', 6602, 1); }
public static function currentSong($app) { $app->response->headers->set('Content-Type', 'application/json'); $socket = openMpdSocket('/run/mpd.sock'); sendMpdCommand($socket, 'currentsong'); $song = readMpdResponse($socket); $obj = array("song" => self::parsePlaylist($song)); echo json_encode($obj); }
public static function playlistRemove($app, $num) { $socket = openMpdSocket('/run/mpd.sock'); sendMpdCommand($socket, "deleteid " . $num); $infos = readMpdResponse($socket); var_dump($infos); }
} else { 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) {
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); }
// direct output bypass template system $tplfile = 0; runelog("\n--------------------- coverart (start) ---------------------"); // turn off output buffering ob_implicit_flush(0); // --------------------- MPD --------------------- if ($activePlayer === 'MPD') { // output switch $output = 0; include 'getid3/audioinfo.class.php'; // get Last.FM api-key $lastfm_apikey = $redis->get('lastfm_apikey'); // get HTTP proxy settings $proxy = $redis->hGetall('proxy'); // connect to MPD daemon $mpd2 = openMpdSocket('/run/mpd.sock', 0); // fetch MPD status $status = _parseStatusResponse(MpdStatus($mpd2)); $curTrack = getTrackInfo($mpd2, $status['song']); $mpdRoot = "/mnt/MPD/"; $trackMpdPath = findPLposPath($status['song'], $mpd2); $currentpath = $mpdRoot . $trackMpdPath; closeMpdSocket($mpd2); // debug runelog("MPD current path", $currentpath); $request_uri = urldecode($_SERVER['REQUEST_URI']); runelog("HTTP GET request_uri (urldecoded)", $request_uri); $request_folder = substr(substr($request_uri, 0, strrpos($request_uri, "/")), 10); runelog("HTTP GET (request_folder)", $request_folder); $request_coverfile = substr($request_uri, strrpos($request_uri, "/") + 1); runelog("HTTP GET (request_coverfile)", $request_coverfile);
<?php /** * PlayerUI Copyright (C) 2013 Andrea Coiutti & Simone De Gregori * Tsunamp Team * http://www.tsunamp.com * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with TsunAMP; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. * * Rewrite by Tim Curtis and Andreas Goetz */ require_once dirname(__FILE__) . '/config.inc'; require_once dirname(__FILE__) . '/../inc/player.php'; // mpd socket/port $mpd = openMpdSocket(MPD_HOST, 6600);