mirror of
https://github.com/danbee/neompc
synced 2025-03-04 08:39:10 +00:00
+ Button at the top now lights up to let you know what mode you're at.
+ 'Add' and 'Play' buttons now recurse down the file tree. Be careful about hitting this button at the top level if you've got a big library! ~ Playlist now highlights currently playing track.
This commit is contained in:
parent
9d8cf6704d
commit
9a3fbae4fd
@ -14,7 +14,7 @@
|
|||||||
$_CONFIG['template'] = 'default';
|
$_CONFIG['template'] = 'default';
|
||||||
|
|
||||||
/* Browse mode can be 'filesystem' or 'metadata' */
|
/* Browse mode can be 'filesystem' or 'metadata' */
|
||||||
$_CONFIG['browse_mode'] = 'metadata';
|
$_CONFIG['browse_mode'] = 'filesystem';
|
||||||
|
|
||||||
$_CONFIG['sort_by_tracknumber'] = true;
|
$_CONFIG['sort_by_tracknumber'] = true;
|
||||||
|
|
||||||
|
|||||||
@ -19,20 +19,7 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "addall":
|
case "addall":
|
||||||
/* create the array of files for the playlist add */
|
addall($_COOKIE['browse']);
|
||||||
if ($browse == '/') {
|
|
||||||
$browse = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$browselist = $mympd->GetDir($browse);
|
|
||||||
|
|
||||||
foreach($browselist as $browselist_item) {
|
|
||||||
if ($browselist_item['file']) {
|
|
||||||
$addlist[] = $browselist_item['file'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$mympd->PLAddBulk($addlist);
|
|
||||||
$page = 'playlist';
|
$page = 'playlist';
|
||||||
setcookie('page', $page);
|
setcookie('page', $page);
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
@ -40,20 +27,9 @@
|
|||||||
|
|
||||||
case "playall":
|
case "playall":
|
||||||
$mympd->PLClear();
|
$mympd->PLClear();
|
||||||
/* create the array of files for the playlist add */
|
|
||||||
if ($browse == '/') {
|
|
||||||
$browse = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$browselist = $mympd->GetDir($browse);
|
addall($_COOKIE['browse']);
|
||||||
|
|
||||||
foreach($browselist as $browselist_item) {
|
|
||||||
if ($browselist_item['file']) {
|
|
||||||
$addlist[] = $browselist_item['file'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$mympd->PLAddBulk($addlist);
|
|
||||||
$page = 'control';
|
$page = 'control';
|
||||||
setcookie('page', $page);
|
setcookie('page', $page);
|
||||||
$mympd->Play();
|
$mympd->Play();
|
||||||
@ -94,4 +70,74 @@
|
|||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addall($browse) {
|
||||||
|
|
||||||
|
global $_CONFIG, $mympd;
|
||||||
|
|
||||||
|
if ($browse == '/') {
|
||||||
|
$browse = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($_CONFIG['browse_mode']) {
|
||||||
|
|
||||||
|
case 'filesystem':
|
||||||
|
|
||||||
|
function get_browselist($path) {
|
||||||
|
|
||||||
|
global $mympd;
|
||||||
|
|
||||||
|
$browselist = $mympd->GetDir($path);
|
||||||
|
|
||||||
|
foreach ($browselist as $browseitem) {
|
||||||
|
if ($browseitem['directory']) {
|
||||||
|
//echo $browseitem.directory;
|
||||||
|
$browselist = array_merge($browselist, get_browselist($browseitem['directory']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $browselist;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create the array of files for the playlist add */
|
||||||
|
$browselist = get_browselist($browse);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'metadata':
|
||||||
|
|
||||||
|
$browse_bits = split('/', $browse);
|
||||||
|
|
||||||
|
if (is_array($browse_bits)) {
|
||||||
|
|
||||||
|
if ($browse_bits[1]) {
|
||||||
|
$album = $browse_bits[1];
|
||||||
|
$browselist = $mympd->Find(MPD_SEARCH_ALBUM, $album);
|
||||||
|
}
|
||||||
|
elseif ($browse_bits[0]) {
|
||||||
|
$artist = $browse_bits[0];
|
||||||
|
$browselist = $mympd->Find(MPD_SEARCH_ARTIST, $artist);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//$browselist = $mympd->Search(MPD_SEARCH_TITLE, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($browselist)) {
|
||||||
|
|
||||||
|
foreach($browselist as $browselist_item) {
|
||||||
|
if ($browselist_item['file']) {
|
||||||
|
$addlist[] = $browselist_item['file'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$mympd->PLAddBulk($addlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Smarty stuff */
|
/* Smarty stuff */
|
||||||
|
|
||||||
|
$version = 0.3;
|
||||||
|
|
||||||
require('config/config.inc.php');
|
require('config/config.inc.php');
|
||||||
|
|
||||||
define('SMARTY_DIR', 'lib/smarty/libs/');
|
define('SMARTY_DIR', 'lib/smarty/libs/');
|
||||||
@ -11,6 +13,8 @@
|
|||||||
$smarty->config_dir = 'smarty/configs/';
|
$smarty->config_dir = 'smarty/configs/';
|
||||||
$smarty->cache_dir = 'smarty/cache/';
|
$smarty->cache_dir = 'smarty/cache/';
|
||||||
|
|
||||||
|
$smarty->assign('version', $version);
|
||||||
|
|
||||||
include('lib/mpd.class.php');
|
include('lib/mpd.class.php');
|
||||||
$mympd = new mpd('localhost',6600);
|
$mympd = new mpd('localhost',6600);
|
||||||
|
|
||||||
@ -67,4 +71,6 @@
|
|||||||
$page = 'playlist';
|
$page = 'playlist';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$smarty->assign('page', $page);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
65
lib/page.php
65
lib/page.php
@ -6,7 +6,14 @@
|
|||||||
|
|
||||||
switch ($page) {
|
switch ($page) {
|
||||||
case "playlist":
|
case "playlist":
|
||||||
|
/*
|
||||||
|
echo '<pre>';
|
||||||
|
print_r($mympd->playlist);
|
||||||
|
echo '</pre>';
|
||||||
|
//*/
|
||||||
|
|
||||||
$smarty->assign('playlist', $mympd->playlist);
|
$smarty->assign('playlist', $mympd->playlist);
|
||||||
|
$smarty->assign('playing', $mympd->current_track_id);
|
||||||
break;
|
break;
|
||||||
case "control":
|
case "control":
|
||||||
/* get the currently playing track */
|
/* get the currently playing track */
|
||||||
@ -25,50 +32,70 @@
|
|||||||
|
|
||||||
/* split the browse get var if present */
|
/* split the browse get var if present */
|
||||||
if ($_GET['browse']) {
|
if ($_GET['browse']) {
|
||||||
|
setcookie('browse', stripslashes($_GET['browse']));
|
||||||
if ($_GET['browse'] == '/') {
|
if ($_GET['browse'] == '/') {
|
||||||
$browse_bits[0] = 'artists';
|
$meta_level = 'artists';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$browse_bits = split('::', $_GET['browse']);
|
$browse_bits = split('/', $_GET['browse']);
|
||||||
|
if ($browse_bits[0]) {
|
||||||
|
$artist = $browse_bits[0];
|
||||||
|
$meta_level = 'albums';
|
||||||
|
}
|
||||||
|
if ($browse_bits[1]) {
|
||||||
|
$album = $browse_bits[1];
|
||||||
|
$meta_level = 'tracks';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elseif ($_COOKIE['browse']) {
|
||||||
|
if ($_COOKIE['browse'] == '/') {
|
||||||
|
$meta_level = 'artists';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$browse_bits = split('/', $_COOKIE['browse']);
|
||||||
|
if ($browse_bits[0]) {
|
||||||
|
$artist = $browse_bits[0];
|
||||||
|
$meta_level = 'albums';
|
||||||
|
}
|
||||||
|
if ($browse_bits[1]) {
|
||||||
|
$album = $browse_bits[1];
|
||||||
|
$meta_level = 'tracks';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//print_r($browse_bits);
|
|
||||||
|
|
||||||
/* set the meta_level */
|
|
||||||
if ($browse_bits[0]) {
|
|
||||||
$meta_level = $browse_bits[0];
|
|
||||||
}
|
|
||||||
elseif ($_COOKIE['meta_level']) {
|
|
||||||
$meta_level = $_COOKIE['meta_level'];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$meta_level = 'artists';
|
$meta_level = 'artists';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//print_r($browse_bits);
|
||||||
|
|
||||||
switch ($meta_level) { /* we need to get the information differently for different meta levels */
|
switch ($meta_level) { /* we need to get the information differently for different meta levels */
|
||||||
|
|
||||||
case 'artists':
|
case 'artists':
|
||||||
$artists = $mympd->GetArtists();
|
$artists = $mympd->GetArtists();
|
||||||
|
|
||||||
foreach ($artists as $artist) {
|
foreach ($artists as $the_artist) {
|
||||||
$browselist[]['metaArtist'] = $artist;
|
$browselist[] = array('metaArtist' => $the_artist, 'path' => stripslashes($the_artist));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'albums':
|
case 'albums':
|
||||||
$albums = $mympd->GetAlbums($browse_bits[1]);
|
$albums = $mympd->GetAlbums($artist);
|
||||||
|
|
||||||
foreach ($albums as $album) {
|
foreach ($albums as $the_album) {
|
||||||
$browselist[]['metaAlbum'] = $album;
|
$browselist[] = array('metaAlbum' => $the_album, 'path' => stripslashes($artist . '/' . $the_album));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode(stripslashes($artist))));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'tracks':
|
case 'tracks':
|
||||||
|
|
||||||
$tracks = $mympd->Find(MPD_SEARCH_ALBUM, $browse_bits[1]);
|
$tracks = $mympd->Find(MPD_SEARCH_ALBUM, $album);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
echo '<pre>';
|
echo '<pre>';
|
||||||
@ -86,9 +113,12 @@
|
|||||||
usort($browselist, "track_sort");
|
usort($browselist, "track_sort");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode(stripslashes($artist))), array('name' => stripslashes($album), 'path' => urlencode(stripslashes($artist . '/' . $album))));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$smarty->assign('dir_list', $dir_list);
|
||||||
$smarty->assign('browselist', $browselist);
|
$smarty->assign('browselist', $browselist);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -120,7 +150,7 @@
|
|||||||
|
|
||||||
foreach ($browse_list as $browse_item) {
|
foreach ($browse_list as $browse_item) {
|
||||||
$path .= $browse_item . '/';
|
$path .= $browse_item . '/';
|
||||||
$dir_list[] = array('path' => trim($path, '/'), 'name' => $browse_item);
|
$dir_list[] = array('path' => urlencode(trim($path, '/')), 'name' => $browse_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -163,6 +193,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//print_r($browselist);
|
||||||
|
|
||||||
$smarty->assign('browselist', $browselist);
|
$smarty->assign('browselist', $browselist);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<li><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}
|
{foreach from=$dir_list item=dir_list_item}
|
||||||
<li>• <a href="index.php?browse={$dir_list_item.path|escape:'url'}">{$dir_list_item.name|escape:'html'}</a></li>
|
<li>• <a href="index.php?browse={$dir_list_item.path}">{$dir_list_item.name|escape:'html'}</a></li>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
|
|
||||||
{if $browselist_item.directory}
|
{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}"><img src="images/dir.gif" class="icon" /> {$browselist_item.directory_name|escape:'html'}</a></li>
|
||||||
|
|
||||||
{elseif $browselist_item.metaArtist}
|
{elseif $browselist_item.metaArtist}
|
||||||
|
|
||||||
<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>
|
<li><a href="index.php?browse={$browselist_item.path|escape:'url'}"><img src="images/artist.gif" class="icon" /> {$browselist_item.metaArtist|escape:'html'}</a></li>
|
||||||
|
|
||||||
{elseif $browselist_item.metaAlbum}
|
{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>
|
<li><a href="index.php?browse={$browselist_item.path|escape:'url'}"><img src="images/album.gif" class="icon" /> {$browselist_item.metaAlbum|escape:'html'}</a></li>
|
||||||
|
|
||||||
{elseif $browselist_item.Title}
|
{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>
|
{if $browselist_item.in_playlist}<li class="playing">{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>
|
||||||
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Neo MPC 0.2</title>
|
<title>Neo MPC {$version}</title>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="menu"><a href="{$browse_link}">Browse</a><a href="{$playlist_link}">Playlist</a><a href="{$control_link}">Control</a></div>
|
{include file="default/menu.html"}
|
||||||
|
|
||||||
<div id="page">
|
<div id="page">
|
||||||
|
|
||||||
|
|||||||
6
templates/default/menu.html
Normal file
6
templates/default/menu.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div id="menu">
|
||||||
|
<a {if $page == 'browse'}class="selected" {/if}href="{$browse_link}">Browse</a>
|
||||||
|
<a {if $page == 'playlist'}class="selected" {/if}href="{$playlist_link}">Playlist</a>
|
||||||
|
<a {if $page == 'control'}class="selected" {/if}href="{$control_link}">Control</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
@ -1 +1 @@
|
|||||||
<li><a href="{$playlist_remove_link}{$playlist_item.Pos}"><img src="images/del.gif" alt="Remove from Playlist" class="button" /></a><a href="{$playlist_play_link}{$playlist_item.Pos}"><img src="images/play.gif" alt="Play" class="button" /></a><img src="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><br /><span class="artist">{$playlist_item.Artist}</span> <span class="album">({$playlist_item.Album})</span>{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="images/del.gif" alt="Remove from Playlist" class="button" /></a><a href="{$playlist_play_link}{$playlist_item.Pos}"><img src="images/play.gif" alt="Play" class="button" /></a><img src="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><br /><span class="artist">{$playlist_item.Artist}</span> <span class="album">({$playlist_item.Album})</span>{else}{$playlist_item.file}{/if}</li>
|
||||||
|
|||||||
@ -42,6 +42,24 @@ body {
|
|||||||
background: #ccc;
|
background: #ccc;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
#menu a.selected {
|
||||||
|
background: #ddd;
|
||||||
|
color: #333;
|
||||||
|
padding: 1px 0px 3px;
|
||||||
|
float: left;
|
||||||
|
margin-left: 2px;
|
||||||
|
display: block;
|
||||||
|
width: 32%;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
#menu a.selected:hover {
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
#menu a.selecteds:active {
|
||||||
|
background: #666;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
#page {
|
#page {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
clear: left;
|
clear: left;
|
||||||
@ -114,6 +132,8 @@ img.button {
|
|||||||
margin-left: 3px;
|
margin-left: 3px;
|
||||||
border: 0px none !important;
|
border: 0px none !important;
|
||||||
}
|
}
|
||||||
|
li.playing {
|
||||||
|
background: #444;
|
||||||
|
}
|
||||||
|
|
||||||
{/literal}
|
{/literal}
|
||||||
Loading…
Reference in New Issue
Block a user