From 585224f5dbe2565ed04c97b054e8d8354c21dc5e Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Wed, 28 Sep 2016 22:35:19 +0300 Subject: [PATCH 1/1] =?utf8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?utf8?q?=D0=B0=20=D0=BF=D0=BB=D0=B5=D0=B9=D0=BB=D0=B8=D1=81=D1=82=D0=BE?= =?utf8?q?=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ajax/editplaylist.php | 2 +- ajax/mpd.js | 57 ++++++++++++++++++++++++++++- ajax/playlist.php | 4 +- ajax/playlists.php | 45 +++++++++++++++++++++++ ajax/trackname.php | 24 ++++++++++++ images/lists.png | Bin 0 -> 958 bytes model/tracklist.php | 4 ++ system/mpd_class.php | 45 +++++++++++++++++++++++ view/default/tmpl/playlistmenu.php | 1 + 9 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 ajax/playlists.php create mode 100644 ajax/trackname.php create mode 100644 images/lists.png diff --git a/ajax/editplaylist.php b/ajax/editplaylist.php index 28a6d3a..a4764c9 100644 --- a/ajax/editplaylist.php +++ b/ajax/editplaylist.php @@ -26,7 +26,7 @@ $dir = $_REQUEST['dir'];
- + GetDir($dir); diff --git a/ajax/mpd.js b/ajax/mpd.js index 1fe1a82..fec89c6 100644 --- a/ajax/mpd.js +++ b/ajax/mpd.js @@ -6,7 +6,6 @@ var req = new XMLHttpRequest(); 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); @@ -14,6 +13,19 @@ req.send(); } +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(); @@ -66,6 +78,7 @@ req.send(); function RefreshPageStatus() { + RefreshTitle(); RefreshNowPlaying(); RefreshPlayerState(); RefreshRepeatState(); @@ -103,6 +116,20 @@ req.send(); } +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(); @@ -138,6 +165,20 @@ req.send(); } +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(); @@ -152,6 +193,20 @@ req.send(); } +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) { diff --git a/ajax/playlist.php b/ajax/playlist.php index 78fe8ad..8050bba 100644 --- a/ajax/playlist.php +++ b/ajax/playlist.php @@ -5,12 +5,11 @@ include('mpd.php'); $cur_track= $mpd->current_track_id; $playlist= $mpd->playlist; ?> -
TitleControlНазваниеУправление
- + playlist;
TitleControlsНазваниеУправление
- diff --git a/ajax/playlists.php b/ajax/playlists.php new file mode 100644 index 0000000..eaf4415 --- /dev/null +++ b/ajax/playlists.php @@ -0,0 +1,45 @@ + + +
+ + + +
+ +
+
+ +
+ + + + +playlists; + +for($i=0;$i + "> + + + + + +
Название
+
+ +
+ + + +
+ +
+
diff --git a/ajax/trackname.php b/ajax/trackname.php new file mode 100644 index 0000000..49cc01d --- /dev/null +++ b/ajax/trackname.php @@ -0,0 +1,24 @@ +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 "Трек не выбран"; +} + +?> diff --git a/images/lists.png b/images/lists.png new file mode 100644 index 0000000000000000000000000000000000000000..cbae3018ee023b9739c3661f149a438464dec845 GIT binary patch literal 958 zcmV;v13~Zv~Pb{>EO5T59 zV`C7JL_`!(Qi$59SfzM~C@4hH?4Fs=;+(U4cJI61OYSsx_nzJPX1@8(oLOT->n@!Z za!^1x<8_)`-|)l-wuwJm54a;m%8unDXawMB2%=qc4j=!-t_%3zi#wWUr8e7eB**G{ zIHCrZa$s_9eCjLP82F!$PpUeeXQK#=KsA`C;67y_${Nm1C%(0{z<+=Atj3Ho#nuEd z0_8O+QVHB_iSsCI#TM1zQa>T^w;=h_ppYH!~0Ba zwAA?EV1MrzM^0U4fA82@up_4~57(Z$L5!2~0QTE^kE=?biCUdIPkg>r#{0WBGw7!7 za|D7#q^_tpCXFFSw>slCvsIS711}jP1ek#Y3r{^JCu&qx$?_$TO~6`H-)FdX(-wU# z!aG#Bw}=uz*&Z9zxcz?~m`gbTEjJCja{d7gdog^{JnlaG(^fV9`4xi#s)Ag>7vVjl zxXN!ic{Ww`suF|-Tuen*C6>j|I6MsklRIMj8dqQ|zcR2Wz}|PIE&9;fRF1TDs-82j zRO1+HTLY-du^(Q)N5}~|=A)`368FCL=Tb|$3@D@4rSV1aQ|D(&SOs_C54l(U$mv+NLn74tnAOpeQg-+npTWHU%r4^ z;8qVq2Wn!O1fkj1VG0iL;5lsNu=mCD1^giDTCcMVYCDt;@GN-fZEWp$``MWZbF3@3 zt$F6*cUV8(R{Qk1#+Nqv<~aDVN8V-gfxfj%JJakZBC8H;rUAjD=efR5n7Lg%on32% g*s3lb+uO|Nf1jQ*pb(o2i2wiq07*qoM6N<$g7$~M#Q*>R literal 0 HcmV?d00001 diff --git a/model/tracklist.php b/model/tracklist.php index 798ca01..234cc94 100644 --- a/model/tracklist.php +++ b/model/tracklist.php @@ -41,6 +41,10 @@ switch($task) { $mpd->PLAdd($item); break; + case("load"): + $mpd->PLLoad($item); + break; + case("adddir"): addDir($item,$mpd); break; diff --git a/system/mpd_class.php b/system/mpd_class.php index 6f9f1ac..38769e3 100644 --- a/system/mpd_class.php +++ b/system/mpd_class.php @@ -51,6 +51,7 @@ define("MPD_CMD_PLSWAPTRACK", "swap"); define("MPD_CMD_PLMOVETRACK", "move"); define("MPD_CMD_PASSWORD", "password"); define("MPD_CMD_TABLE", "list"); +define("MPD_CMD_LISTS", "listplaylists"); // Predefined MPD Response messages define("MPD_RESPONSE_ERR", "ACK"); @@ -417,6 +418,17 @@ class mpd { return $resp; } + /* PLList() + * + * Retrieves the playlists info. + */ + function PLList() { + if ( $this->debugging ) echo "mpd->PLList()\n"; + if ( ! is_null($resp = $this->SendCommand(MPD_CMD_LISTS))) $this->RefreshInfo(); + if ( $this->debugging ) echo "mpd->PLList() / return\n"; + return $resp; + } + /* PLSave() * * Saves the playlist to .m3u for later retrieval. The file is saved in the MPD playlist @@ -814,6 +826,35 @@ class mpd { return $plistArray; } + /* _parsePlayListsResponse() + * + * Builds a multidimensional array with MPD response lists. + * + * NOTE: This function is used internally within the class. It should not be used. + */ + function _parsePlayListsResponse($resp) { + if ( is_null($resp) ) { + return NULL; + } else { + $plistArray = array(); + $plistLine = strtok($resp,"\n"); + $plistFile = ""; + $plCounter = -1; + while ( $plistLine ) { + list ( $element, $value ) = explode(": ",$plistLine); + if($element == "playlist") { + $plCounter++; + $plistArray[$plCounter]['name']=$value; + } + if($element == "Last-Modified") { + $plistArray[$plCounter]['timestamp']=$value; + } + $plistLine = strtok("\n"); + } + } + return $plistArray; + } + /* RefreshInfo() * * Updates all class properties with the values from the MPD server. @@ -849,6 +890,10 @@ class mpd { } } + // Get list of lists + $plStr = $this->SendCommand(MPD_CMD_LISTS); + $this->playlists = $this->_parsePlayListsResponse($plStr); + // Get the Playlist $plStr = $this->SendCommand(MPD_CMD_PLLIST); $this->playlist = $this->_parseFileListResponse($plStr); diff --git a/view/default/tmpl/playlistmenu.php b/view/default/tmpl/playlistmenu.php index cb8113a..7c34930 100644 --- a/view/default/tmpl/playlistmenu.php +++ b/view/default/tmpl/playlistmenu.php @@ -2,6 +2,7 @@ -- 2.34.1
+