Skip to content

Commit

Permalink
Browse by Album/Artist (continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
ACXgit committed Nov 13, 2014
1 parent 216611e commit f87314c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 33 deletions.
23 changes: 18 additions & 5 deletions app/libs/runeaudio.php
Expand Up @@ -599,14 +599,14 @@ function browseDB($sock,$browsemode,$query) {
break;
case 'album':
if (isset($query) && !empty($query)){
sendMpdCommand($sock,'search "album" "'.html_entity_decode($query).'"');
sendMpdCommand($sock,'find "album" "'.html_entity_decode($query).'"');
} else {
sendMpdCommand($sock,'list "album"');
}
break;
case 'artist':
if (isset($query) && !empty($query)){
sendMpdCommand($sock,'search "artist" "'.html_entity_decode($query).'"');
sendMpdCommand($sock,'list "album" "'.html_entity_decode($query).'"');
} else {
sendMpdCommand($sock,'list "artist"');
}
Expand Down Expand Up @@ -636,7 +636,7 @@ function remTrackQueue($sock, $songpos)
return $datapath;
}

function addQueue($sock, $path, $addplay = null, $pos = null)
function addToQueue($sock, $path, $addplay = null, $pos = null)
{
$fileext = parseFileStr($path,'.');
if ($fileext == 'm3u' OR $fileext == 'pls' OR $fileext == 'cue') {
Expand All @@ -662,6 +662,19 @@ function addQueue($sock, $path, $addplay = null, $pos = null)
}
}

function addAlbumToQueue($sock, $path, $addplay = null, $pos = null)
{
if (isset($addplay)) {
$cmdlist = "command_list_begin\n";
$cmdlist .= "findadd \"album\" \"".html_entity_decode($path)."\"\n";
$cmdlist .= "play ".$pos."\n";
$cmdlist .= "command_list_end";
sendMpdCommand($sock, $cmdlist);
} else {
sendMpdCommand($sock, "findadd \"album\" \"".html_entity_decode($path)."\"");
}
}

/*
class globalRandom extends Thread
{
Expand All @@ -683,7 +696,7 @@ public function run()
}
$path = randomSelect($mpd);
if ($path) {
addQueue($mpd,$path);
addToQueue($mpd,$path);
runelog("global random call",$path);
ui_notify('Global Random Mode', htmlentities($path,ENT_XML1,'UTF-8').' added to current Queue');
}
Expand Down Expand Up @@ -1084,7 +1097,7 @@ function rp_addPlay($path, $mpd, $pos)
$song = parseFileStr($path,"/");
$ramplaypath = "ramplay/".$song;
$_SESSION['DEBUG'] .= "rp_addPlay:$id $song $path $pos|";
addQueue($mpd, $ramplaypath);
addToQueue($mpd, $ramplaypath);
sendMpdCommand($mpd, 'play '.$pos);
}

Expand Down
7 changes: 7 additions & 0 deletions app/templates/playback.php
Expand Up @@ -197,6 +197,13 @@
<li><a href="javascript:;" data-cmd="pl-rm"><i class="fa fa-trash-o sx"></i> Delete</a></li>
</ul>
</div>
<div id="context-menu-album" class="context-menu">
<ul class="dropdown-menu" role="menu">
<li><a href="javascript:;" data-cmd="albumadd"><i class="fa fa-plus-circle sx"></i> Add</a></li>
<li><a href="javascript:;" data-cmd="albumaddplay"><i class="fa fa-play sx"></i> Add and play</a></li>
<li><a href="javascript:;" data-cmd="albumaddreplaceplay"><i class="fa fa-share-square-o sx"></i> Add, replace and play</a></li>
</ul>
</div>
</div>
<div id="modal-pl-save" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal-pl-save-label" aria-hidden="true">
<div class="modal-dialog">
Expand Down
28 changes: 8 additions & 20 deletions assets/js/runeui.js
Expand Up @@ -828,7 +828,7 @@ function parseResponse(options) {

// DEBUG
// console.log('parseResponse OPTIONS: inputArr = ' + inputArr + ', respType = ' + respType + ', i = ' + i + ', inpath = ' + inpath +', querytype = ' + querytype);
// console.log(inputArr);
console.log(inputArr);

switch (respType) {
case 'playlist':
Expand Down Expand Up @@ -915,21 +915,17 @@ function parseResponse(options) {
} else if (inputArr.album !== '') {
content = '<li id="db-' + (i + 1) + '" class="db-folder db-album" data-path="';
content += inputArr.album;
content += '"><i class="fa fa-bars db-action" title="Actions" data-toggle="context" data-target="#context-menu"></i><span><i class="fa fa-dot-circle-o"></i>';
content += '"><i class="fa fa-bars db-action" title="Actions" data-toggle="context" data-target="#context-menu-album"></i><span><i class="fa fa-dot-circle-o"></i>';
content += inputArr.album;
content += '</span></li>';
}
} else if (GUI.browsemode === 'artist') {
// browse by artist
if (inputArr.file !== undefined) {
content = '<li id="db-' + (i + 1) + '" data-path="';
content += inputArr.file;
content += '"><i class="fa fa-bars db-action" title="Actions" data-toggle="context" data-target="#context-menu-file"></i><i class="fa fa-music db-icon"></i><span class="sn">';
content += inputArr.Title + ' <span>' + timeConvert(inputArr.Time) + '</span></span>';
content += ' <span class="bl">';
content += inputArr.Artist;
content += ' - ';
content += inputArr.Album;
if (inputArr.album !== undefined) {
content = '<li id="db-' + (i + 1) + '" class="db-folder db-album" data-path="';
content += inputArr.album;
content += '"><i class="fa fa-bars db-action" title="Actions" data-toggle="context" data-target="#context-menu-album"></i><span><i class="fa fa-dot-circle-o"></i>';
content += (inputArr.album !== '') ? inputArr.album : 'Unknown album';
content += '</span></li>';
} else if (inputArr.artist !== '') {
content = '<li id="db-' + (i + 1) + '" class="db-folder db-artist" data-path="';
Expand Down Expand Up @@ -1113,7 +1109,7 @@ function populateDB(options){
inpath: path
});
}
if (path === 'Webradio') {
if (path === 'Webradio') {
content += '<li id="webradio-add" class="db-webradio-add"><i class="fa fa-plus-circle db-icon"></i><span class="sn"><em>add new</em></span><span class="bl">add a webradio to your library</span></li>';
}
document.getElementById('database-entries').innerHTML = content;
Expand Down Expand Up @@ -1209,14 +1205,6 @@ function getDB(options){
uplevel: uplevel
});
}, 'json');
// } else if (cmd === 'album') {
// $.post('/db/?cmd=album', { 'albumname': path, 'browsemode': GUI.browsemode }, function(data) {
// populateDB({
// data: data,
// path: path,
// uplevel: uplevel
// });
// }, 'json');
} else {
// EXAMPLE: cmd === 'update', 'addplay', 'addreplaceplay', 'update'
loadingSpinner('db', 'hide');
Expand Down
4 changes: 2 additions & 2 deletions assets/js/runeui.min.js

Large diffs are not rendered by default.

43 changes: 37 additions & 6 deletions db/index.php
Expand Up @@ -70,9 +70,9 @@
case 'add':
if ($activePlayer === 'MPD') {
if (isset($_POST['path'])) {
addQueue($mpd, $_POST['path']);
addToQueue($mpd, $_POST['path']);
// send MPD response to UI
ui_mpd_response($mpd, array('title' => 'Added to playlist', 'text' => $_POST['path']));
ui_mpd_response($mpd, array('title' => 'Added to queue', 'text' => $_POST['path']));
}
}
break;
Expand All @@ -81,20 +81,20 @@
if (isset($_POST['path'])) {
$status = _parseStatusResponse(MpdStatus($mpd));
$pos = $status['playlistlength'] ;
addQueue($mpd, $_POST['path'], 1, $pos);
addToQueue($mpd, $_POST['path'], 1, $pos);
// send MPD response to UI
ui_mpd_response($mpd, array('title' => 'Added to playlist', 'text' => $_POST['path']));
ui_mpd_response($mpd, array('title' => 'Added to queue', 'text' => $_POST['path']));
}
}
break;
case 'addreplaceplay':
if ($activePlayer === 'MPD') {
if (isset($_POST['path'])) {
sendMpdCommand($mpd, 'clear');
addQueue($mpd, $_POST['path']);
addToQueue($mpd, $_POST['path']);
sendMpdCommand($mpd, 'play');
// send MPD response to UI
ui_mpd_response($mpd, array('title' => 'Playlist cleared<br> Added to playlist', 'text' => $_POST['path']));
ui_mpd_response($mpd, array('title' => 'Queue cleared<br> Added to queue', 'text' => $_POST['path']));
}
}
break;
Expand Down Expand Up @@ -275,6 +275,37 @@
$proxy = $redis->hGetall('proxy');
print_r($proxy);
break;
case 'albumadd':
if ($activePlayer === 'MPD') {
if (isset($_POST['path'])) {
addAlbumToQueue($mpd, $_POST['path']);
// send MPD response to UI
ui_mpd_response($mpd, array('title' => 'Added to queue', 'text' => $_POST['path']));
}
}
break;
case 'albumaddplay':
if ($activePlayer === 'MPD') {
if (isset($_POST['path'])) {
$status = _parseStatusResponse(MpdStatus($mpd));
$pos = $status['playlistlength'] ;
addAlbumToQueue($mpd, $_POST['path'], 1, $pos);
// send MPD response to UI
ui_mpd_response($mpd, array('title' => 'Added to queue', 'text' => $_POST['path']));
}
}
break;
case 'albumaddreplaceplay':
if ($activePlayer === 'MPD') {
if (isset($_POST['path'])) {
sendMpdCommand($mpd, 'clear');
addAlbumToQueue($mpd, $_POST['path']);
sendMpdCommand($mpd, 'play');
// send MPD response to UI
ui_mpd_response($mpd, array('title' => 'Queue cleared<br> Added to queue', 'text' => $_POST['path']));
}
}
break;
}
} else {
echo 'MPD DB INTERFACE<br>';
Expand Down

0 comments on commit f87314c

Please sign in to comment.