gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd56e5054d56e5054Sync theme and shared tokens from layouts 17e0f03mred56e5054/components/media-player/README.md

3.4 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. | `jump` | the seek jump of the back / forward buttons, in seconds (default 10) |
  34. Write every attribute as a **literal** (`kind = "audio"`): then several players stand on
  35. one page, each with its own values. (A composed component's members are the page's state.)
  36. Use one per page: the player's own state (the time, the speed) is the page's state too.
  37. ## Controls
  38. - A **seek bar** you drag with a finger (pointer events, the whole strip is 44 px tall):
  39. the played part in the accent colour, the buffered part lighter, the thumb a dot. It
  40. takes the keyboard too (arrows, Home, End) when it has the focus.
  41. - **Back 10 s**, **play / pause** (the largest button), **forward 10 s**, the **current
  42. time / total time**, **mute**, the **speed** (1 / 1.25 / 1.5 / 2, one button that steps
  43. through them), and **fullscreen** on video.
  44. - Keyboard on the media element (a click on the video gives it the focus): Space plays /
  45. pauses, ArrowLeft / ArrowRight jump 10 s.
  46. ## Behaviour
  47. - The video area is 16:9, letterboxed (`object-fit: contain`); audio shows the cover with
  48. the title and artist.
  49. - The queue under the player is dense: 44 px tap rows that look thin (the visible rows
  50. hug their text, the touch area is the padding).
  51. - When an item ends, the next queue item's `src` goes to the host the same way a tap does.
  52. - Colours are the semantic tokens with a black/white/grey fallback (the base look), so a
  53. bare copy looks right and an app that declares the WorldAPI tokens (layouts.worldapi.org's
  54. theme) restyles it. No frames; the current queue item is the accent colour on a surface.
  55. ## Not yet
  56. No captions track UI (a `<track>` can be handed to the media element by the host's own
  57. markup inside the component's slot is not offered yet); no volume slider (mute only);
  58. no picture-in-picture button (the browser's own menu on the video still has it).

Branches

Latest commits

  • d56e5054Sync theme and shared tokens from layouts 17e0f03mre
  • b1362547Re-vendor to Hybriel set day35mre
  • 89e10f08Records: mission 002 rollback wordingmre
  • 9485dee7Records: mission 002 brief (live step)mre
  • 9ba68fe7Records: S1b reviewedmre
  • 193dfff1Records: S1 result, S1b startedmre
  • 028ed776Records: mission 001 continuation S1bmre
  • 1838d7e8Records: S1 startedmre
  • a43fca3fRecords: mission 001 decided pointsmre
  • 41773828Records: statusmre
  • a82c0805Records: mission 001 brief (Style form)mre
  • a4bce6d1Records: ticket push subscriptionmre
  • 14abde3bjukebox: records: Atlas's records moved to worldapi-conductor/archivemre
  • 0433e9a8jukebox: records: gitoria remote added and pushedmre
  • 1722d707jukebox: records: repo creation handed to Gitoriamre
  • b42e7dfbjukebox: conductor records (CONDUCTOR.md, STATUS.md), old STATUS archivedmre
  • 1b0d0bc1jukebox: a startup error prints its message before exit 1 (hybriel#247)mre
  • b19c478bjukebox JB18 (jukebox#17): onto Hybriel set-day31 (b287cd82, contains the SIGPIPE fix 6d2ca454): plugins/core and plugins/web re-vendored, bin/ from the set; a client that closes /stream while it is written no longer kills the server (90 aborted streams survived, the old bin died with exit 141 on the first)mre
  • 73867a2ejukebox#2: Style blocks in the language's nested form (rules named after the View's own elements, pseudo-classes nested, merged duplicates); the same CSS rules, the pages look the samemre
  • 06c548d6jukebox JB15: report, log linemre