Ejemplo n.º 1
0
$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);
}
Ejemplo n.º 2
0
 *
 *  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);
$spop = openSpopSocket(DAEMONIP, 6602);
Ejemplo n.º 3
0
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);
}