gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitcfe95440cfe95440|||PR day39 re-vendor: Hybriel 51e921d7 (bin 6b481aa7), ids kebab-case since hybriel#256: quoted state rule and tests use jb-shuffle / jb-repeatmrecfe95440/components/media-player/README.md

4.2 KB

  1. # Media player
  2. Audio and video in one phone-first player. Demo: `/media-player`
  3. (https://components.hybriel.worldapi.org/media-player).
  4. Pure Hybriel: one file, `media-player.hl`, with its own `Style`; no JavaScript file. The
  5. browser's own media element plays — this component draws the controls around it, sized
  6. for a thumb (every button at least 44 px, play / pause larger).
  7. ## Use it in an app
  8. Copy `components/media-player/media-player.hl` (and `components/icons/icons.hl` if you
  9. do not have it — the player's icons come from there), then:
  10. ```
  11. import MediaPlayer from './media-player.hl'
  12. Hybrid queue = [
  13. { src = '/media/song.mp3' title = 'Song' dur = '3:41' }
  14. { src = '/media/clip.mp4' title = 'Clip' dur = '0:30' }
  15. ]
  16. String current = '/media/song.mp3'
  17. picked = (src) => { current = src }
  18. View {
  19. MediaPlayer { src = current kind = "audio" title = "Song" artist = "Someone"
  20. cover = "/media/cover.png" queue = queue onPlay = picked }
  21. }
  22. ```
  23. ## Attributes
  24. | Attribute | Meaning |
  25. |---|---|
  26. | `src` | the address of the media file (the host owns it) |
  27. | `kind` | `"video"` (default) or `"audio"`: audio shows a cover instead of the video area |
  28. | `title` | the heading of the cover (audio); the video element's accessible name |
  29. | `artist` | the second line of the cover (audio) |
  30. | `cover` | the cover image of an audio item (optional) |
  31. | `queue` | the host's list: `[{ src, title, dur }]` — rendered under the player; the row whose `src` plays is marked with the accent colour only |
  32. | `onPlay` | a function the host hands in; a tap on a queue item (and the end of one) calls it with that item's `src` (the host then hands a new `src` back — the player is built anew with it) |
  33. | `skip` | `true` (default) shows the back / forward buttons; `false` leaves both out of the View. Keyboard seeking stays available. |
  34. | `repeat` | `"off"` (default) advances through the host queue; `"one"` replays the current item from zero without calling `onPlay` or replacing its source. |
  35. | `jump` | the seek jump of the back / forward buttons, in seconds (default 10) |
  36. Write every attribute as a **literal** (`kind = "audio"`): then several players stand on
  37. one page, each with its own values. (A composed component's members are the page's state.)
  38. Use one per page: the player's own state (the time, the speed) is the page's state too.
  39. ## Controls
  40. - A **seek bar** you drag with a finger (pointer events, the whole strip is 44 px tall):
  41. the played part in the accent colour, the buffered part lighter, the thumb a dot. It
  42. takes the keyboard too (arrows, Home, End) when it has the focus.
  43. - **Back 10 s**, **play / pause** (the largest button), **forward 10 s**, the **current
  44. time / total time**, **mute**, the **speed** (1 / 1.25 / 1.5 / 2, one button that steps
  45. through them), and **fullscreen** on video.
  46. - Keyboard on the media element (a click on the video gives it the focus): Space plays /
  47. pauses, ArrowLeft / ArrowRight jump 10 s.
  48. ## Behaviour
  49. - The video area is 16:9, letterboxed (`object-fit: contain`); audio shows the cover with
  50. the title and artist.
  51. - The queue under the player is dense: 44 px tap rows that look thin (the visible rows
  52. hug their text, the touch area is the padding).
  53. - When an item ends, the next queue item's `src` goes to the host the same way a tap does.
  54. - Colours are the semantic tokens with a black/white/grey fallback (the base look), so a
  55. bare copy looks right and an app that declares the WorldAPI tokens (layouts.worldapi.org's
  56. theme) restyles it. No frames; the current queue item is the accent colour on a surface.
  57. ## Not yet
  58. No captions track UI (a `<track>` can be handed to the media element by the host's own
  59. markup inside the component's slot is not offered yet); no volume slider (mute only);
  60. no picture-in-picture button (the browser's own menu on the video still has it).
  61. ## Player options
  62. Use `MediaPlayer { src = current skip = false repeat = "one" }` to leave out
  63. the two ten-second buttons and repeat the current song. Both options can change
  64. while the player is mounted. Repeat one uses the media element’s native `loop`
  65. attribute; it does not reload the source or call the host at each end. The `/media-player` demo has one toggle for each.
  66. Shuffle, Previous/Next and repeat-all controls belong to the host app.

Branches

Latest commits

  • cfe95440|||PR day39 re-vendor: Hybriel 51e921d7 (bin 6b481aa7), ids kebab-case since hybriel#256: quoted state rule and tests use jb-shuffle / jb-repeatmre
  • f3614c9bRe-vendor to Hybriel day39 (51e921d7, bin 6b481aa7)mre
  • 9f5c6532Merge branch 'status-22-pr' into mainJukebox
  • 5838d6c7|||PR STATUS: #22 pending decision, PR-only rulemre
  • 29d2029cRecords: PR-only rule (Kunibert)mre
  • adacb0abRecords: neutral ticket rule, #22 decision recordedmre
  • b2d6f121Records: #308 hold liftedmre
  • 7ab67533Records: day39 on hold (hybriel#308)mre
  • 22f21739Records: note rebase before mergemre
  • f7368ea3Records: mission 011 day39, waits for lisbethmre
  • 9515d2cdRecords: jb20 livemre
  • 019f6601ui gate: comment names the open bug components#27 (workaround, not fixed)mre
  • 277a2722README: provenance linemre
  • 4169ca6aREADME: sync pinmre
  • a01f3aa8ui gate: back to the top before the sort checks (the screen reopens where it was left)mre
  • f7936c20Lists keep their scroll position across a reload (jukebox#20): per-list offsets in storage/ui.json, gate jb20mre
  • d67906devirtual-list and icons from components.hybriel e5b98ec (centerId, scrollTop, onScroll)mre
  • df7920ceRecords: R3 startedmre
  • 0549f038Mission 010: jb20 livemre
  • 273494e2STATUS rewrittenmre