The four overlays that read /data/playlist.js (loading, goodbye,
music-box, music/nc) only ever consumed `tracks.length` for cosmetic
"LIBRARY :: N TRACKS" / "indexed N tracks" flavor text — all live
playback signal flows through bridges/mpd-state.py over OBS WS. The
142 KB JSON, ffprobe walk, and ETag-cached route were all producing
one integer that MPD itself already knows.
RigData::playlistCount() now shells `mpc stats` and parses "Songs: N",
returning 0 on any failure (treated by callers as empty library).
Removes RigPlaylistCommand, DataController::playlist(), the
/data/playlist.js route, the per-overlay <script src> + window.__PLAYLIST
shims, and the stale storage/data/playlist.json artifact.
AudioController still consumes config('rig.music_dirs') for the HTTP
audio stream — that's orthogonal and stays.
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Controllers;
|
||
|
||
use App\Support\RigData;
|
||
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||
|
||
class DataController extends Controller
|
||
{
|
||
/**
|
||
* Serve bridges/cover.jpg. `no-store` so CEF never holds a stale image
|
||
* even if a caller forgets the ?v=<hash> cache-bust. 404 returns a 1×1
|
||
* transparent PNG so the music-box cover placeholder doesn't get a
|
||
* broken-image icon while the bridge is starting up.
|
||
*/
|
||
public function coverImage(RigData $rig): SymfonyResponse
|
||
{
|
||
$path = $rig->coverPath();
|
||
if (is_file($path) && is_readable($path)) {
|
||
return response()->file($path, [
|
||
'Content-Type' => 'image/jpeg',
|
||
'Cache-Control' => 'no-store, max-age=0',
|
||
]);
|
||
}
|
||
|
||
// 1x1 transparent PNG (67 bytes).
|
||
$png = base64_decode(
|
||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
||
);
|
||
return response($png, 200, [
|
||
'Content-Type' => 'image/png',
|
||
'Cache-Control' => 'no-store, max-age=0',
|
||
]);
|
||
}
|
||
}
|