commit 38cfa30adc0c5c7f439a883d05dbd1ee7106d80e
parent 2094216ac1fabc17b097d041be3c8889143f200f
Author: Hunter
Date:   Sun,  3 May 2026 22:46:18 -0400

add default album art; allow overriding

Diffstat:
Mbuild.py | 1+
Mmix/readme.md | 3++-
Mreadme.md | 2+-
Aresources/album_art.jpg | 0
Mresources/script.js | 12++++++++++--
5 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/build.py b/build.py @@ -141,6 +141,7 @@ def build_pwa(app_name=None, base_path=None): "resources/script.js", "mix/tracks.json", "resources/icon.png", + "resources/album_art.jpg", "resources/play.svg", "resources/pause.svg", "resources/prev.svg", diff --git a/mix/readme.md b/mix/readme.md @@ -5,6 +5,6 @@ add your audio files here, then run `scan.py` to create `tracks.json`. supported formats: `.mp3`, `.m4a`, `.ogg`, `.flac`, `.wav` ## optional files -- `album_art.jpg` - cover art for your mix - `custom.css` - custom styles to override the default theme - `custom.js` - custom scripts for additional functionality +- `album_art.jpg` - cover art for your mix (overrides the default in `/resources`) +\ No newline at end of file diff --git a/readme.md b/readme.md @@ -66,7 +66,7 @@ hits different, right?<br><br> (pictured: integration with iOS lockscreen controls) ## customization -add `custom.css`, `custom.js` and/or `album_art.jpg` to `/mix` to customize your mixapp's appearance and behavior. these files are automatically loaded if present. +add your own `custom.css`, `custom.js`, and/or `album_art.jpg` to `/mix` to customize your mixapp's appearance and behavior. ## intellectual property notice ensure you have the right to distribute any media files you include in public mixapps. personal archival backups are for your own use. sharing them with others, even as a gift, is not covered by fair use or backup exceptions. diff --git a/resources/album_art.jpg b/resources/album_art.jpg Binary files differ. diff --git a/resources/script.js b/resources/script.js @@ -75,6 +75,7 @@ let isPreloadingPriority = false; let totalBytesLoaded = 0; // Track total filesize of all preloaded tracks let cachedTracks = new Set(); // Track which tracks are cached for offline use let CACHE_NAME = 'my-mixapp'; // Default fallback +let hasCustomAlbumArt = false; const staticFiles = [ './', 'index.html', @@ -82,6 +83,7 @@ const staticFiles = [ 'resources/script.js', 'mix/tracks.json', 'resources/icon.png', + 'resources/album_art.jpg', 'resources/play.svg', 'resources/pause.svg', 'resources/prev.svg', @@ -136,7 +138,12 @@ fetch('manifest.json') return Promise.all([ ...optionalFiles.map(f => fetch(f, { method: 'HEAD' }) - .then(r => { if (r.ok) staticFiles.push(f); }) + .then(r => { + if (r.ok) { + staticFiles.push(f); + if (f === 'mix/album_art.jpg') hasCustomAlbumArt = true; + } + }) .catch(() => {}) ), fetch('mix/tracks.json') @@ -202,7 +209,8 @@ audio.addEventListener('play', () => { if ('mediaSession' in navigator) { // Convert relative path to absolute URL for media session // Use document.baseURI to correctly resolve paths in subdirectories - const albumArtUrl = new URL('mix/album_art.jpg', document.baseURI).href; + const albumArtPath = hasCustomAlbumArt ? 'mix/album_art.jpg' : 'resources/album_art.jpg'; + const albumArtUrl = new URL(albumArtPath, document.baseURI).href; navigator.mediaSession.metadata = new MediaMetadata({ title: track.title, artist: track.artist,