@adelin-io/cli 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +76 -2
  2. package/authoring-release.json +174 -0
  3. package/package.json +30 -4
  4. package/runtime-integrity.json +9 -0
  5. package/scripts/adelin.mjs +7768 -0
  6. package/scripts/assemble-checkout.mjs +93 -0
  7. package/scripts/local-save.mjs +513 -0
  8. package/scripts/materialize.mjs +319 -0
  9. package/scripts/runtime.mjs +8950 -0
  10. package/scripts/typecheck.mjs +72 -0
  11. package/scripts/workspace-state.mjs +183 -0
  12. package/skill/README.md +77 -0
  13. package/skill/SKILL.md +100 -0
  14. package/skill/authoring/access.md +193 -0
  15. package/skill/authoring/analytics.md +20 -0
  16. package/skill/authoring/app-memory.md +128 -0
  17. package/skill/authoring/app-requirements.md +99 -0
  18. package/skill/authoring/app-structure.md +265 -0
  19. package/skill/authoring/assets.md +117 -0
  20. package/skill/authoring/auth.md +263 -0
  21. package/skill/authoring/content-binding.md +26 -0
  22. package/skill/authoring/i18n.md +184 -0
  23. package/skill/authoring/language.md +503 -0
  24. package/skill/authoring/local-workflow.md +1667 -0
  25. package/skill/authoring/offline/connectivity.md +50 -0
  26. package/skill/authoring/offline/example.md +102 -0
  27. package/skill/authoring/offline/history-sync.md +39 -0
  28. package/skill/authoring/offline/index.md +29 -0
  29. package/skill/authoring/offline/package-storage.md +37 -0
  30. package/skill/authoring/offline/platforms.md +35 -0
  31. package/skill/authoring/offline/startup-navigation.md +53 -0
  32. package/skill/authoring/platform-files.md +616 -0
  33. package/skill/authoring/player/casting.md +47 -0
  34. package/skill/authoring/player/controls.md +95 -0
  35. package/skill/authoring/player/downloads.md +90 -0
  36. package/skill/authoring/player/drm.md +31 -0
  37. package/skill/authoring/player/index.md +39 -0
  38. package/skill/authoring/player/live-dvr.md +74 -0
  39. package/skill/authoring/player/platforms.md +47 -0
  40. package/skill/authoring/player/playback.md +43 -0
  41. package/skill/authoring/player/tracks-subtitles.md +32 -0
  42. package/skill/authoring/profiles.md +213 -0
  43. package/skill/authoring/remote-keys.md +139 -0
  44. package/skill/authoring/search.md +27 -0
  45. package/skill/authoring/store.md +85 -0
  46. package/skill/authoring/tv-text-entry.md +146 -0
  47. package/skill/design/approved/README.md +14 -0
  48. package/skill/design/approved/vesper-phone-home.jpg +0 -0
  49. package/skill/design/approved/vesper-tv-detail.jpg +0 -0
  50. package/skill/design/approved/vesper-tv-home.jpg +0 -0
  51. package/skill/design/design-guide.md +610 -0
  52. package/skill/design/edge-to-edge.md +66 -0
  53. package/skill/design/icons.md +50 -0
  54. package/skill/design/responsive-layout.md +175 -0
  55. package/skill/design/safe-area.md +221 -0
  56. package/skill/design/streaming-playbook.md +131 -0
  57. package/skill/design/visual-review.md +150 -0
  58. package/skill/examples/README.md +24 -0
  59. package/skill/examples/cinema/DESIGN.md +58 -0
  60. package/skill/examples/cinema/app.tsx +17 -0
  61. package/skill/examples/cinema/assets/logo.png +0 -0
  62. package/skill/examples/cinema/components/Action.tsx +40 -0
  63. package/skill/examples/cinema/components/Action.tv.tsx +44 -0
  64. package/skill/examples/cinema/components/CatalogGrid.tsx +31 -0
  65. package/skill/examples/cinema/components/ContinueRail.tsx +98 -0
  66. package/skill/examples/cinema/components/Feedback.tsx +28 -0
  67. package/skill/examples/cinema/components/Field.tsx +41 -0
  68. package/skill/examples/cinema/components/LibraryRail.tsx +46 -0
  69. package/skill/examples/cinema/components/PlayAction.tsx +29 -0
  70. package/skill/examples/cinema/components/Root.tsx +59 -0
  71. package/skill/examples/cinema/components/Shell.tsx +70 -0
  72. package/skill/examples/cinema/components/Tab.tsx +22 -0
  73. package/skill/examples/cinema/components/TitleCard.tsx +68 -0
  74. package/skill/examples/cinema/components/TitleMeta.tsx +36 -0
  75. package/skill/examples/cinema/locales/en.ts +211 -0
  76. package/skill/examples/cinema/locales/lt.ts +211 -0
  77. package/skill/examples/cinema/preview/phone-home.jpg +0 -0
  78. package/skill/examples/cinema/preview/tv-detail.jpg +0 -0
  79. package/skill/examples/cinema/preview/tv-home.jpg +0 -0
  80. package/skill/examples/cinema/screens/portrait/Account.tsx +110 -0
  81. package/skill/examples/cinema/screens/portrait/Browse.tsx +73 -0
  82. package/skill/examples/cinema/screens/portrait/Detail.tsx +159 -0
  83. package/skill/examples/cinema/screens/portrait/Home.tsx +196 -0
  84. package/skill/examples/cinema/screens/portrait/Player.tsx +299 -0
  85. package/skill/examples/cinema/screens/portrait/Search.tsx +46 -0
  86. package/skill/examples/cinema/screens/portrait/Search.tv.tsx +55 -0
  87. package/skill/examples/cinema/screens/portrait/SignIn.tsx +101 -0
  88. package/skill/examples/cinema/screens/portrait/SignUp.tsx +106 -0
  89. package/skill/examples/cinema/store.tsx +132 -0
  90. package/skill/examples/cinema/theme.ts +32 -0
  91. package/skill/examples/documentary/DESIGN.md +33 -0
  92. package/skill/examples/documentary/app.tsx +17 -0
  93. package/skill/examples/documentary/components/Action.tsx +43 -0
  94. package/skill/examples/documentary/components/CatalogGrid.tsx +47 -0
  95. package/skill/examples/documentary/components/Feedback.tsx +27 -0
  96. package/skill/examples/documentary/components/Field.tsx +33 -0
  97. package/skill/examples/documentary/components/LibraryRail.tsx +47 -0
  98. package/skill/examples/documentary/components/Root.tsx +62 -0
  99. package/skill/examples/documentary/components/Shell.tsx +93 -0
  100. package/skill/examples/documentary/components/StoryCard.tsx +53 -0
  101. package/skill/examples/documentary/components/StoryMeta.tsx +22 -0
  102. package/skill/examples/documentary/preview/phone-home.jpg +0 -0
  103. package/skill/examples/documentary/preview/tv-detail.jpg +0 -0
  104. package/skill/examples/documentary/preview/tv-home.jpg +0 -0
  105. package/skill/examples/documentary/screens/portrait/Account.tsx +97 -0
  106. package/skill/examples/documentary/screens/portrait/Browse.tsx +71 -0
  107. package/skill/examples/documentary/screens/portrait/Detail.tsx +133 -0
  108. package/skill/examples/documentary/screens/portrait/Home.tsx +89 -0
  109. package/skill/examples/documentary/screens/portrait/Player.tsx +116 -0
  110. package/skill/examples/documentary/screens/portrait/Search.tsx +48 -0
  111. package/skill/examples/documentary/screens/portrait/SignIn.tsx +96 -0
  112. package/skill/examples/documentary/screens/portrait/SignUp.tsx +101 -0
  113. package/skill/examples/documentary/store.tsx +115 -0
  114. package/skill/examples/documentary/theme.ts +20 -0
  115. package/skill/examples/series/DESIGN.md +55 -0
  116. package/skill/examples/series/app.tsx +17 -0
  117. package/skill/examples/series/components/Action.tsx +42 -0
  118. package/skill/examples/series/components/CatalogGrid.tsx +43 -0
  119. package/skill/examples/series/components/ContinueRail.tsx +78 -0
  120. package/skill/examples/series/components/Feedback.tsx +26 -0
  121. package/skill/examples/series/components/Field.tsx +34 -0
  122. package/skill/examples/series/components/LibraryRail.tsx +38 -0
  123. package/skill/examples/series/components/OutcomeNote.tsx +28 -0
  124. package/skill/examples/series/components/PlayAction.tsx +29 -0
  125. package/skill/examples/series/components/RestoreAction.tsx +33 -0
  126. package/skill/examples/series/components/Root.tsx +75 -0
  127. package/skill/examples/series/components/SaveTitle.tsx +34 -0
  128. package/skill/examples/series/components/Shell.tsx +75 -0
  129. package/skill/examples/series/components/TitleCard.tsx +62 -0
  130. package/skill/examples/series/components/UnlockAction.tsx +10 -0
  131. package/skill/examples/series/preview/phone-home.jpg +0 -0
  132. package/skill/examples/series/preview/tv-detail.jpg +0 -0
  133. package/skill/examples/series/preview/tv-home.jpg +0 -0
  134. package/skill/examples/series/screens/portrait/Account.tsx +125 -0
  135. package/skill/examples/series/screens/portrait/Browse.tsx +61 -0
  136. package/skill/examples/series/screens/portrait/Detail.tsx +231 -0
  137. package/skill/examples/series/screens/portrait/Home.tsx +109 -0
  138. package/skill/examples/series/screens/portrait/MyList.tsx +44 -0
  139. package/skill/examples/series/screens/portrait/Plans.tsx +131 -0
  140. package/skill/examples/series/screens/portrait/Player.tsx +138 -0
  141. package/skill/examples/series/screens/portrait/Profiles.tsx +103 -0
  142. package/skill/examples/series/screens/portrait/Search.tsx +50 -0
  143. package/skill/examples/series/screens/portrait/SignIn.tsx +94 -0
  144. package/skill/examples/series/screens/portrait/SignUp.tsx +100 -0
  145. package/skill/examples/series/store.tsx +192 -0
  146. package/skill/examples/series/theme.ts +32 -0
  147. package/skill/guides/final-pricing-capabilities.md +13 -0
  148. package/skill/reference/api.md +842 -0
  149. package/skill/reference/components.md +1782 -0
  150. package/skill/reference/packages.md +24 -0
  151. package/skill/scripts/assemble-checkout.mjs +93 -0
  152. package/skill/scripts/local-save.mjs +513 -0
  153. package/skill/scripts/materialize.mjs +319 -0
  154. package/skill/scripts/workspace-state.mjs +183 -0
  155. package/types/adelin-access.d.ts +70 -0
  156. package/types/adelin-analytics.d.ts +5 -0
  157. package/types/adelin-assets.d.ts +26 -0
  158. package/types/adelin-auth.d.ts +37 -0
  159. package/types/adelin-content.d.ts +120 -0
  160. package/types/adelin-device.d.ts +195 -0
  161. package/types/adelin-downloads.d.ts +47 -0
  162. package/types/adelin-env.d.ts +8 -0
  163. package/types/adelin-globals.d.ts +19 -0
  164. package/types/adelin-i18n.d.ts +31 -0
  165. package/types/adelin-native-stack.d.ts +178 -0
  166. package/types/adelin-navigation.d.ts +264 -0
  167. package/types/adelin-profiles.d.ts +51 -0
  168. package/types/adelin-react.d.ts +49 -0
  169. package/types/adelin-reanimated.d.ts +376 -0
  170. package/types/adelin-storage.d.ts +9 -0
  171. package/types/adelin-store.d.ts +74 -0
  172. package/types/adelin-ui.d.ts +1518 -0
  173. package/types/adelin-utils.d.ts +7 -0
  174. package/types/adelin-worklets.d.ts +15 -0
  175. package/workspace-tsconfig.json +53 -0
@@ -0,0 +1,47 @@
1
+ # Casting
2
+
3
+ Read cast state from the same player that owns playback: `player.cast.airplay` and
4
+ `player.cast.chromecast`. Both technology objects always exist. Check `supported` before
5
+ showing a technology's control; unsupported targets are inert and commands resolve an
6
+ `unsupported` result without opening a picker or changing playback.
7
+
8
+ Use `available` for receiver/picker availability and `canCast` for the current source's
9
+ eligibility. They are separate from platform support. Read `state` (`idle`, `connecting`,
10
+ `active`), `deviceName`, `pending` and `lastResult` to draw the controls in the app's design.
11
+ No casting dialog or subscription rule is added to the app automatically.
12
+
13
+ ## Output selection
14
+
15
+ In a player handler, `player.cast.airplay.showPicker()` opens AirPlay output selection;
16
+ `player.cast.chromecast.showPicker()` opens Chromecast selection. A picker closing does
17
+ not mean a receiver was selected: follow the player's actual `state` events.
18
+
19
+ `player.cast.airplay.stop()` does nothing. To return playback to this device, reopen the
20
+ AirPlay picker and select the iPhone or other local device. Do not label an AirPlay button
21
+ as an automatic disconnect action. On a supported AirPlay target, `stop()` resolves
22
+ `{ outcome: "unsupported", reason: "capability" }` and leaves the route unchanged.
23
+
24
+ `player.cast.chromecast.stop()` ends that cast session. Existing player transport controls
25
+ and progress follow the receiver while its session is active. Use typed outcomes for
26
+ unavailable receivers, ineligible sources and operation failures; never show success just
27
+ because a picker closed.
28
+
29
+ TV targets without sender support expose inert technology objects. Do not simulate a
30
+ receiver or add UI for unsupported capabilities. Casting is independent of
31
+ [offline startup](../offline/index.md) and
32
+ [connection changes](../offline/connectivity.md#connection-changes-during-a-session).
33
+
34
+ ```tsx
35
+ import { Screen, VideoView, Text, Pressable, useVideoPlayer } from "@adelin/ui";
36
+ import type { VideoSource } from "@adelin/ui";
37
+ interface Props { source?: VideoSource }
38
+ export default function Outputs(props: Props) {
39
+ const player = useVideoPlayer(props.source);
40
+ return <Screen><VideoView player={player} style={{ flex: 1 }} />
41
+ {player.cast.airplay.supported ? <Pressable onPress={() => player.cast.airplay.showPicker()}><Text>Change AirPlay output</Text></Pressable> : null}
42
+ {player.cast.chromecast.supported ? <Pressable onPress={() => player.cast.chromecast.showPicker()}><Text>Choose Chromecast</Text></Pressable> : null}
43
+ {player.cast.chromecast.state === "active" ? <Pressable onPress={() => player.cast.chromecast.stop()}><Text>Stop Chromecast</Text></Pressable> : null}
44
+ <Text>{player.cast.chromecast.deviceName}</Text>
45
+ </Screen>;
46
+ }
47
+ ```
@@ -0,0 +1,95 @@
1
+ # Controls and seeking
2
+
3
+ The player owns timing; the screen draws its state. Do not maintain separate playback
4
+ clocks, seek timers or time formatting. Design controls for the chosen screens and input.
5
+
6
+ - **Remote keys.** The player never reads remote keys; the screen maps them in one
7
+ `useTVEventHandler` from `@adelin/device` (key events are described in
8
+ [Remote keys](../remote-keys.md)). Media keys (`Keys.PlayPause`, `Play`, `Pause`, `Stop`,
9
+ `Rewind`, `FastForward`) act whatever has focus. Left and Right scrub only while the scrubber
10
+ has focus: keep a boolean in `useState`, set it from the scrubber `Pressable`'s `onFocus` and
11
+ `onBlur`, and check it before scrubbing. A `Pressable` that unmounts gets no `onBlur`, so when
12
+ the scrubber renders only while the controls show, clear the flag as they hide:
13
+ `useEffect(() => { if (!player.controlsVisible) setOnScrubber(false); }, [player.controlsVisible])`.
14
+ OK on the scrubber is its `onPress`, which calls `player.togglePlay()`. Act on `down` only and
15
+ return `true` for every key you handle. The player repeats a held key by itself, so never call a
16
+ scrub command on `longPress`. There is no per-element key prop; do not look for one.
17
+ - **Controls that hide.** `useVideoPlayer(source, { autoHideControls: true })` sets
18
+ `player.controlsVisible` to false after a few seconds of playback without input and keeps it
19
+ true while paused, buffering, scrubbing or ended. Every player command shows the controls again;
20
+ `player.showControls()`, `hideControls()` and `toggleControls()` do it directly. Fade the overlay
21
+ from `controlsVisible`, give it `pointerEvents="none"` while hidden, and put it above a
22
+ full-screen `<Pressable focusable={false} onPress={() => player.toggleControls()}>` with a
23
+ `zIndex`. In `useTVEventHandler`, a key that arrives while the controls are hidden calls
24
+ `player.showControls()` and returns `true`, so the first press only wakes them; let Back through,
25
+ and handle `PlayPause`, `Play`, `Pause` and `Stop` before this check so they act at once.
26
+ - **Scrubbing.** Draw the track from `player.progress` (0 to 1) and the times from
27
+ `player.elapsedText`, `durationText` and `remainingText`. `player.displayPosition` is the preview
28
+ while `player.scrubbing`. On TV make the track a focusable `Pressable` and map keys as above.
29
+ `scrubForward()` and `scrubBackward()` move the preview one step, repeat a held key with growing
30
+ steps until it is released or the preview reaches either end, and seek once input rests:
31
+ `commitMs` after the key is released, or after the last call when no key is held.
32
+ `commitScrub()` seeks at once and `cancelScrub()` drops the preview. For touch and mouse, lay a transparent `Slider` over the
33
+ track: `value={player.displayPosition}`, `maximumValue={player.duration}`,
34
+ `onValueChange={v => player.scrubTo(v)}`, `onSlidingComplete={() => player.commitScrub()}`.
35
+ - **Scrub tuning.** `useVideoPlayer(source, { scrub: { … } })` changes how scrubbing feels.
36
+ Every key is optional and takes a literal value:
37
+
38
+ | Key | Default | Meaning |
39
+ | --- | --- | --- |
40
+ | `step` | `10` | Seconds per tap, 0.1 to 3600. |
41
+ | `hold` | `[{ after: 0, step: 10 }, { after: 20, step: 30 }, { after: 40, step: 60 }]` | Tiers for a held key: each repeat uses the `step` of the last tier whose `after` is below the repeat count. Up to 8 tiers; the first `after` is 0 and they rise. |
42
+ | `repeatMs` | `100` | Milliseconds between repeats of a held key, 50 to 5000. |
43
+ | `commitMs` | `500` | Milliseconds input rests before the seek, 0 to 10000. A held key is input, so the wait starts at its release. |
44
+ | `pause` | `true` | Pause playback while scrubbing. |
45
+ | `resume` | `500` | Milliseconds after the seek before playing again, if it was playing. `false` stays paused, for players where the viewer confirms the new spot with Play. |
46
+
47
+ - **Scrub thumbnails.** Pass the item's `playbackSource` as the source and the player finds its
48
+ preview frames; each view below draws nothing for media without them. `<ScrubThumbnail
49
+ player={player} />` rides above the track at the scrub position: lay it absolutely over the
50
+ track's width, just above it, and keep the time label yourself. `<ScrubFilmstrip
51
+ player={player} count={5} />` is a full-width row of frames one step apart with the scrub
52
+ position enlarged in the middle; place it above the bar, a good fit for TV. Both appear only
53
+ while scrubbing. For any other layout, build it from `<VideoThumbnail player={player}
54
+ offset={-10} style={…} />`, the frame `offset` seconds from the scrub position at the size
55
+ `style` gives it. Roku refuses `Slider` and these views; see the
56
+ [Roku capability profile](../platform-files.md#roku-capability-profile).
57
+ - **Picture fit.** `<VideoView resizeMode={…} />` takes `'contain'` (whole picture),
58
+ `'cover'` (fills the view, cropping) or `'stretch'`; keep it in `useState` and offer it in the
59
+ settings panel below.
60
+ - **Speed.** Set it with `player.setRate(1.5)` and read `player.rate`; supported rates run from
61
+ 0.25 through 4. Playback settings belong to your authored UI.
62
+ - **What the platform supports.** `import { capabilities } from '@adelin/device'`. Show the fit
63
+ menu only when `capabilities.player.resizeMode` is true and the speed menu only when
64
+ `capabilities.player.rate` is true. Where a flag is false, `setRate` and a fit other than
65
+ `'contain'` are accepted and do nothing.
66
+
67
+ ```tsx
68
+ import { useState } from "@adelin/react";
69
+ import { Keys, capabilities, useTVEventHandler } from "@adelin/device";
70
+ import { Pressable, Screen, Text, VideoView, useVideoPlayer } from "@adelin/ui";
71
+ import type { VideoSource } from "@adelin/ui";
72
+ interface Props { source?: VideoSource }
73
+ export default function Controls(props: Props) {
74
+ const player = useVideoPlayer(props.source, { autoHideControls: true, scrub: { step: 15 } });
75
+ const [onScrubber, setOnScrubber] = useState(false);
76
+ useTVEventHandler(event => {
77
+ if (event.eventKeyAction !== "down") return false;
78
+ if (event.eventType === Keys.PlayPause) { player.togglePlay(); return true; }
79
+ if (event.eventType === Keys.Play) { player.play(); return true; }
80
+ if (event.eventType === Keys.Pause) { player.pause(); return true; }
81
+ if (event.eventType === Keys.Stop) { player.stop(); return true; }
82
+ if (event.eventType === Keys.Rewind) { player.scrubBackward(); return true; }
83
+ if (event.eventType === Keys.FastForward) { player.scrubForward(); return true; }
84
+ if (onScrubber && event.eventType === Keys.Left) { player.scrubBackward(); return true; }
85
+ if (onScrubber && event.eventType === Keys.Right) { player.scrubForward(); return true; }
86
+ return false;
87
+ });
88
+ return <Screen><VideoView player={player} style={{ flex: 1 }} />
89
+ <Pressable onFocus={() => setOnScrubber(true)} onBlur={() => setOnScrubber(false)} onPress={() => player.togglePlay()}>
90
+ <Text>{player.elapsedText}</Text>
91
+ </Pressable>
92
+ {capabilities.player.rate && <Pressable onPress={() => player.setRate(1.5)}><Text>Speed 1.5x</Text></Pressable>}
93
+ </Screen>;
94
+ }
95
+ ```
@@ -0,0 +1,90 @@
1
+ # Downloads
2
+
3
+ Import `downloads` and `useDownloads` from `@adelin/downloads`. The hook is app-wide:
4
+ tasks keep running when the viewer leaves a player screen. Check `supported` before
5
+ offering download controls. Unsupported platforms, including TV, expose empty inert
6
+ state; every command settles with an `unsupported` outcome. At startup `loading` is
7
+ true until the library is read, and commands settle `pending`; `supported` and
8
+ `tasks` are final once `loading` is false, so show a loading state rather than
9
+ "unavailable" or "no downloads" while it is true.
10
+
11
+ ## Starting and managing tasks
12
+
13
+ Call `downloads.start({ entryId })` with an id from the content library. Optional
14
+ `quality` sets `maxHeight` and `maxBitrate`; `audioTracks` and `textTracks` accept
15
+ `"all"`, `"none"` or language-code arrays. Do not pass URLs, filesystem paths,
16
+ credentials or private player objects. Repeating a start for the same media reuses
17
+ its task and resumes it if paused. A failed task is replaced by a fresh download of
18
+ the current content, so retry a failure with `start`; `resume` does not revive it. The
19
+ retry returns a new `taskId`, so use the returned id rather than the failed one. A
20
+ changed media identity is a different download.
21
+
22
+ Use `downloads.pause(id)`, `resume(id)` and `remove(id)` for one task. There is no
23
+ unscoped remove-all command. `refresh()` reloads inventory; `refreshLicense(id)`
24
+ renews a license when the platform supports it. `resume(id)` and `refreshLicense(id)`
25
+ run only while the current viewer's content still has the entry with the same media;
26
+ otherwise they settle `unavailable` with reason `not-authorized`, so in a shared
27
+ library a viewer without access cannot finish another viewer's paused download.
28
+ Deleting a task revokes its local playback reference. Ordinary screen changes and
29
+ remounts leave downloads running.
30
+
31
+ In the offline app, downloads can be listed, played, paused and removed; `start`,
32
+ `resume` and `refreshLicense` need the online app and settle `unavailable` with
33
+ reason `online-required`, so offer them only online or after `appMode.switchTo('online')`.
34
+
35
+ ## Shared or per-account library
36
+
37
+ By default an app has one download library per device, shared by everyone who uses
38
+ it. Signing in, signing out and switching accounts never pause, hide or revoke
39
+ downloads.
40
+
41
+ For catalogues where each account pays for its own access, opt into a library per
42
+ account with `defineApp({ ..., downloads: { perAccount: true } })` in `app.tsx`.
43
+
44
+ Each signed-in account, and the signed-out viewer, then sees only its own tasks.
45
+ Signing out or changing accounts pauses that account's active downloads, including
46
+ starts that finish late, and revokes its playable sources and task state even if
47
+ the pause fails. Saved bytes are kept: when the account signs back in its tasks are
48
+ listed again with their current status. Downloads stopped at sign-out stay paused
49
+ until the app calls `resume(id)` or `start`, so offer a resume control. Once
50
+ the account state is known, running downloads other signed-in accounts left behind
51
+ are paused too; the signed-out viewer's downloads keep running.
52
+
53
+ Read `tasks`, `loading`, `storageBytes`, `pending` and `lastResult` from the hook.
54
+ Each task supplies its status, progress, downloaded and total bytes, selected
55
+ quality/languages, safe error, known license expiry and `playable` flag. Use the
56
+ optional `playbackSource` only while the task is playable; it is an opaque source
57
+ for `useVideoPlayer`, never a URL to inspect or persist yourself.
58
+
59
+ ```tsx
60
+ import { Screen, Text, Pressable } from "@adelin/ui";
61
+ import { downloads, useDownloads } from "@adelin/downloads";
62
+
63
+ export default function Downloads() {
64
+ const files = useDownloads();
65
+ return <Screen>
66
+ {files.tasks.map(task => <Pressable key={task.id}
67
+ onPress={() => downloads.remove(task.id)}>
68
+ <Text>{task.status}</Text>
69
+ </Pressable>)}
70
+ </Screen>;
71
+ }
72
+ ```
73
+
74
+ Commands run in handlers; read their outcomes through the hook. A portable
75
+ `createAsyncThunk` can await the same commands and return their typed results.
76
+ Do not add arbitrary Promise chains to a direct handler. Outcomes distinguish
77
+ completed, unsupported, unavailable, pending and failed; a rejected operation is
78
+ not a successful download.
79
+
80
+ ## Product choices
81
+
82
+ Decide eligibility, subscription gates, pricing, quality selection and download UI
83
+ with the builder. The runtime adds no subscription rule. Add these choices to the
84
+ authored app when requested.
85
+
86
+ For disconnected app startup, see [offline app mode](../offline/index.md); for
87
+ connection changes, see
88
+ [connectivity](../offline/connectivity.md#connection-changes-during-a-session).
89
+ See [offline watch history](../offline/history-sync.md) for automatic local Resume
90
+ and conditional replay.
@@ -0,0 +1,31 @@
1
+ # Protected playback
2
+
3
+ `VideoSource.drm` supports `type` (`widevine`, `playready` or `fairplay`),
4
+ `licenseServer` and optional string-valued `headers`. Use the source supplied by
5
+ the library/runtime. Never hardcode a license URL, token or key in authored code,
6
+ persist credentials in the app store or import the private DRM package.
7
+
8
+ The runtime registers the actual engine integration. Source renewal preserves
9
+ media identity and playback position where the engine can do so. Platform key
10
+ systems and receiver eligibility still vary: the declared source shape is not
11
+ proof that every browser or device supports its protection.
12
+
13
+ Persistent offline licenses are separate from online playback licenses. A
14
+ completed task can be unplayable when its license has expired or cannot persist.
15
+ Use the task's real playability and supported renewal outcome from
16
+ [downloads](downloads.md); never fabricate renewal success or a license expiry.
17
+ Known expiries are enforced even before a task inventory refresh. Opaque native
18
+ license lifetimes stay unknown rather than being invented.
19
+
20
+ For protected casting, read [casting](casting.md) and its source-ineligibility
21
+ reasons. Opening a receiver picker does not make a restricted source castable.
22
+
23
+ ```tsx
24
+ import { Screen, VideoView, Text, useVideoPlayer } from "@adelin/ui";
25
+ import type { VideoSource } from "@adelin/ui";
26
+ interface Props { source?: VideoSource }
27
+ export default function ProtectedWatch(props: Props) {
28
+ const player = useVideoPlayer(props.source);
29
+ return <Screen><VideoView player={player} style={{ flex: 1 }} /><Text>{player.error ?? ""}</Text></Screen>;
30
+ }
31
+ ```
@@ -0,0 +1,39 @@
1
+ # Player
2
+
3
+ Use `useVideoPlayer` and `VideoView` from `@adelin/ui` for an authored player. The
4
+ runtime owns engines, timing, sources and media operations; your screen owns their
5
+ layout and controls. Keep one player for one viewing experience. A source that is
6
+ not available yet leaves it idle.
7
+
8
+ ```tsx
9
+ import { Screen, VideoView, Pressable, Text, useVideoPlayer } from "@adelin/ui";
10
+ import type { VideoSource } from "@adelin/ui";
11
+
12
+ interface Props { source?: VideoSource; entryId?: string }
13
+ export default function Watch(props: Props) {
14
+ const player = useVideoPlayer(props.source, { entryId: props.entryId });
15
+ return <Screen>
16
+ <VideoView player={player} style={{ flex: 1 }} />
17
+ <Pressable onPress={() => player.togglePlay()}>
18
+ <Text>{player.playing ? "Pause" : "Play"}</Text>
19
+ </Pressable>
20
+ </Screen>;
21
+ }
22
+ ```
23
+
24
+ | Feature | Read |
25
+ | --- | --- |
26
+ | Sources, lifecycle, transport and errors | [Playback](playback.md) |
27
+ | Remote keys, auto-hide, scrubbing, speed, fit and controls | [Controls](controls.md) |
28
+ | Audio, sidecar subtitles and subtitle styling | [Tracks and subtitles](tracks-subtitles.md) |
29
+ | Live streams, optional viewer counts and DVR limitations | [Live and DVR](live-dvr.md) |
30
+ | Protected media and license ownership | [DRM](drm.md) |
31
+ | Sender state, receivers and output selection | [Casting](casting.md) |
32
+ | Task lifecycle and local playback | [Downloads](downloads.md) |
33
+ | Supported targets and inert APIs | [Platforms](platforms.md) |
34
+ | Offline app startup and navigation | [Offline app mode](../offline/index.md) |
35
+
36
+ The workspace declarations are the callable API. Import only public `@adelin/*`
37
+ names; private player packages, native task objects and source credentials are
38
+ runtime infrastructure. Do not simulate capabilities that the runtime reports as
39
+ unsupported. Discuss requested controls and product behavior with the builder.
@@ -0,0 +1,74 @@
1
+ # Live streams and DVR
2
+
3
+ Select the current library row by ID. For a `mediaType: "live"` item, use
4
+ `useVideoPlayer(undefined, { entryId })` and mount its `VideoView` only when the
5
+ viewer chooses to watch. Live rows do not need a catalogue `playbackSource`.
6
+ The runtime obtains and renews finite playback authority for the current app,
7
+ entry and broadcast. It handles free guest viewing and private preview access;
8
+ authored code does not call admission endpoints, persist operation IDs, construct
9
+ HLS URLs or schedule renewal requests.
10
+
11
+ Use `live.state` for Live now, Upcoming and Offline labels. An upcoming
12
+ announcement can supply `startsAtText`, formatted in its time zone and the
13
+ viewer's language. Offer Watch live only for an on-air row with open access;
14
+ preserve the normal sign-in or unlock flow for restricted content. Catalogue
15
+ refreshes preserve selection and must not trigger playback. The runtime refreshes
16
+ live metadata while the app is active and on resume, so library reducers should
17
+ retain ready data during refresh.
18
+
19
+ An offline title cannot start a new session. An already admitted broadcast may
20
+ continue under its existing completion policy while authority remains valid.
21
+ Current access refusal, expiry, deletion or broadcast replacement stops playback.
22
+ Never bypass a refused grant or substitute another title. Source replacement
23
+ during renewal does not guarantee seamless buffer preservation.
24
+
25
+ Live playback does not save VOD progress, resume a saved position, mark completion,
26
+ auto-advance or download. A saved recording is ordinary VOD. Hide timelines,
27
+ scrub previews and seek controls for live playback. The player exposes no live
28
+ edge, seekable DVR range or dedicated go-live command; do not infer these from a
29
+ finite duration or encoder settings. Follow [controls](controls.md) for supported
30
+ input and [playback](playback.md) for recovery.
31
+
32
+ ```tsx
33
+ import { Screen, VideoView, Text, Pressable, useVideoPlayer } from "@adelin/ui";
34
+ interface Props { entryId: string }
35
+ export default function Live(props: Props) {
36
+ const player = useVideoPlayer(undefined, { entryId: props.entryId });
37
+ return <Screen><VideoView player={player} style={{ flex: 1 }} />
38
+ <Pressable onPress={() => player.togglePlay()}><Text>{player.playing ? "Pause" : "Play"}</Text></Pressable>
39
+ </Screen>;
40
+ }
41
+ ```
42
+
43
+ ## Optional viewer counts
44
+
45
+ Use `useLiveViewers(entryId, { enabled })` from `@adelin/content` when the builder
46
+ wants a watching annotation on a live title or player. Call it unconditionally;
47
+ use `enabled` to limit it to the title being shown. The runtime shares polling
48
+ between components, pauses it when the screen or app is inactive, and handles
49
+ guest, signed-in and private-preview authority. Do not write polling timers or
50
+ call count endpoints from authored code. Reading a count does not start playback.
51
+
52
+ The result has `state`, `count` and `observedAt`. Show a current annotation only
53
+ for `fresh`; zero is a valid count. `stale` is an older observation and may be
54
+ shown only with wording such as “Recently … watching”. Hide the annotation for
55
+ `idle`, `loading`, `hidden` and `unavailable`; their count is `null`, not zero.
56
+ The creator's visibility setting is authoritative. Do not substitute a creator
57
+ tool's count when the app returns `hidden`.
58
+
59
+ Counts are concurrent viewers reported by the streaming provider. They are not
60
+ an exact count of people using this app. The runtime ages observations without
61
+ depending on the device's wall clock and removes expired or refused data.
62
+ This binding is available on the web and native app runtimes; Roku is not covered.
63
+
64
+ ```tsx
65
+ import { Text } from "@adelin/ui";
66
+ import { useLiveViewers } from "@adelin/content";
67
+ interface Props { entryId: string; visible: boolean }
68
+ export default function Watching(props: Props) {
69
+ const viewers = useLiveViewers(props.entryId, { enabled: props.visible });
70
+ return viewers.state === "fresh" && viewers.count !== null
71
+ ? <Text>{viewers.count} watching</Text>
72
+ : null;
73
+ }
74
+ ```
@@ -0,0 +1,47 @@
1
+ # Player platform support
2
+
3
+ | Target | Casting sender | Downloads |
4
+ | --- | --- | --- |
5
+ | iPhone/iPad | AirPlay when offered by the engine | Native download engine |
6
+ | Android phone/tablet | Chromecast with trusted receiver configuration | Native download engine |
7
+ | Desktop/mobile browser | AirPlay/Chromecast when the browser offers them | Shaka offline storage when supported |
8
+ | tvOS, Android TV, Fire TV and web TV | Inert | Inert |
9
+
10
+ `capabilities` from `@adelin/device` reports what the player can change on this platform:
11
+ `capabilities.player.rate` (speed) and `capabilities.player.resizeMode` (picture fit other than
12
+ `'contain'`). Both are true on phones, tablets, Apple TV, Android TV, Fire TV, browsers and web
13
+ TVs, and false on a platform that cannot change them. Read it instead of checking the platform;
14
+ the gating rule is in [Controls](controls.md).
15
+
16
+ Technology members always exist. Read `supported`, `available`, `canCast` and the
17
+ unavailable reason; platform support and a reachable receiver are different facts.
18
+ Browser downloads require usable offline storage and media support. A browser
19
+ without them has an inert downloads API, even if another browser can download.
20
+
21
+ Unsupported APIs can be imported, read and subscribed to safely. They expose idle
22
+ cast state or empty download state, and commands return `unsupported` without
23
+ native initialization, task storage or network traffic. Hide unsupported controls
24
+ or explain availability in the app's own design. Do not navigate automatically.
25
+
26
+ Browser downloads accept supported HLS/DASH manifests and refuse progressive
27
+ MP4. Published viewer delivery currently offers MP4, so those titles remain
28
+ unavailable for browser download. Never claim successful browser download from
29
+ platform support alone.
30
+
31
+ Browser offline license renewal currently reports unsupported capability. Native
32
+ renewal depends on the task's real key system. Unknown expiry remains unknown.
33
+ Android's download service owns foreground/background work; the runtime handles
34
+ its platform setup. Authored screens do not request native plugin permissions.
35
+
36
+ Preview screenshots prove layout. Browser checks prove only that browser's media
37
+ path. Physical receivers, protected streams and mobile background behavior need
38
+ their actual supported devices; do not describe one kind of proof as another.
39
+
40
+ ```tsx
41
+ import { Screen, Text } from "@adelin/ui";
42
+ import { useDownloads } from "@adelin/downloads";
43
+ export default function Availability() {
44
+ const files = useDownloads();
45
+ return <Screen><Text>{files.loading ? "Checking downloads" : files.supported ? "Downloads available" : "Downloads unavailable on this device"}</Text></Screen>;
46
+ }
47
+ ```
@@ -0,0 +1,43 @@
1
+ # Playback and sources
2
+
3
+ Pass a library item's `playbackSource` to `useVideoPlayer`. Do not reconstruct its
4
+ URL, remove query parameters or add request headers. An undefined source waits
5
+ for content unless `entryId` selects a current live title as described in
6
+ [Live streams and DVR](live-dvr.md); never substitute sample media. The runtime keeps
7
+ credential renewals on the same media identity and disposes an outgoing engine
8
+ when that identity changes or its view unmounts.
9
+
10
+ Read `playing`, `position`, `duration`, `buffering`, `ended` and `error` to render
11
+ state. `play()`, `pause()`, `togglePlay()`, `seekTo(seconds)` and `seekBy(seconds)`
12
+ are handler commands. `stop()` stops playback; it is not a casting disconnect.
13
+ Do not keep a parallel playback clock. Read the formatted time and scrub fields
14
+ described in [controls](controls.md).
15
+
16
+ Pass `entryId` for a library title. For VOD with a signed-in viewer, the runtime selects
17
+ the chosen profile or its default, resumes the saved place and saves progress on
18
+ pause, end, close, background and every five minutes of playback. Leave `entryId`
19
+ off for trailers and previews. The app reads saved history through
20
+ [`@adelin/profiles`](../profiles.md); it does not save player positions itself.
21
+
22
+ `VideoPlayer` is the prop-driven alternative: supply `source`, `paused`, `muted`,
23
+ `loop`, `volume`, `rate`, `resizeMode` and the declared load/progress/end/error/buffer
24
+ callbacks. Use it where the screen already owns those values. Do not mount both
25
+ player APIs for the same visible video.
26
+
27
+ When a video cannot play, `<VideoView>` itself shows a neutral "This video isn't available right
28
+ now" in the viewer's language; never add text of your own about balance, billing, payment or credit.
29
+ Show an appropriate loading or retry state from the real player error and source
30
+ availability. A missing or expired local source leaves the view idle; never swap
31
+ in another title to hide a failure. Pass completed download playback sources as
32
+ described in [downloads](downloads.md).
33
+
34
+ ```tsx
35
+ import { useState } from "@adelin/react";
36
+ import { Screen, VideoPlayer, Text } from "@adelin/ui";
37
+ import type { VideoSource } from "@adelin/ui";
38
+ interface Props { source?: VideoSource }
39
+ export default function Clip(props: Props) {
40
+ const [message, setMessage] = useState("");
41
+ return <Screen>{props.source ? <VideoPlayer source={props.source} onError={event => setMessage(event.error.message)} style={{ flex: 1 }} /> : null}<Text>{message}</Text></Screen>;
42
+ }
43
+ ```
@@ -0,0 +1,32 @@
1
+ # Audio and subtitles
2
+
3
+ - **Audio and subtitles.** `player.audioTracks` with `player.audioTrack` and `player.selectAudioTrack(track.id)`;
4
+ `player.subtitleTracks` with `player.subtitleTrack` (null while off) and
5
+ `player.selectSubtitleTrack(track.id)` or `(null)`. Each track has `id`, `label` and
6
+ `language`. The lists fill once the media loads, and the item's subtitle files arrive with
7
+ its `playbackSource`. Offer them as lists in a settings panel the viewer opens, never as a
8
+ button that cycles, and show the audio list only when `player.audioTracks.length > 1`. Draw
9
+ the panel over the player inside `<FocusGroup trap autoFocus>`, with the controls still
10
+ mounted beneath it: focus stays in the panel, `useBackHandler` closes it, and focus returns to
11
+ the button that opened it.
12
+ - **Subtitle look.** `<VideoView subtitleStyle={{ fontSizeScale, fontColor, edgeStyle,
13
+ edgeColor, windowColor, bottomInset }} />` styles the subtitles. Let the viewer pick text
14
+ size, style and colour in the same panel, kept in `useState`: size scales `fontSizeScale`,
15
+ style is `edgeStyle` (`'dropShadow'`, `'uniform'` for an outline, `'raised'`, `'depressed'`)
16
+ or a box from `windowColor` with `edgeStyle: 'none'`. Raise `bottomInset` (a fraction of the
17
+ view's height) while the controls show. Some platforms draw subtitles with their system
18
+ caption styles and approximate this look; the platform's profile lists what they ignore.
19
+
20
+ ```tsx
21
+ import { Screen, VideoView, Text, Pressable, useVideoPlayer } from "@adelin/ui";
22
+ import type { VideoSource } from "@adelin/ui";
23
+ interface Props { source?: VideoSource }
24
+ export default function Tracks(props: Props) {
25
+ const player = useVideoPlayer(props.source);
26
+ return <Screen><VideoView player={player} style={{ flex: 1 }} />
27
+ {player.audioTracks.map(track => <Pressable key={track.id} onPress={() => player.selectAudioTrack(track.id)}><Text>{track.label}</Text></Pressable>)}
28
+ {player.subtitleTracks.map(track => <Pressable key={track.id} onPress={() => player.selectSubtitleTrack(track.id)}><Text>{track.label}</Text></Pressable>)}
29
+ <Pressable onPress={() => player.selectSubtitleTrack(null)}><Text>Subtitles off</Text></Pressable>
30
+ </Screen>;
31
+ }
32
+ ```