Common->getStatus(); $current = $mpd->Playback->getCurrentSong(); // MPD actions if (!empty($_POST['action']) OR !empty($_GET['action'])) { if (!empty($_GET['action'])) $action = $_GET['action']; else $action = $_POST['action']; list($action, $value) = explode(' ', $action); switch($action) { case 'next': $mpd->Playback->nextSong(); break; case 'prev': case 'previous': $mpd->Playback->previousSong(); break; case 'toggle': if ($status['state'] == 'stop') $mpd->Playback->play(intval($current['Pos'])); else $mpd->Playback->pause(); break; case 'stop': $mpd->Playback->stop(); break; case 'volume': if (substr($value, 0, 1) == '-') { $value = $status['volume'] - intval(substr($value, 1)); } elseif (substr($value, 0, 1) == '+') { $value = $status['volume'] + intval(substr($value, 1)); } $mpd->Playback->setVolume(intval($value)); break; } $mpd->Common->disconnect(); die('1'); } // Event server if (!empty($_GET['eventserver'])) { header("Content-Type: application/x-dom-event-stream"); if (@set_time_limit(60)) $max = 57; else $max = ini_get("max_execution_time") - 3; $i = 0; while($i < $max) { $new_current = $mpd->Playback->getCurrentSong(); $new_status = $mpd->Common->getStatus(); if ($new_current != $current) { echo "Event: song-change\n"; echo "data: ".utils::getPlayingTitle($new_current)."\n\n"; flush(); } if ($new_status['volume'] != $status['volume']) { echo "Event: volume-change\n"; echo "data: ".$new_status['volume']."\n\n"; flush(); } if ($new_status['state'] != $status['state']) { echo "Event: state-change\n"; echo "data: ".$new_status['state']."\n\n"; flush(); } echo "Event: pong\n"; echo "data: ".date("dmY His")."\n\n"; flush(); $current = $new_current; $status = $new_status; sleep(2); $i += 2; } echo "Event: client-must-reconnect\ndata: OK\n\n"; $mpd->Common->disconnect(); flush(); exit; } // Display of page header("Content-Type: application/xhtml+xml"); echo ' Wiimuplay - Wii Music Player Client '; // Only Opera supports SVG and event-sse if (!preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT'])) { echo '

Warning : you are not using a Wii to view this page. It could be broken.

'; } echo ' '.utils::getPlayingTitle($current).' '; $mpd->Common->disconnect(); ?>