function mpd_connect()
{
    global $mpd;
    if (getSystemSetting("jukemode") == "mpd") {
        if ($mpd == null) {
            $server = getSystemSetting("mpdserver");
            $port = getSystemSetting("mpdport");
            $mpd = new mpd($server, $port);
            if ($mpd->connected == FALSE) {
                return 0;
            } else {
                return 1;
            }
        } else {
            if (feof($mpd->mpd_sock)) {
                // got disconnected... reconnect
                $mpd->Disconnect();
                $server = getSystemSetting("mpdserver");
                $port = getSystemSetting("mpdport");
                $mpd = new mpd($server, $port);
                if ($mpd->connected == FALSE) {
                    return 0;
                } else {
                    return 1;
                }
            } else {
                return 1;
            }
        }
    }
}
Esempio n. 2
0
<html>
<head>
<title>mpd remote</title>
<meta http-equiv="cache-control" content="must-revalidate" forua=true />
<meta http-equiv="cache-control" content="no-cache" forua=true />
<style type="text/css">
A, A:visited {
  color: blue;
}
</style>
</head>
<body>

BLK1;
require_once 'mpd-class/mpd.class.php';
$mpd = new mpd($host, $port, $password);
$pl = $mpd->GetDir();
if (isset($_GET['setTo'])) {
    if (in_array($_GET['setTo'], $pl['playlist'])) {
        //test for illegit data
        $mpd->PLLoad($_GET['setTo']);
    } elseif (isset($_GET['clear'])) {
        $mpd->PLClear();
    } elseif (isset($_GET['del'])) {
        //mpd.class tests for integer
        $mpd->PLRemove($_GET['del']);
    } elseif (isset($_GET['play'])) {
        //mpd.class tests for integer
        $mpd->SkipTo($_GET['play']);
        $mpd->Play();
    }
Esempio n. 3
0
<?php

require "./include/mpd.class.php";
$config = parse_ini_file("./include/config.ini");
// try to connect to MPD server
$Mpd = new mpd($config["server"], $config["port"], $config["password"] == "" ? null : $config["password"]);
if (!$Mpd->connected) {
    die("Could not connect to MPD server.");
}
$memcache = new Memcache();
$memcache->connect('localhost', 11211) or die("Could not connect");
$playlistcount = $memcache->get('mpdplaylistcount');
if ($Mpd->state == MPD_STATE_PLAYING) {
    if ($_GET["action"] == "playpause") {
        $Mpd->Pause();
    }
} elseif ($Mpd->state == MPD_STATE_PAUSED || $Mpd->state == MPD_STATE_STOPPED) {
    if ($_GET["action"] == "playpause") {
        $Mpd->Play();
    }
} else {
    if ($_GET["action"] == "playpause") {
    }
}
if ($_GET["action"] == "stop") {
    $Mpd->Stop();
}
if ($_GET["action"] == "next") {
    $Mpd->Next();
}
if ($_GET["action"] == "previous") {
Esempio n. 4
0
<?php

if ($terminal['PLAYER_PASSWORD'] == '') {
    $terminal['PLAYER_PASSWORD'] = NULL;
}
include 'mpd.class.php';
if (!$terminal['PLAYER_PORT']) {
    $terminal['PLAYER_PORT'] = 6600;
}
if (!$terminal['HOST']) {
    $terminal['HOST'] = 'localhost';
}
$mpd = new mpd($terminal['HOST'], $terminal['PLAYER_PORT'], $terminal['PLAYER_PASSWORD']);
if ($mpd->connected) {
    if ($command == 'refresh') {
        $mpd->PLClear();
        $mpd->DBRefresh();
        $path = preg_replace('/\\\\$/is', '', $out['PLAY']);
        $db = SQLSelect("SELECT * FROM collections ORDER BY TITLE");
        $total = count($db);
        for ($i = 0; $i < $total; $i++) {
            if ($db[$i][PATH][0] == '/') {
                $path = str_replace($db[$i][PATH], '', $path);
                break;
            }
        }
        $path = str_replace('\\', '/', $path);
        $path = str_replace('./', '', $path);
        $mpd->PLAdd($path);
        $mpd->Play();
    }
Esempio n. 5
0
<?php

/* Settings */
$mpdServer = 'localhost';
$mpdPort = '6600';
$mpdPassword = NULL;
$volDownSteps = 10;
$volUpSteps = 10;
/* Do not change */
ob_start();
include 'inc/mpd.class.php';
include 'inc/functions.php';
$mpd = new mpd($mpdServer, $mpdPort, $mpdPassword);
define('CURRENTARTIST', $mpd->playlist[$mpd->current_track_id]['Artist']);
define('CURRENTTRACK', $mpd->playlist[$mpd->current_track_id]['Title']);
define('CURRENTID', $mpd->playlist[$mpd->current_track_id]['Id']);
include 'tpl/header.tpl.php';
if ($mpd->connected == FALSE) {
    echo "Error: " . $mpd->errStr;
} else {
    $statusrow = explode("\n", $mpd->SendCommand('status'));
    foreach ($statusrow as $row) {
        $get = explode(': ', $row);
        $status[$get[0]] = $get[1];
    }
    $times = explode(':', $status['time']);
    $CURRENTLENGTH = convertSecs($times[1]);
    $CURRENTTIME = convertSecs($times[0]);
    // f*****g dirty
    if ($mpd->state != 'stop') {
        $refresh = ($times[1] - $times[0]) * 1000 + 500;
Esempio n. 6
0
<?php
include "mpd.class.php";
$inst = new mpd("127.0.0.1", 6600);

$inst->Stop();
$inst->DBRefresh();
//$inst->PLClear();
$inst->PLAdd($_GET["file"]);
$inst->Play();
$inst->Next();
Esempio n. 7
0
<?php

require "./include/mpd.class.php";
$config = parse_ini_file("./include/config.ini");
function is_odd($int)
{
    return $int % 2;
}
$Mpd = new mpd($config["server"], $config["port"], $config["password"] == "" ? null : $config["password"]);
if (!$Mpd->connected) {
    die("Could not connect to MPD server.");
}
$currenttrackid = $Mpd->current_track_id;
$m_currenttrackid = $Mpd->current_track_id;
$memcache = new Memcache();
$memcache->connect('localhost', 11211) or die("Could not connect");
if ($m_currenttrackid < 0) {
    $m_currenttrackid = 0;
    $memcache->delete('mpdplaylist');
}
$playlist_results1 = $memcache->get('mpdplaylist');
if (is_null($playlist_results1[$currenttrackid]["Title"])) {
    $memcache->delete('mpdplaylist');
}
if (!$memcache->get('mpdplaylist')) {
    $Mpd->RefreshPlaylist();
    $m_uplist = 200;
    $m_downlist = $m_uplist * 2;
    //temp Hack To load all songs and not just batches of 400s
    $m_downlist = count($Mpd->playlist);
    if (count($Mpd->playlist) < $m_downlist) {
Esempio n. 8
0
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
  <link rel="stylesheet" href="css.mobile.css" />
  <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head> 
<body> 
<div data-role="page">

  <div data-role="header">
    <h1>Ultrasonic Controller</h1>
  </div><!-- /header -->


BLK1;
require_once 'mpd-class/mpd.class.php';
$mpd = new mpd($host, $port, $password);
if (isset($_GET['pause'])) {
    $mpd->Pause();
} elseif (isset($_GET['prev'])) {
    $mpd->Previous();
} elseif (isset($_GET['play'])) {
    $mpd->Play();
} elseif (isset($_GET['next'])) {
    $mpd->Next();
} elseif (isset($_GET['stop'])) {
    $mpd->Stop();
} elseif (isset($_GET['voldn'])) {
    $mpd->AdjustVolume(-5);
} elseif (isset($_GET['volup'])) {
    $mpd->AdjustVolume(+5);
} elseif (isset($_GET['stovr'])) {
Esempio n. 9
0
<?php
include "mpd.class.php";
$inst = new mpd("127.0.0.1", 6600);

$inst->Stop();
$inst->DBRefresh();
$inst->PLClear();
$inst->PLAdd($_GET["file"]);
$inst->Play();
Esempio n. 10
0
<?php

/*
 *  mpdcontrol.php
 *  Controls mpd using mpd.class.php
 */
require_once 'mpdconfig.php';
require_once 'mpd.class.php';
require_once 'globalFunctions.php';
$mpd = new mpd($host, $mpdPort, $mpdPassword);
if (!$mpd->connected) {
    echo "\nCould not connect to the MPD server\n";
    exit(1);
}
// GET variables
if (isset($_GET['action'])) {
    $action = $_GET['action'];
} else {
    $action = "";
}
if (isset($_GET['track'])) {
    $track = $_GET['track'];
} else {
    $track = "";
}
// Control
switch ($action) {
    case "Play":
        $mpd->Play();
        break;
    case "Pause":