-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontrol.php
67 lines (61 loc) · 1.37 KB
/
control.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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") {
$Mpd->Previous();
}
if ($_GET["action"] == "totalqueue") {
echo "Playlist ";
echo "<br />";
echo $playlistcount . " songs";
}
if ($_GET["action"] == "play") {
if (preg_match('/^\d+$/', $_GET["num"])) {
$Mpd->SkipTo($_GET["num"]);
}
}
if ($_GET["action"] == "volume") {
if (!$_GET["set"]) {
if ($Mpd->volume != -1) {
echo $Mpd->volume;
}
else {
echo "N/A";
}
}
elseif($_GET["set"] == "up") {
$Mpd->AdjustVolume(+5);
}
elseif($_GET["set"] == "down") {
$Mpd->AdjustVolume(-5);
}
}
?>