mirror of
https://github.com/danbee/neompc
synced 2025-03-04 08:39:10 +00:00
+ Added cover art to the Control page. Complete with scaled image caching.
This commit is contained in:
parent
cb1c845466
commit
2adb4a9ddd
@ -5,16 +5,16 @@
|
||||
**************************************/
|
||||
|
||||
/* Config relating to the display of CD covers */
|
||||
/******** THIS IS NOT YET IMPLEMENTED! *********/
|
||||
$_CONFIG['music_directory'] = '/var/lib/mpd/music';
|
||||
/* music_directory must match you MPD music_directory config */
|
||||
$_CONFIG['music_directory'] = '/home/danbee/Music';
|
||||
$_CONFIG['album_cover_name'] = 'folder.jpg';
|
||||
/***********************************************/
|
||||
$_CONFIG['album_cover_size'] = 130;
|
||||
|
||||
/* Template to use for displaying the pages */
|
||||
$_CONFIG['template'] = 'default';
|
||||
|
||||
/* Browse mode can be 'filesystem' or 'metadata' */
|
||||
$_CONFIG['browse_mode'] = 'filesystem';
|
||||
$_CONFIG['browse_mode'] = 'metadata';
|
||||
|
||||
$_CONFIG['sort_by_tracknumber'] = true;
|
||||
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
<?php
|
||||
/* Smarty stuff */
|
||||
|
||||
$version = 0.4;
|
||||
$version = 0.5;
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
/* Deal with Magic quotes. We can safely strip these off as we're not using a database. */
|
||||
$_REQUEST = array_map('stripslashes', $_REQUEST);
|
||||
$_GET = array_map('stripslashes', $_GET);
|
||||
$_POST = array_map('stripslashes', $_POST);
|
||||
$_COOKIE = array_map('stripslashes', $_COOKIE);
|
||||
}
|
||||
|
||||
require('config/config.inc.php');
|
||||
|
||||
|
||||
40
lib/image.php
Normal file
40
lib/image.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// The file
|
||||
$filename = $_GET['file'];
|
||||
|
||||
// Set a maximum height and width
|
||||
$width = $_GET['size'];
|
||||
$height = $_GET['size'];
|
||||
|
||||
// Content type
|
||||
header('Content-type: image/jpeg');
|
||||
|
||||
$script_root = substr($_SERVER["SCRIPT_FILENAME"], 0, strrpos(substr($_SERVER["SCRIPT_FILENAME"], 0, strrpos($_SERVER["SCRIPT_FILENAME"], '/')), '/'));
|
||||
|
||||
$cache_file_name = "$script_root/imagecache/" . md5($filename . $width) . ".jpg";
|
||||
|
||||
if (!file_exists($cache_file_name)) {
|
||||
|
||||
// Get new dimensions
|
||||
list($width_orig, $height_orig) = getimagesize($filename);
|
||||
|
||||
$ratio_orig = $width_orig/$height_orig;
|
||||
|
||||
if ($width/$height > $ratio_orig) {
|
||||
$width = $height*$ratio_orig;
|
||||
} else {
|
||||
$height = $width/$ratio_orig;
|
||||
}
|
||||
|
||||
// Resample
|
||||
$image_p = imagecreatetruecolor($width, $height);
|
||||
$image = imagecreatefromjpeg($filename);
|
||||
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
|
||||
|
||||
// Output
|
||||
imagejpeg($image_p, $cache_file_name, 95);
|
||||
|
||||
}
|
||||
|
||||
echo file_get_contents($cache_file_name);
|
||||
?>
|
||||
24
lib/page.php
24
lib/page.php
@ -25,6 +25,16 @@
|
||||
$smarty->assign('current_album', $current_track['Album']);
|
||||
$smarty->assign('current_artist', $current_track['Artist']);
|
||||
$smarty->assign('current_file', $current_track['file']);
|
||||
|
||||
$cover_link = $_CONFIG['music_directory'] . '/'
|
||||
. substr($current_track['file'], 0, strrpos($current_track['file'], '/') + 1)
|
||||
. $_CONFIG['album_cover_name'];
|
||||
|
||||
if (file_exists($cover_link)) {
|
||||
$smarty->assign('coverimage', $cover_link);
|
||||
$smarty->assign('coversize', $_CONFIG['album_cover_size']);
|
||||
}
|
||||
|
||||
break;
|
||||
case "browse":
|
||||
|
||||
@ -36,7 +46,7 @@
|
||||
|
||||
/* split the browse get var if present */
|
||||
if ($_GET['browse']) {
|
||||
setcookie('browse', stripslashes($_GET['browse']));
|
||||
setcookie('browse', $_GET['browse']);
|
||||
if ($_GET['browse'] == '/') {
|
||||
$meta_level = 'artists';
|
||||
}
|
||||
@ -81,7 +91,7 @@
|
||||
$artists = $mympd->GetArtists();
|
||||
|
||||
foreach ($artists as $the_artist) {
|
||||
$browselist[] = array('metaArtist' => $the_artist, 'path' => stripslashes($the_artist));
|
||||
$browselist[] = array('metaArtist' => $the_artist, 'path' => $the_artist);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -90,10 +100,10 @@
|
||||
$albums = $mympd->GetAlbums($artist);
|
||||
|
||||
foreach ($albums as $the_album) {
|
||||
$browselist[] = array('metaAlbum' => $the_album, 'path' => stripslashes($artist . '/' . $the_album));
|
||||
$browselist[] = array('metaAlbum' => $the_album, 'path' => $artist . '/' . $the_album);
|
||||
}
|
||||
|
||||
$dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode(stripslashes($artist))));
|
||||
$dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode($artist)));
|
||||
|
||||
break;
|
||||
|
||||
@ -117,7 +127,7 @@
|
||||
usort($browselist, "track_sort");
|
||||
}
|
||||
|
||||
$dir_list = array(array('name' => stripslashes($artist), 'path' => urlencode(stripslashes($artist))), array('name' => stripslashes($album), 'path' => urlencode(stripslashes($artist . '/' . $album))));
|
||||
$dir_list = array(array('name' => $artist, 'path' => urlencode($artist)), array('name' => $album, 'path' => urlencode($artist . '/' . $album)));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -132,13 +142,13 @@
|
||||
/* get the browse position from the cookie or from get */
|
||||
if ($_GET['browse']) {
|
||||
$browse = $_GET['browse'];
|
||||
setcookie('browse', stripslashes($browse));
|
||||
setcookie('browse', $browse);
|
||||
}
|
||||
else {
|
||||
$browse = $_COOKIE['browse'];
|
||||
}
|
||||
|
||||
$browse = stripslashes($browse);
|
||||
$browse = $browse;
|
||||
|
||||
/* make the path array */
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
<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_file}{$current_file}{else}<br />[Nothing playing]{/if}</div>
|
||||
|
||||
{if $coverimage}<div id="cover_image"><img id="cover" src="lib/image.php?file={$coverimage}&size={$coversize}"></div>{/if}
|
||||
|
||||
<div id="controls"><a href="index.php?action=prev"><img src="images/prev_button.gif" Alt="Previous" /></a><a href="index.php?action=play"><img src="images/play_button.gif" Alt="Play" /></a><a href="index.php?action=pause"><img src="images/pause_button.gif" Alt="Pause" /></a><a href="index.php?action=stop"><img src="images/stop_button.gif" Alt="Stop" /></a><a href="index.php?action=next"><img src="images/next_button.gif" Alt="Next" /></a></div>
|
||||
|
||||
@ -61,7 +61,7 @@ body {
|
||||
color: #fff;
|
||||
}
|
||||
#page {
|
||||
padding: 15px;
|
||||
padding: 7px;
|
||||
clear: left;
|
||||
}
|
||||
#page ul {
|
||||
@ -108,7 +108,7 @@ img.button {
|
||||
#song_display {
|
||||
width: 215px;
|
||||
margin: 0px auto;
|
||||
height: 50px;
|
||||
height: 55px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
}
|
||||
@ -135,5 +135,9 @@ img.button {
|
||||
li.playing {
|
||||
background: #444;
|
||||
}
|
||||
img#cover {
|
||||
border: 1px solid #666;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
{/literal}
|
||||
{/literal}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user