1
0
mirror of https://github.com/danbee/neompc synced 2025-03-04 08:39:10 +00:00

+ Added metadata browse mode. Unfinished. Still need to add the crumb trail across the top and make the play/play all buttons work.

This commit is contained in:
Dan Barber 2007-05-11 14:18:07 +00:00
parent 380e95b06e
commit 9d8cf6704d
7 changed files with 163 additions and 68 deletions

View File

@ -4,10 +4,18 @@
** NeoMPC Config File
**************************************/
/* Config relating to the display of CD covers */
/******** THIS IS NOT YET IMPLEMENTED! *********/
$_CONFIG['music_directory'] = '/var/lib/mpd/music';
$_CONFIG['album_cover_name'] = 'folder.jpg';
/***********************************************/
/* Template to use for displaying the pages */
$_CONFIG['template'] = 'default';
/* Browse mode can be 'filesystem' or 'metadata' */
$_CONFIG['browse_mode'] = 'metadata';
$_CONFIG['sort_by_tracknumber'] = true;
?>

BIN
images/album.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

BIN
images/artist.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

View File

@ -67,15 +67,4 @@
$page = 'playlist';
}
/* do the same with the current browse position */
if ($_GET['browse']) {
$browse = $_GET['browse'];
setcookie('browse', stripslashes($browse));
}
else {
$browse = $_COOKIE['browse'];
}
$browse = stripslashes($browse);
?>

View File

@ -17,67 +17,157 @@
$smarty->assign('current_artist', $current_track['Artist']);
$smarty->assign('current_file', $current_track['file']);
break;
case "browse":
/* make the path array */
if ($browse == '/') {
$browse = '';
}
$browse_list = explode('/', $browse);
case "browse":
switch ($_CONFIG['browse_mode']) {
//print_r($browse);
if ($browse) {
foreach ($browse_list as $browse_item) {
$path .= $browse_item . '/';
$dir_list[] = array('path' => trim($path, '/'), 'name' => $browse_item);
}
}
$smarty->assign('dir_list', $dir_list);
if (!$browselist) {
$browselist = $mympd->GetDir($browse);
}
case 'metadata': /* metadata based browsing. this will list artists->albums->tracks */
/* split the browse get var if present */
if ($_GET['browse']) {
if ($_GET['browse'] == '/') {
$browse_bits[0] = 'artists';
}
else {
$browse_bits = split('::', $_GET['browse']);
}
}
//print_r($browse_bits);
if ($_CONFIG['sort_by_tracknumber']) {
usort($browselist, "track_sort");
}
/* set the meta_level */
if ($browse_bits[0]) {
$meta_level = $browse_bits[0];
}
elseif ($_COOKIE['meta_level']) {
$meta_level = $_COOKIE['meta_level'];
}
else {
$meta_level = 'artists';
}
switch ($meta_level) { /* we need to get the information differently for different meta levels */
case 'artists':
$artists = $mympd->GetArtists();
foreach ($artists as $artist) {
$browselist[]['metaArtist'] = $artist;
}
break;
case 'albums':
$albums = $mympd->GetAlbums($browse_bits[1]);
foreach ($albums as $album) {
$browselist[]['metaAlbum'] = $album;
}
break;
case 'tracks':
$tracks = $mympd->Find(MPD_SEARCH_ALBUM, $browse_bits[1]);
/*
echo '<pre>';
print_r($tracks);
echo '</pre>';
//*/
/* foreach ($albums as $album) {
$browselist[]['metaAlbum'] = $album;
} */
$browselist = $tracks;
if ($_CONFIG['sort_by_tracknumber']) {
usort($browselist, "track_sort");
}
break;
}
$smarty->assign('browselist', $browselist);
break;
/*
echo '<pre>';
print_r($browselist);
echo '</pre>';
//*/
foreach ($browselist as $key => $browselist_item) {
case 'filesystem': /* filesystem based browsing. this will follow the filesystem tree */
if ($browselist_item['directory']) {
$lastpos = strrpos($browselist_item['directory'], '/');
if ($lastpos !== false) {
$browselist[$key]['directory_name'] = substr($browselist_item['directory'], $lastpos + 1);
/* get the browse position from the cookie or from get */
if ($_GET['browse']) {
$browse = $_GET['browse'];
setcookie('browse', stripslashes($browse));
}
else {
$browselist[$key]['directory_name'] = $browselist_item['directory'];
}
}
/* add a token for files currently on the playlist */
foreach($mympd->playlist as $playlist_item) {
if ($browselist_item['file'] == $playlist_item['file']) {
$browselist[$key]['in_playlist'] = "1";
}
}
}
$browse = $_COOKIE['browse'];
}
$browse = stripslashes($browse);
$smarty->assign('browselist', $browselist);
/* make the path array */
if ($browse == '/') {
$browse = '';
}
$browse_list = explode('/', $browse);
//print_r($browse);
if ($browse) {
foreach ($browse_list as $browse_item) {
$path .= $browse_item . '/';
$dir_list[] = array('path' => trim($path, '/'), 'name' => $browse_item);
}
}
$smarty->assign('dir_list', $dir_list);
if (!$browselist) {
$browselist = $mympd->GetDir($browse);
}
if ($_CONFIG['sort_by_tracknumber']) {
usort($browselist, "track_sort");
}
/*
echo '<pre>';
print_r($browselist);
echo '</pre>';
//*/
foreach ($browselist as $key => $browselist_item) {
if ($browselist_item['directory']) {
$lastpos = strrpos($browselist_item['directory'], '/');
if ($lastpos !== false) {
$browselist[$key]['directory_name'] = substr($browselist_item['directory'], $lastpos + 1);
}
else {
$browselist[$key]['directory_name'] = $browselist_item['directory'];
}
}
/* add a token for files currently on the playlist */
foreach($mympd->playlist as $playlist_item) {
if ($browselist_item['file'] == $playlist_item['file']) {
$browselist[$key]['in_playlist'] = "1";
}
}
}
$smarty->assign('browselist', $browselist);
break;
}
//echo '<pre style="text-align: left;">';
//print_r($mympd->GetDir($browse));

View File

@ -1,6 +1,6 @@
<ul id="crumb_trail">
<li>&bull; <a href="index.php?browse=/"><img src="images/home.gif" alt="Home" /></a></li>
<li><a href="index.php?browse=/"><img src="images/home.gif" alt="Home" /></a></li>
{foreach from=$dir_list item=dir_list_item}
<li>&bull; <a href="index.php?browse={$dir_list_item.path|escape:'url'}">{$dir_list_item.name|escape:'html'}</a></li>

View File

@ -1,9 +1,17 @@
{if $browselist_item.directory}
<li><a href="index.php?browse={$browselist_item.directory|escape:'url'}"><img src="images/dir.gif" class="icon" /> {$browselist_item.directory_name|escape:'html'}</a></li>
<li><a href="index.php?browse={$browselist_item.directory|escape:'url'}"><img src="images/dir.gif" class="icon" /> {$browselist_item.directory_name|escape:'html'}</a></li>
{elseif $browselist_item.metaArtist}
{else}
<li><a href="index.php?browse=albums::{$browselist_item.metaArtist|escape:'url'}"><img src="images/artist.gif" class="icon" /> {$browselist_item.metaArtist|escape:'html'}</a></li>
{elseif $browselist_item.metaAlbum}
<li><a href="index.php?browse=tracks::{$browselist_item.metaAlbum|escape:'url'}"><img src="images/album.gif" class="icon" /> {$browselist_item.metaAlbum|escape:'html'}</a></li>
{elseif $browselist_item.Title}
{if $browselist_item.in_playlist}<li style="background: #555;">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file|escape:'url'}"><img src="images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file|escape:'url'}"><img src="images/play.gif" alt="Play" class="button" /></a><img src="images/note.gif" class="icon" /> {if $browselist_item.Title|escape:'html'}<span class="title">{$browselist_item.Title|escape:'html'}</span><br /><span class="artist">{$browselist_item.Artist|escape:'html'}</span> <span class="album">({$browselist_item.Album|escape:'html'})</span>{else}{$browselist_item.file|escape:'html'}{/if}</li>