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

Bunch of nice changes;

* Problems with / characters in artist names (eg, AC/DC).
* Added server config options to config.inc.php
* Files without title tags now display using the filename instead.
This commit is contained in:
Dan Barber 2008-01-08 14:46:35 +00:00
parent 92f7e15aa7
commit f4d0e75c24
8 changed files with 60 additions and 20 deletions

View File

@ -4,6 +4,11 @@
** NeoMPC Config File
**************************************/
/* Server details */
$_CONFIG['server'] = 'localhost';
$_CONFIG['password'] = '';
$_CONFIG['port'] = '6600';
/* Config relating to the display of CD covers */
/* music_directory must match you MPD music_directory config */
$_CONFIG['music_directory'] = '/home/danbee/Music';
@ -14,6 +19,7 @@
/* Browse mode can be 'filesystem' or 'metadata' */
$_CONFIG['browse_mode'] = 'metadata';
//$_CONFIG['browse_mode'] = 'filesystem';
$_CONFIG['sort_by_tracknumber'] = true;

View File

@ -75,7 +75,7 @@
global $_CONFIG, $mympd;
if ($browse == '/') {
if ($browse == $_CONFIG['separator']) {
$browse = '';
}
@ -107,8 +107,8 @@
case 'metadata':
$browse_bits = split('/', $browse);
$browse_bits = explode($_CONFIG['separator'], $browse);
if (is_array($browse_bits)) {
if ($browse_bits[1]) {

View File

@ -11,7 +11,16 @@
$_COOKIE = array_map('stripslashes', $_COOKIE);
}
require('config/config.inc.php');
require('config/config.inc.php');
switch ($_CONFIG['browse_mode']) {
case 'filesystem':
$_CONFIG['separator'] = '/';
break;
case 'metadata':
$_CONFIG['separator'] = '|';
break;
}
define('SMARTY_DIR', 'lib/smarty/libs/');
require(SMARTY_DIR . 'Smarty.class.php');
@ -26,8 +35,13 @@
require("templates/${_CONFIG['template']}/config.inc.php");
include('lib/mpd.class.php');
$mympd = new mpd('localhost',6600);
include('lib/mpd.class.php');
if ($_CONFIG['password'] != '') {
$mympd = new mpd($_CONFIG['server'], $_CONFIG['port'], $_CONFIG['password']);
}
else {
$mympd = new mpd($_CONFIG['server'], $_CONFIG['port']);
}
if (!$mympd->connected) {
echo "<p>Problem connecting to MPD!</p>";

View File

@ -14,7 +14,12 @@
$smarty->assign('show_extra_track_info', $_CONFIG['playlist_extra_track_info']);
$smarty->assign('playlist', $mympd->playlist);
$playlist = $mympd->playlist;
foreach ($playlist as $key => $playlist_item) {
$playlist[$key]['file_name'] = substr($playlist_item['file'], strrpos($playlist_item['file'], '/') + 1);
}
$smarty->assign('playlist', $playlist);
$smarty->assign('playing', $mympd->current_track_id);
break;
case "control":
@ -25,6 +30,7 @@
$smarty->assign('current_album', $current_track['Album']);
$smarty->assign('current_artist', $current_track['Artist']);
$smarty->assign('current_file', $current_track['file']);
$smarty->assign('current_filename', substr($current_track['file'], strrpos($current_track['file'], '/') + 1));
$smarty->assign('song_length', $mympd->current_track_length);
$smarty->assign('song_position', $mympd->current_track_position);
$smarty->assign('mpd_state', $mympd->state);
@ -64,15 +70,17 @@
switch ($_CONFIG['browse_mode']) {
case 'metadata': /* metadata based browsing. this will list artists->albums->tracks */
$home_link = 'index.php?browse=|';
/* split the browse get var if present */
if ($_GET['browse']) {
setcookie('browse', $_GET['browse']);
if ($_GET['browse'] == '/') {
if ($_GET['browse'] == '|') {
$meta_level = 'artists';
}
else {
$browse_bits = split('/', $_GET['browse']);
$browse_bits = explode('|', $_GET['browse']);
if ($browse_bits[0]) {
$artist = $browse_bits[0];
$meta_level = 'albums';
@ -84,11 +92,11 @@
}
}
elseif ($_COOKIE['browse']) {
if ($_COOKIE['browse'] == '/') {
if ($_COOKIE['browse'] == '|') {
$meta_level = 'artists';
}
else {
$browse_bits = split('/', $_COOKIE['browse']);
$browse_bits = explode('|', $_COOKIE['md_browse']);
if ($browse_bits[0]) {
$artist = $browse_bits[0];
$meta_level = 'albums';
@ -121,7 +129,7 @@
$albums = $mympd->GetAlbums($artist);
foreach ($albums as $the_album) {
$browselist[] = array('metaAlbum' => $the_album, 'path' => $artist . '/' . $the_album);
$browselist[] = array('metaAlbum' => $the_album, 'path' => $artist . '|' . $the_album);
}
$dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode($artist)));
@ -148,18 +156,21 @@
usort($browselist, "track_sort");
}
$dir_list = array(array('name' => $artist, 'path' => urlencode($artist)), array('name' => $album, 'path' => urlencode($artist . '/' . $album)));
$dir_list = array(array('name' => $artist, 'path' => urlencode($artist)), array('name' => $album, 'path' => urlencode($artist . '|' . $album)));
break;
}
$smarty->assign('dir_list', $dir_list);
$smarty->assign('browselist', $browselist);
$smarty->assign('home_link', $home_link);
break;
case 'filesystem': /* filesystem based browsing. this will follow the filesystem tree */
$home_link = 'index.php?browse=/';
/* get the browse position from the cookie or from get */
if ($_GET['browse']) {
$browse = $_GET['browse'];
@ -169,7 +180,8 @@
$browse = $_COOKIE['browse'];
}
$browse = $browse;
//$browse = $browse;
// ^ wtf?!?
/* make the path array */
@ -207,8 +219,7 @@
//*/
foreach ($browselist as $key => $browselist_item) {
if ($browselist_item['directory']) {
$lastpos = strrpos($browselist_item['directory'], '/');
if ($lastpos !== false) {
@ -222,7 +233,11 @@
/* add a token for files currently on the playlist */
foreach($mympd->playlist as $playlist_item) {
$lastpos = strrpos($browselist_item['file'], '/');
$browselist[$key]['file_name'] = substr($browselist_item['file'], $lastpos + 1);
if ($browselist_item['file'] == $playlist_item['file']) {
$browselist[$key]['in_playlist'] = "1";
}
}
@ -231,6 +246,7 @@
//print_r($browselist);
$smarty->assign('browselist', $browselist);
$smarty->assign('home_link', $home_link);
break;
}

View File

@ -1,6 +1,6 @@
<ul id="crumb_trail">
<li><a href="index.php?browse=/"><img src="templates/{$template}/images/home.gif" alt="Home" /></a></li>
<li><a href="{$home_link}"><img src="templates/{$template}/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}">{$dir_list_item.name|escape:'html'}</a></li>

View File

@ -13,6 +13,10 @@
{elseif $browselist_item.Title}
{if $browselist_item.in_playlist}<li class="playing">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file|escape:'url'}"><img src="templates/{$template}/images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file|escape:'url'}"><img src="templates/{$template}/images/play.gif" alt="Play" class="button" /></a><img src="templates/{$template}/images/note.gif" class="icon" /> {if $browselist_item.Title|escape:'html'}<span class="title">{$browselist_item.Title|escape:'html'}</span>{if $browselist_item.Artist && $show_extra_track_info}<br /><span class="artist">{$browselist_item.Artist|escape:'html'}</span> {if $browselist_item.Album}<span class="album">({$browselist_item.Album|escape:'html'})</span>{/if}{/if}{else}{$browselist_item.file|escape:'html'}{/if}</li>
{if $browselist_item.in_playlist}<li class="playing">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file|escape:'url'}"><img src="templates/{$template}/images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file|escape:'url'}"><img src="templates/{$template}/images/play.gif" alt="Play" class="button" /></a><img src="templates/{$template}/images/note.gif" class="icon" /> {if $browselist_item.Title|escape:'html'}<span class="title">{$browselist_item.Title|escape:'html'}</span>{if $browselist_item.Artist && $show_extra_track_info}<br /><span class="artist">{$browselist_item.Artist|escape:'html'}</span> {if $browselist_item.Album}<span class="album">({$browselist_item.Album|escape:'html'})</span>{/if}{/if}{else}{$browselist_item.file_name|escape:'html'}{/if}</li>
{elseif $browselist_item.file}
{if $browselist_item.in_playlist}<li class="playing">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file|escape:'url'}"><img src="templates/{$template}/images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file|escape:'url'}"><img src="templates/{$template}/images/play.gif" alt="Play" class="button" /></a><img src="templates/{$template}/images/note.gif" class="icon" /> {if $browselist_item.Title|escape:'html'}<span class="title">{$browselist_item.Title|escape:'html'}</span>{if $browselist_item.Artist && $show_extra_track_info}<br /><span class="artist">{$browselist_item.Artist|escape:'html'}</span> {if $browselist_item.Album}<span class="album">({$browselist_item.Album|escape:'html'})</span>{/if}{/if}{else}{$browselist_item.file_name|escape:'html'}{/if}</li>
{/if}

View File

@ -1,6 +1,6 @@
<div id="controls"><a href="index.php?action=prev"><img src="templates/{$template}/images/prev_button.gif" Alt="Previous" /></a><a href="index.php?action=play"><img src="templates/{$template}/images/play_button.gif" Alt="Play" /></a><a href="index.php?action=pause"><img src="templates/{$template}/images/pause_button.gif" Alt="Pause" /></a><a href="index.php?action=stop"><img src="templates/{$template}/images/stop_button.gif" Alt="Stop" /></a><a href="index.php?action=next"><img src="templates/{$template}/images/next_button.gif" Alt="Next" /></a></div>
<div id="song_display">{if $current_title}<span class="pos">{$current_track_no+1|string_format:"%02d"}.</span> <span class="title">{$current_title}</span><br /><span class="artist">{$current_artist}</span> {if $current_album}<!--<span class="album">({$current_album})</span>-->{/if}{elseif $current_file}{$current_file}{else}<br />[Nothing playing]{/if}</div>
<div id="song_display">{if $current_title}<span class="pos">{$current_track_no+1|string_format:"%02d"}.</span> <span class="title">{$current_title}</span><br /><span class="artist">{$current_artist}</span> {if $current_album}<!--<span class="album">({$current_album})</span>-->{/if}{elseif $current_filename}{$current_filename}{else}<br />[Nothing playing]{/if}</div>
{if $mpd_state == 'play' || $mpd_state == 'pause'}<div id="tracktime"><span id="min">{$initialmin}</span>:<span id="sec">{$initialsec}</span> <span id="total">({$totalmin}:{$totalsec})</span></div>{/if}

View File

@ -1 +1 @@
{if $playlist_item.Pos == $playing}<li class="playing">{else}<li>{/if}<a href="{$playlist_remove_link}{$playlist_item.Pos}"><img src="templates/{$template}/images/del.gif" alt="Remove from Playlist" class="button" /></a><a href="{$playlist_play_link}{$playlist_item.Pos}"><img src="templates/{$template}/images/play.gif" alt="Play" class="button" /></a><img src="templates/{$template}/images/note.gif" class="icon" /> <span class="pos">{$playlist_item.Pos+1|string_format:"%02d"}.</span> {if $playlist_item.Title}<span class="title">{$playlist_item.Title}</span>{if $playlist_item.Artist && $show_extra_track_info}<br /><span class="artist">{$playlist_item.Artist}</span> {if $playlist_item.Album}<span class="album">({$playlist_item.Album})</span>{/if}{/if}{else}{$playlist_item.file}{/if}</li>
{if $playlist_item.Pos == $playing}<li class="playing">{else}<li>{/if}<a href="{$playlist_remove_link}{$playlist_item.Pos}"><img src="templates/{$template}/images/del.gif" alt="Remove from Playlist" class="button" /></a><a href="{$playlist_play_link}{$playlist_item.Pos}"><img src="templates/{$template}/images/play.gif" alt="Play" class="button" /></a><img src="templates/{$template}/images/note.gif" class="icon" /> <span class="pos">{$playlist_item.Pos+1|string_format:"%02d"}.</span> {if $playlist_item.Title}<span class="title">{$playlist_item.Title}</span>{if $playlist_item.Artist && $show_extra_track_info}<br /><span class="artist">{$playlist_item.Artist}</span> {if $playlist_item.Album}<span class="album">({$playlist_item.Album})</span>{/if}{/if}{else}{$playlist_item.file_name}{/if}</li>