Make the bottom bar always link to current song and only make the righthand cube do it if there actually is a cover image.

This commit is contained in:
flash 2024-01-09 15:44:01 +00:00
parent ab0968ed35
commit 4b8a3ab588

View file

@ -3,8 +3,9 @@ require __DIR__ . '/../sig.php';
if(is_file(NP_INFO)) { if(is_file(NP_INFO)) {
$nowPlaying = true; $nowPlaying = true;
$nowPlayingHasCover = is_file(NP_COVER_IMG);
$npInfo = unserialize(file_get_contents(NP_INFO)); $npInfo = unserialize(file_get_contents(NP_INFO));
} else $nowPlaying = false; } else $nowPlaying = $nowPlayingHasCover = false;
$reqMethod = $_SERVER['REQUEST_METHOD']; $reqMethod = $_SERVER['REQUEST_METHOD'];
$reqPath = '/' . trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'); $reqPath = '/' . trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
@ -44,9 +45,7 @@ if($reqPath === '/signature.png') {
$imagickDraw->setFont(FW_FONT_FAM); $imagickDraw->setFont(FW_FONT_FAM);
$imagickDraw->setFontSize(FW_FONT_SIZE); $imagickDraw->setFontSize(FW_FONT_SIZE);
$hasCover = $nowPlaying && is_file(NP_COVER_IMG); if($nowPlayingHasCover) {
if($hasCover) {
try { try {
$imagickDraw->rectangle( $imagickDraw->rectangle(
SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD) - NP_COVER_FRAME, SIG_WIDTH - (NP_COVER_RES + NP_COVER_PAD) - NP_COVER_FRAME,
@ -63,7 +62,7 @@ if($reqPath === '/signature.png') {
$npCover->destroy(); $npCover->destroy();
} catch(ImagickException $ex) { } catch(ImagickException $ex) {
$hasCover = false; $nowPlayingHasCover = false;
} }
} }
@ -73,7 +72,7 @@ if($reqPath === '/signature.png') {
$imagickLogo->newImage($imagick->getImageWidth(), $imagick->getImageHeight(), new ImagickPixel('none'), 'png'); $imagickLogo->newImage($imagick->getImageWidth(), $imagick->getImageHeight(), new ImagickPixel('none'), 'png');
$imagickLogo->annotateImage( $imagickLogo->annotateImage(
$imagickDraw, $imagickDraw,
SIG_WIDTH - (4.8 * FW_FONT_SIZE) - ($hasCover ? (NP_COVER_RES + NP_COVER_PAD + NP_COVER_FRAME) : 0), SIG_WIDTH - (4.8 * FW_FONT_SIZE) - ($nowPlayingHasCover ? (NP_COVER_RES + NP_COVER_PAD + NP_COVER_FRAME) : 0),
SIG_HEIGHT - ($nowPlaying ? 37 : 27), SIG_HEIGHT - ($nowPlaying ? 37 : 27),
0, 0,
FW_TEXT FW_TEXT
@ -124,7 +123,7 @@ if($reqPath === '/') {
http_response_code(302); http_response_code(302);
if($x >= (SIG_WIDTH - SIG_HEIGHT) && $nowPlaying) { if($nowPlaying && (($y >= (SIG_HEIGHT - 33)) || ($nowPlayingHasCover && $x >= (SIG_WIDTH - SIG_HEIGHT)))) {
header('Location: ' . $npInfo->url); header('Location: ' . $npInfo->url);
return; return;
} }