<div id="items">
<table>
<tr id="items_heading">
- <td></td><td>Title</td><th colspan="2">Control</th>
+ <td></td><td>Название</td><th colspan="2">Управление</th>
</tr>
<?php
$dirs=$mpd->GetDir($dir);
req.onreadystatechange = function () {
if (this.readyState != 4 || this.status != 200) return;
document.getElementById('nowplaying_content').innerHTML=this.responseText;
- document.title='MPD Player: '+this.responseText;
};
req.open("GET", "ajax/trackinfo.php", true);
}
+function RefreshTitle() {
+
+var req = new XMLHttpRequest();
+
+req.onreadystatechange = function () {
+ if (this.readyState != 4 || this.status != 200) return;
+ document.title='MPD Player: '+this.responseText;
+};
+
+req.open("GET", "ajax/trackname.php", true);
+req.send();
+}
+
function RefreshPlayerState() {
var req = new XMLHttpRequest();
function RefreshPageStatus() {
+ RefreshTitle();
RefreshNowPlaying();
RefreshPlayerState();
RefreshRepeatState();
}
+function LoadPlayList() {
+
+var req = new XMLHttpRequest();
+
+req.onreadystatechange = function () {
+ if (this.readyState != 4 || this.status != 200) return;
+ document.getElementById('playlist').innerHTML=this.responseText;
+};
+
+req.open("GET", "ajax/playlists.php", true);
+req.send();
+
+}
+
function RefreshPageContent() {
RefreshPageStatus();
}
+function PlaylistCommandRefStatus(cmd,item) {
+
+var req = new XMLHttpRequest();
+
+req.onreadystatechange = function () {
+ if (this.readyState != 4 || this.status != 200) return;
+ RefreshPageStatus();
+};
+
+req.open("GET", "ajax/playlist-command.php?item="+item+"&task="+cmd, true);
+req.send();
+
+}
+
function PlaylistEditCommand(cmd,item) {
var req = new XMLHttpRequest();
}
+function PlaylistEditCommandRefFull(cmd,item) {
+
+var req = new XMLHttpRequest();
+
+req.onreadystatechange = function () {
+ if (this.readyState != 4 || this.status != 200) return;
+ RefreshPageContent();
+};
+
+req.open("GET", "ajax/playlist-command.php?item="+item+"&task="+cmd, true);
+req.send();
+
+}
+
function PlaylistItemsCommand(cmd) {
$cur_track= $mpd->current_track_id;
$playlist= $mpd->playlist;
?>
-<div id="playlist">
<?php include("../view/default/tmpl/playlistmenu.php"); ?>
<div id="items">
<table>
<tr id="items_heading">
- <td></td><td>Title</td><th colspan="4">Controls</th>
+ <td></td><td>Название</td><th colspan="4">Управление</th>
</tr>
<?php
for($i=0;$i<count($playlist);$i++) {
</table>
</div>
<?php include("../view/default/tmpl/playlistmenu.php"); ?>
-</div>
--- /dev/null
+<?php
+
+include('mpd.php');
+?>
+
+<div id="playlist_menu">
+ <table>
+ <tr>
+ <td><span class="button" onclick="RefreshPlaylist()"><img width="20" src="images/playlist.png"></span><td>
+ <td><span class="button" onclick="confirm('Очистить список. Вы уверены?') ? PlaylistCommandRefStatus('clear') : false;" ><img width="20" src="images/removeall.png"></span><td>
+ </tr>
+ </table>
+</div>
+
+<div id="items">
+ <table>
+ <tr id="items_heading">
+ <td></td><td>Название</td>
+ </tr>
+<?
+
+$playlists = $mpd->playlists;
+
+for($i=0;$i<count($playlists);$i++) {
+
+?>
+ <tr id="item<?php if($i%2==0) { echo "Even";}else{echo "Odd";}?>">
+ <td id="track_number"><a name="<?php echo $i;?>"></a></td>
+ <td id="file"><span class="button" onclick="PlaylistEditCommandRefFull('load','<?php echo $playlists[$i]['name'];?>')"><? echo $playlists[$i]['name'];?></td></td>
+ </tr>
+<?php
+}
+?>
+
+ </table>
+</div>
+
+<div id="playlist_menu">
+ <table>
+ <tr>
+ <td><span class="button" onclick="RefreshPlaylist()"><img width="20" src="images/playlist.png"></span><td>
+ <td><span class="button" onclick="return confirm('Очистить список. Вы уверены?') ? PlaylistCommand('clear') : false;" ><img width="20" src="images/removeall.png"></span><td>
+ </tr>
+ </table>
+</div>
--- /dev/null
+<?php
+
+include('mpd.php');
+
+$cur_track = $mpd->current_track_id;
+$playlist = $mpd->playlist;
+
+$playlist_count = $mpd->playlist_count;
+
+if($cur_track !=-1) {
+
+ $trackno=$cur_track+1;
+
+ if ($playlist[$cur_track]['name']==$playlist[$cur_track]['title']) {
+ echo htmlentities(cut_file($playlist[$cur_track]['name']));
+ } else {
+ echo htmlentities($playlist[$cur_track]['title']);
+ }
+
+} else {
+ echo "Трек не выбран";
+}
+
+?>
$mpd->PLAdd($item);
break;
+ case("load"):
+ $mpd->PLLoad($item);
+ break;
+
case("adddir"):
addDir($item,$mpd);
break;
define("MPD_CMD_PLMOVETRACK", "move");\r
define("MPD_CMD_PASSWORD", "password");\r
define("MPD_CMD_TABLE", "list");\r
+define("MPD_CMD_LISTS", "listplaylists");\r
\r
// Predefined MPD Response messages\r
define("MPD_RESPONSE_ERR", "ACK");\r
return $resp;\r
}\r
\r
+ /* PLList() \r
+ * \r
+ * Retrieves the playlists info. \r
+ */\r
+ function PLList() {\r
+ if ( $this->debugging ) echo "mpd->PLList()\n";\r
+ if ( ! is_null($resp = $this->SendCommand(MPD_CMD_LISTS))) $this->RefreshInfo();\r
+ if ( $this->debugging ) echo "mpd->PLList() / return\n";\r
+ return $resp;\r
+ }\r
+\r
/* PLSave() \r
* \r
* Saves the playlist to <file>.m3u for later retrieval. The file is saved in the MPD playlist\r
return $plistArray;\r
}\r
\r
+ /* _parsePlayListsResponse() \r
+ * \r
+ * Builds a multidimensional array with MPD response lists.\r
+ *\r
+ * NOTE: This function is used internally within the class. It should not be used.\r
+ */\r
+ function _parsePlayListsResponse($resp) {\r
+ if ( is_null($resp) ) {\r
+ return NULL;\r
+ } else {\r
+ $plistArray = array();\r
+ $plistLine = strtok($resp,"\n");\r
+ $plistFile = "";\r
+ $plCounter = -1;\r
+ while ( $plistLine ) {\r
+ list ( $element, $value ) = explode(": ",$plistLine);\r
+ if($element == "playlist") {\r
+ $plCounter++;\r
+ $plistArray[$plCounter]['name']=$value;\r
+ }\r
+ if($element == "Last-Modified") {\r
+ $plistArray[$plCounter]['timestamp']=$value;\r
+ }\r
+ $plistLine = strtok("\n");\r
+ } \r
+ }\r
+ return $plistArray;\r
+ }\r
+\r
/* RefreshInfo() \r
* \r
* Updates all class properties with the values from the MPD server.\r
}\r
}\r
\r
+ // Get list of lists\r
+ $plStr = $this->SendCommand(MPD_CMD_LISTS);\r
+ $this->playlists = $this->_parsePlayListsResponse($plStr);\r
+\r
// Get the Playlist\r
$plStr = $this->SendCommand(MPD_CMD_PLLIST);\r
$this->playlist = $this->_parseFileListResponse($plStr);\r
<table>
<tr>
<td><span class="button" onclick="EditPlayList()"><img width="20" src="images/songs.png"></span><td>
+ <td><span class="button" onclick="LoadPlayList()"><img width="20" src="images/lists.png"></span><td>
<td><span class="button" onclick="return confirm('Очистить список. Вы уверены?') ? PlaylistCommand('clear') : false;" ><img width="20" src="images/removeall.png"></span><td>
<td><span class="button" onclick="PlaylistItemsCommand('removeselected')"><img width="20" src="images/removeselected.png"></span><td>
</tr>