gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2a4cfc552a4cfc55jukebox: library screens (songs, artists, albums, artist, album, search, favourites), compact player bar, /stream with Range, thumbnails, virtual list vendored, ui gate and real-library checkmre2a4cfc55/components/main.hl

3.3 KB

  1. // components/main.hl — THE SHELL: the layouts header with the main menu (the phone's sidebar behind the toggle), the slot every screen renders
  2. // into, and the PLAYER BAR at the bottom. The shell stays when a screen is replaced by a click on a link (hl:web navigates in the page), so the song keeps playing
  3. // while you browse. A screen starts a song with `emit jbPlay(ctx, index)`: the context says which list the song was tapped in (`{ kind, sort, minPlays, ... }`,
  4. // lib/rows.hl), the index which row. The shell asks the server for the songs of that list from there on (`jbQueue`) and hands them to the media
  5. // player as its queue; when a song ends the player picks the next one, and the shell refills the queue before it runs out. The media player's own queue list is hidden by
  6. // the bar's CSS (a 13,000-song list is not drawn).
  7. import AppHeader from '../theme/shell/app-header.hl'
  8. import MainMenu from '../theme/shell/main-menu.hl'
  9. import Sidebar from '../theme/shell/app-sidebar.hl'
  10. import MediaPlayer from './media-player/media-player.hl'
  11. import { rowsFor, queueFor } from '../lib/rows.hl'
  12. slot = null
  13. menu = [ { label = 'Songs' href = '/' current = false } { label = 'Artists' href = '/artists' } { label = 'Albums' href = '/albums' } { label = 'Search' href = '/search' } ]
  14. // the player: what plays now, and the songs that follow in the list it came from
  15. String nowSrc = ''
  16. String nowTitle = ''
  17. String nowArtist = ''
  18. String nowCover = ''
  19. String nowId = ''
  20. String autoPlay = 'false'
  21. Hybrid nowQueue = []
  22. Hybrid nowCtx = {}
  23. String barClass = 'jb-app'
  24. View {
  25. body {
  26. AppHeader { brand = "Jukebox"
  27. MainMenu { items = menu }
  28. }
  29. Sidebar { desktop = "false" MainMenu { items = menu } }
  30. div { class = barClass
  31. slot
  32. div { class = "jb-bar"
  33. MediaPlayer { src = nowSrc kind = "audio" title = nowTitle artist = nowArtist cover = nowCover queue = nowQueue onPlay = pickedNext autoPlay = autoPlay }
  34. }
  35. }
  36. }
  37. }
  38. // ---- the server's part -------------------------------------------------------------------------------------------------------
  39. // rows of a list for a screen: `{ total, offset, rows }`
  40. on server jbRows(ctx, offset, limit) {
  41. return rowsFor(ctx, offset, limit)
  42. }
  43. // the songs of a list from `index` on, as queue items
  44. on server jbQueue(ctx, index, count) {
  45. return queueFor(ctx, index, count)
  46. }
  47. // ---- playing -----------------------------------------------------------------------------------------------------------------
  48. // show what plays (a queue item) and start it
  49. showNow = (item) => {
  50. nowSrc = item.src
  51. nowTitle = item.title
  52. nowArtist = item.artist
  53. nowCover = item.cover
  54. nowId = item.id
  55. autoPlay = 'true'
  56. barClass = 'jb-app playing'
  57. }
  58. // a song was tapped in a screen: its list becomes the queue
  59. on jbPlay(ctx, index) {
  60. items = emit server jbQueue(ctx, index, 40)
  61. if (items == null || items.length == 0) { return null }
  62. nowCtx = ctx
  63. nowQueue = items
  64. showNow(items[0])
  65. return null
  66. }
  67. // the player picked a queue item (a tap on it, or the end of the song before): refill the queue when it runs short
  68. pickedNext = (src) => {
  69. let at = -1
  70. let i = 0
  71. while (i < nowQueue.length) {
  72. if (nowQueue[i].src == src) { at = i }
  73. i = i + 1
  74. }
  75. if (at < 0) { return }
  76. item = nowQueue[at]
  77. showNow(item)
  78. if (nowQueue.length - at < 10) {
  79. more = emit server jbQueue(nowCtx, item.idx, 40)
  80. if (more != null && more.length > 0) { nowQueue = more }
  81. }
  82. }

Branches

Latest commits

  • 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