Пример #1
0
 function &getMPDPlayback()
 {
     if (class_exists("Net_MPD", false)) {
         if (empty($this->playback)) {
             $this->playback = Net_MPD::factory('Playback');
         }
         if (!$this->playback->isConnected() && !$this->playback->connect()) {
             print "Error connecting to MPD (playback)";
         }
     }
     return $this->playback;
 }
Пример #2
0
function get_mpd($type)
{
    try {
        $port = 6600;
        if (is_numeric(get_config("mpd_port"))) {
            $port = (int) get_config("mpd_port");
        }
        $ret = Net_MPD::factory($type, get_config('mpd_host'), intval($port), get_config("mpd_pass"));
        $ret->connect();
        return $ret;
    } catch (PEAR_Exception $e) {
        return false;
    }
}
Пример #3
0
 function player($withIcons = true)
 {
     global $config;
     $withIcons ? $this->imgPath = "templates/" . $config->template . "/images/" : ($this->useIcons = false);
     // include MPD-lib and connect
     require_once 'include/lib-mpd.php';
     $this->mdb = Net_MPD::factory('Database', $config->host, intval($config->port), $config->pass);
     if (!$this->mdb->connect()) {
         $this->error = 'Connection failed';
         return false;
     }
     // get the root filelist
     if ($this->mdb->isCommand('lsinfo')) {
         $this->data = $this->mdb->getInfo("");
     }
     return true;
 }
    require "/var/www/liferecorder/web/relaxx/include/class-config.php";
    $config = new config("/var/www/liferecorder/web/relaxx/config/config.php");
    // no need to read config every ping
    $_SESSION['relaxx_hostdata'] = $config->host . ";" . $config->port . ";" . $config->pass;
}
if (isset($_SESSION['relaxx_hostdata'])) {
    $config = split(";", $_SESSION['relaxx_hostdata'], 3);
    if ($config[2] == "") {
        $config[2] = null;
    }
    // include MPD-lib and connect
    require_once 'lib-mpd.php';
    $MPD_COMMON = Net_MPD::factory('Common', $config[0], $config[1], $config[2]);
    if (!$MPD_COMMON->connect() or !$MPD_COMMON->isCommand('status')) {
        echo '({"error":"connect"})';
        die;
    }
    // ping and exit
    $status = $MPD_COMMON->getStatus();
    echo '{"status":' . json_encode($status) . '';
    $plpos = $_GET['value'];
    // is the actual playlist position different then the recent?
    if ($plpos < $status or $plpos == 0) {
        $MPD_PL = Net_MPD::factory('Playlist', $config[0], $config[1], $config[2]);
        $getChanges = $MPD_PL->getChanges($_GET['value']);
        if ($getChanges != 'true') {
            echo ',"playlist":' . json_encode($getChanges) . "";
        }
    }
    echo '}';
}
Пример #5
0
/* ----------------------------------------------  /
/  Relax Player                                    /
/                                                  /
/  AJAX controller for MPD - admin functions	   /
/  ---------------------------------------------- */
session_start();
ini_set('default_mimetype', 'text/javascript');
header("Content-type: text/javascript;  charset=utf-8");
// read config
require "class-config.php";
$config = new config("../config/config.php");
if (isset($_SESSION['relaxx']) && $_SESSION['relaxx'] == $config->admin_name && $_SESSION['relaxx_pass'] == $config->admin_pass) {
    // include MPD-lib and connect
    require_once 'lib-mpd.php';
    $MPD = Net_MPD::factory('Admin', $config->host, intval($config->port), $config->pass);
    if (!$MPD->connect()) {
        echo json_encode('error');
        die;
    }
    // switch ond action
    switch ($_GET['action']) {
        case 'getOutputs':
            $status = $MPD->isCommand('outputs') ? $MPD->getOutputs() : 'error';
            break;
        case 'disableOutput':
            $config->checkRights("admin_mpd") && $MPD->isCommand('disableoutput') ? $MPD->disableOutput($_GET['value']) : ($status = "error");
            break;
        case 'enableOutput':
            $config->checkRights("admin_mpd") && $MPD->isCommand('enableoutput') ? $MPD->enableOutput($_GET['value']) : ($status = "error");
            break;
/  ---------------------------------------------- */
session_start();
if ($_GET['action'] == "extendTree") {
    ini_set('default_mimetype', 'text/xml');
    header("Content-type: text/xml;  charset=utf-8");
} else {
    ini_set('default_mimetype', 'text/javascript');
    header("Content-type: text/javascript;  charset=utf-8");
}
if (1) {
    // read config
    require "class-config.php";
    $config = new config("../config/config.php");
    // include MPD-lib and connect
    require_once 'lib-mpd.php';
    $MPD = Net_MPD::factory('Database', $config->host, intval($config->port), $config->pass);
    if (!$MPD->connect()) {
        echo json_encode('error');
        die;
    }
    // switch Tab
    switch ($_GET['action']) {
        case 'extendTree':
            // returns next directory level in html/xml
            if ($MPD->isCommand('lsinfo')) {
                $data = $MPD->getInfo($_GET['dir']);
                if ($data['directory']) {
                    foreach ($data['directory'] as $entry) {
                        // look for subdirs in every entry
                        $subdata = $MPD->getInfo($entry);
                        // select dirs with subdirswith a class tag
<?php

/* ----------------------------------------------  /
/  Relax Player                                    /
/                                                  /
/  AJAX controller for playback commands		   /
/  ---------------------------------------------- */
session_start();
ini_set('default_mimetype', 'text/javascript');
header("Content-type: text/javascript;  charset=utf-8");
// read config
require "class-config.php";
$config = new config("../config/config.php");
// include MPD-lib and connect
require_once 'lib-mpd.php';
$MPD = Net_MPD::factory('Playback', $config->host, intval($config->port), $config->pass);
if (!$MPD->connect()) {
    die(json_encode('error'));
}
$status = "success";
// switch ond action
switch ($_GET['action']) {
    case 'getCurrentSong':
        $status = $MPD->isCommand('currentsong') ? $MPD->getCurrentSong() : array('error');
        break;
    case 'play':
        $config->checkRights("controll_player") && $MPD->isCommand('playid') ? $MPD->playid($_GET['value']) : ($status = "error");
        break;
    case 'continue':
        $config->checkRights("start_playing") && $MPD->isCommand('playid') ? $MPD->playid($_GET['value']) : ($status = "error");
        break;