jukebox
All repositories: gitoria
2.9 KB
// components/songs.hl — `/`: ALL SONGS in one long list (the virtual list: only the rows near the viewport exist, 100 are fetched at a time from the server).// Sort by artist, title, album or plays; the Favourites button keeps only the songs played at least N times (N is adjustable, default 5) and the line// under it says how many songs that is. A tap on a song plays it with this list as the queue (the shell's `jbPlay`).parent './main.hl'import VirtualList from './virtual-list/virtual-list.hl'import { rowsFor, thousands } from '../lib/rows.hl'__title = 'Songs · Jukebox'String sortBy = 'artist'Boolean favOn = falseNumber favMin = 5Hybrid songCtx = { kind = 'songs' sort = 'artist' minPlays = 0 }Hybrid firstRows = rowsFor({ kind = 'songs' sort = 'artist' minPlays = 0 }, 0, 100)Number songTotal = firstRows.totalHybrid chunk = firstRows.rowsNumber chunkFrom = 0String playingId = ''String favClass = favOn ? 'on' : ''String countText = thousands(songTotal) + (songTotal == 1 ? ' song' : ' songs')// the list asks for the rows near the viewport; one request of 100 rows around themon songsLoad(first, wanted) {let start = first - 20if (start < 0) { start = 0 }r = emit server jbRows(songCtx, start, 100)songTotal = r.totalchunk = r.rowschunkFrom = r.offsetreturn null}// the list changed (order or filter): the first rows, back to the topon songsReload() {songCtx = { kind = 'songs' sort = sortBy minPlays = favOn ? favMin : 0 }r = emit server jbRows(songCtx, 0, 100)songTotal = r.totalchunk = r.rowschunkFrom = 0emit vlTop()return null}loadRange = (first, wanted) => { emit songsLoad(first, wanted) }picked = (id, index) => {playingId = idemit jbPlay(songCtx, index)}on songsSort(e) {sortBy = e.target.valueemit songsReload()return null}on songsFav(e) {favOn = !favOnemit songsReload()return null}on songsMin(e) {n = toNumber(e.target.value)if (n == null || n < 1) { return null }favMin = nif (favOn) { emit songsReload() }return null}View {jbScreen {jbTools {select { id = "sort" 'aria-label' = "Sort by" on change(e) { emit songsSort(e) }option { value = "artist" "Sort: artist" }option { value = "title" "Sort: title" }option { value = "album" "Sort: album" }option { value = "plays" "Sort: most played" }}button { id = "fav" type = "button" class = favClass 'aria-pressed' = favOn on click(e) { emit songsFav(e) } "Favourites" }}jbCount {output { id = "count" countText }if (favOn) {span { "played at least" }input { id = "favmin" type = "number" min = "1" value = favMin inputmode = "numeric" 'aria-label' = "Minimum play count" on input(e) { emit songsMin(e) } }span { "times" }}}VirtualList { itemCount = songTotal rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId listLabel = "Songs" }}}
Branches
Latest commits
- 59c1373ejukebox JB3 (work in progress): albums without folder and with disc markers folded, compilations, duplicate songs, own play counter, server-side shuffle queuemre
- 2a4cfc55jukebox: library screens (songs, artists, albums, artist, album, search, favourites), compact player bar, /stream with Range, thumbnails, virtual list vendored, ui gate and real-library checkmre
- 93a44212jukebox: report, numbers of the full scan, notes on the index key rulemre
- bf5167dajukebox: index keys without commas (mpackdb loses them after a reopen), comma fixture and gate checksmre
- 28a82fa2jukebox: README, STATUS, LOG, DECISIONSmre
- d13987dfjukebox: library scanner, ID3 reader, mpackdb database and JSON API, with fixtures and a gatemre