@hanifhan1f/vidstack-react 1.12.13

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 (284) hide show
  1. package/.templates/sandbox/document.css +27 -0
  2. package/.templates/sandbox/favicon-32x32.png +0 -0
  3. package/.templates/sandbox/index.html +21 -0
  4. package/.templates/sandbox/main.tsx +12 -0
  5. package/.templates/sandbox/player.css +39 -0
  6. package/.templates/sandbox/player.tsx +121 -0
  7. package/.templates/sandbox/tracks.ts +23 -0
  8. package/LICENSE +21 -0
  9. package/README.md +23 -0
  10. package/analyze.config.ts +7 -0
  11. package/build/build-icons.js +62 -0
  12. package/npm/analyze.json.d.ts +7 -0
  13. package/package.json +162 -0
  14. package/rollup.config.ts +256 -0
  15. package/src/components/announcer.tsx +47 -0
  16. package/src/components/layouts/default/audio-layout.tsx +231 -0
  17. package/src/components/layouts/default/context.ts +28 -0
  18. package/src/components/layouts/default/hooks.ts +13 -0
  19. package/src/components/layouts/default/icons.tsx +225 -0
  20. package/src/components/layouts/default/index.ts +11 -0
  21. package/src/components/layouts/default/media-layout.tsx +259 -0
  22. package/src/components/layouts/default/slots.tsx +98 -0
  23. package/src/components/layouts/default/ui/announcer.tsx +22 -0
  24. package/src/components/layouts/default/ui/buttons.tsx +301 -0
  25. package/src/components/layouts/default/ui/captions.tsx +16 -0
  26. package/src/components/layouts/default/ui/controls.tsx +12 -0
  27. package/src/components/layouts/default/ui/keyboard-display.tsx +132 -0
  28. package/src/components/layouts/default/ui/menus/accessibility-menu.tsx +100 -0
  29. package/src/components/layouts/default/ui/menus/audio-menu.tsx +167 -0
  30. package/src/components/layouts/default/ui/menus/captions-menu.tsx +61 -0
  31. package/src/components/layouts/default/ui/menus/chapters-menu.tsx +132 -0
  32. package/src/components/layouts/default/ui/menus/font-menu.tsx +331 -0
  33. package/src/components/layouts/default/ui/menus/items/menu-checkbox.tsx +72 -0
  34. package/src/components/layouts/default/ui/menus/items/menu-items.tsx +135 -0
  35. package/src/components/layouts/default/ui/menus/items/menu-slider.tsx +92 -0
  36. package/src/components/layouts/default/ui/menus/playback-menu.tsx +232 -0
  37. package/src/components/layouts/default/ui/menus/settings-menu.tsx +114 -0
  38. package/src/components/layouts/default/ui/menus/utils.ts +12 -0
  39. package/src/components/layouts/default/ui/sliders.tsx +136 -0
  40. package/src/components/layouts/default/ui/time.tsx +73 -0
  41. package/src/components/layouts/default/ui/title.tsx +24 -0
  42. package/src/components/layouts/default/ui/tooltip.tsx +27 -0
  43. package/src/components/layouts/default/ui.ts +8 -0
  44. package/src/components/layouts/default/video-layout.tsx +344 -0
  45. package/src/components/layouts/plyr/context.ts +26 -0
  46. package/src/components/layouts/plyr/icons/plyr-airplay.js +1 -0
  47. package/src/components/layouts/plyr/icons/plyr-captions-off.js +1 -0
  48. package/src/components/layouts/plyr/icons/plyr-captions-on.js +1 -0
  49. package/src/components/layouts/plyr/icons/plyr-download.js +1 -0
  50. package/src/components/layouts/plyr/icons/plyr-enter-fullscreen.js +1 -0
  51. package/src/components/layouts/plyr/icons/plyr-exit-fullscreen.js +1 -0
  52. package/src/components/layouts/plyr/icons/plyr-fast-forward.js +1 -0
  53. package/src/components/layouts/plyr/icons/plyr-muted.js +1 -0
  54. package/src/components/layouts/plyr/icons/plyr-pause.js +1 -0
  55. package/src/components/layouts/plyr/icons/plyr-pip.js +1 -0
  56. package/src/components/layouts/plyr/icons/plyr-play.js +1 -0
  57. package/src/components/layouts/plyr/icons/plyr-restart.js +1 -0
  58. package/src/components/layouts/plyr/icons/plyr-rewind.js +1 -0
  59. package/src/components/layouts/plyr/icons/plyr-settings.js +1 -0
  60. package/src/components/layouts/plyr/icons/plyr-volume.js +1 -0
  61. package/src/components/layouts/plyr/icons.tsx +71 -0
  62. package/src/components/layouts/plyr/index.ts +11 -0
  63. package/src/components/layouts/plyr/layout.tsx +1024 -0
  64. package/src/components/layouts/plyr/props.ts +104 -0
  65. package/src/components/layouts/plyr/slots.tsx +52 -0
  66. package/src/components/layouts/remotion-ui.ts +13 -0
  67. package/src/components/layouts/utils.ts +17 -0
  68. package/src/components/player-callbacks.ts +67 -0
  69. package/src/components/player.tsx +67 -0
  70. package/src/components/primitives/instances.ts +92 -0
  71. package/src/components/primitives/nodes.tsx +58 -0
  72. package/src/components/primitives/slot.tsx +132 -0
  73. package/src/components/provider.tsx +187 -0
  74. package/src/components/text-track.tsx +106 -0
  75. package/src/components/ui/buttons/airplay-button.tsx +53 -0
  76. package/src/components/ui/buttons/caption-button.tsx +55 -0
  77. package/src/components/ui/buttons/fullscreen-button.tsx +55 -0
  78. package/src/components/ui/buttons/google-cast-button.tsx +53 -0
  79. package/src/components/ui/buttons/live-button.tsx +56 -0
  80. package/src/components/ui/buttons/mute-button.tsx +60 -0
  81. package/src/components/ui/buttons/pip-button.tsx +54 -0
  82. package/src/components/ui/buttons/play-button.tsx +53 -0
  83. package/src/components/ui/buttons/seek-button.tsx +55 -0
  84. package/src/components/ui/buttons/toggle-button.tsx +51 -0
  85. package/src/components/ui/caption.tsx +70 -0
  86. package/src/components/ui/captions.tsx +41 -0
  87. package/src/components/ui/chapter-title.tsx +40 -0
  88. package/src/components/ui/controls.tsx +90 -0
  89. package/src/components/ui/gesture.tsx +43 -0
  90. package/src/components/ui/menu.tsx +251 -0
  91. package/src/components/ui/poster.tsx +101 -0
  92. package/src/components/ui/radio-group.tsx +88 -0
  93. package/src/components/ui/sliders/audio-gain-slider.tsx +55 -0
  94. package/src/components/ui/sliders/quality-slider.tsx +54 -0
  95. package/src/components/ui/sliders/slider-callbacks.ts +14 -0
  96. package/src/components/ui/sliders/slider-value.tsx +13 -0
  97. package/src/components/ui/sliders/slider.tsx +254 -0
  98. package/src/components/ui/sliders/speed-slider.tsx +54 -0
  99. package/src/components/ui/sliders/time-slider.tsx +379 -0
  100. package/src/components/ui/sliders/volume-slider.tsx +55 -0
  101. package/src/components/ui/spinner.tsx +105 -0
  102. package/src/components/ui/thumbnail.tsx +82 -0
  103. package/src/components/ui/time.tsx +77 -0
  104. package/src/components/ui/title.tsx +32 -0
  105. package/src/components/ui/tooltip.tsx +135 -0
  106. package/src/globals.d.ts +3 -0
  107. package/src/hooks/create-text-track.ts +22 -0
  108. package/src/hooks/options/use-audio-gain-options.ts +75 -0
  109. package/src/hooks/options/use-audio-options.ts +71 -0
  110. package/src/hooks/options/use-caption-options.ts +95 -0
  111. package/src/hooks/options/use-chapter-options.ts +97 -0
  112. package/src/hooks/options/use-playback-rate-options.ts +75 -0
  113. package/src/hooks/options/use-video-quality-options.ts +123 -0
  114. package/src/hooks/use-active-text-cues.ts +28 -0
  115. package/src/hooks/use-active-text-track.ts +19 -0
  116. package/src/hooks/use-chapter-title.ts +12 -0
  117. package/src/hooks/use-dom.ts +121 -0
  118. package/src/hooks/use-media-context.ts +6 -0
  119. package/src/hooks/use-media-player.ts +19 -0
  120. package/src/hooks/use-media-provider.ts +31 -0
  121. package/src/hooks/use-media-remote.ts +37 -0
  122. package/src/hooks/use-media-state.ts +58 -0
  123. package/src/hooks/use-signals.ts +24 -0
  124. package/src/hooks/use-slider-preview.ts +126 -0
  125. package/src/hooks/use-slider-state.ts +63 -0
  126. package/src/hooks/use-state.ts +47 -0
  127. package/src/hooks/use-text-cues.ts +33 -0
  128. package/src/hooks/use-thumbnails.ts +69 -0
  129. package/src/icon.ts +37 -0
  130. package/src/icons.ts +754 -0
  131. package/src/index.ts +181 -0
  132. package/src/providers/remotion/index.ts +10 -0
  133. package/src/providers/remotion/layout-engine.ts +123 -0
  134. package/src/providers/remotion/loader.ts +35 -0
  135. package/src/providers/remotion/playback-engine.ts +142 -0
  136. package/src/providers/remotion/provider.tsx +514 -0
  137. package/src/providers/remotion/type-check.ts +13 -0
  138. package/src/providers/remotion/types.ts +94 -0
  139. package/src/providers/remotion/ui/context.tsx +120 -0
  140. package/src/providers/remotion/ui/error-boundary.tsx +57 -0
  141. package/src/providers/remotion/ui/poster.tsx +33 -0
  142. package/src/providers/remotion/ui/slider-thumbnail.tsx +41 -0
  143. package/src/providers/remotion/ui/thumbnail.tsx +166 -0
  144. package/src/providers/remotion/validate.ts +220 -0
  145. package/src/source.ts +5 -0
  146. package/src/utils.ts +27 -0
  147. package/tsconfig.build.json +10 -0
  148. package/tsconfig.json +11 -0
  149. package/types/react/src/components/announcer.d.ts +16 -0
  150. package/types/react/src/components/layouts/default/audio-layout.d.ts +27 -0
  151. package/types/react/src/components/layouts/default/context.d.ts +14 -0
  152. package/types/react/src/components/layouts/default/hooks.d.ts +2 -0
  153. package/types/react/src/components/layouts/default/icons.d.ts +95 -0
  154. package/types/react/src/components/layouts/default/index.d.ts +5 -0
  155. package/types/react/src/components/layouts/default/media-layout.d.ts +133 -0
  156. package/types/react/src/components/layouts/default/slots.d.ts +22 -0
  157. package/types/react/src/components/layouts/default/ui/announcer.d.ts +6 -0
  158. package/types/react/src/components/layouts/default/ui/buttons.d.ts +54 -0
  159. package/types/react/src/components/layouts/default/ui/captions.d.ts +6 -0
  160. package/types/react/src/components/layouts/default/ui/controls.d.ts +6 -0
  161. package/types/react/src/components/layouts/default/ui/keyboard-display.d.ts +8 -0
  162. package/types/react/src/components/layouts/default/ui/menus/accessibility-menu.d.ts +10 -0
  163. package/types/react/src/components/layouts/default/ui/menus/audio-menu.d.ts +10 -0
  164. package/types/react/src/components/layouts/default/ui/menus/captions-menu.d.ts +10 -0
  165. package/types/react/src/components/layouts/default/ui/menus/chapters-menu.d.ts +7 -0
  166. package/types/react/src/components/layouts/default/ui/menus/font-menu.d.ts +6 -0
  167. package/types/react/src/components/layouts/default/ui/menus/items/menu-checkbox.d.ts +13 -0
  168. package/types/react/src/components/layouts/default/ui/menus/items/menu-items.d.ts +49 -0
  169. package/types/react/src/components/layouts/default/ui/menus/items/menu-slider.d.ts +26 -0
  170. package/types/react/src/components/layouts/default/ui/menus/playback-menu.d.ts +10 -0
  171. package/types/react/src/components/layouts/default/ui/menus/settings-menu.d.ts +15 -0
  172. package/types/react/src/components/layouts/default/ui/menus/utils.d.ts +1 -0
  173. package/types/react/src/components/layouts/default/ui/sliders.d.ts +24 -0
  174. package/types/react/src/components/layouts/default/ui/time.d.ts +30 -0
  175. package/types/react/src/components/layouts/default/ui/title.d.ts +6 -0
  176. package/types/react/src/components/layouts/default/ui/tooltip.d.ts +12 -0
  177. package/types/react/src/components/layouts/default/ui.d.ts +8 -0
  178. package/types/react/src/components/layouts/default/video-layout.d.ts +47 -0
  179. package/types/react/src/components/layouts/plyr/context.d.ts +12 -0
  180. package/types/react/src/components/layouts/plyr/icons/plyr-airplay.d.ts +2 -0
  181. package/types/react/src/components/layouts/plyr/icons/plyr-captions-off.d.ts +2 -0
  182. package/types/react/src/components/layouts/plyr/icons/plyr-captions-on.d.ts +2 -0
  183. package/types/react/src/components/layouts/plyr/icons/plyr-download.d.ts +2 -0
  184. package/types/react/src/components/layouts/plyr/icons/plyr-enter-fullscreen.d.ts +2 -0
  185. package/types/react/src/components/layouts/plyr/icons/plyr-exit-fullscreen.d.ts +2 -0
  186. package/types/react/src/components/layouts/plyr/icons/plyr-fast-forward.d.ts +2 -0
  187. package/types/react/src/components/layouts/plyr/icons/plyr-muted.d.ts +2 -0
  188. package/types/react/src/components/layouts/plyr/icons/plyr-pause.d.ts +2 -0
  189. package/types/react/src/components/layouts/plyr/icons/plyr-pip.d.ts +2 -0
  190. package/types/react/src/components/layouts/plyr/icons/plyr-play.d.ts +2 -0
  191. package/types/react/src/components/layouts/plyr/icons/plyr-restart.d.ts +2 -0
  192. package/types/react/src/components/layouts/plyr/icons/plyr-rewind.d.ts +2 -0
  193. package/types/react/src/components/layouts/plyr/icons/plyr-settings.d.ts +2 -0
  194. package/types/react/src/components/layouts/plyr/icons/plyr-volume.d.ts +2 -0
  195. package/types/react/src/components/layouts/plyr/icons.d.ts +25 -0
  196. package/types/react/src/components/layouts/plyr/index.d.ts +6 -0
  197. package/types/react/src/components/layouts/plyr/layout.d.ts +17 -0
  198. package/types/react/src/components/layouts/plyr/props.d.ts +71 -0
  199. package/types/react/src/components/layouts/plyr/slots.d.ts +9 -0
  200. package/types/react/src/components/layouts/remotion-ui.d.ts +3 -0
  201. package/types/react/src/components/layouts/utils.d.ts +1 -0
  202. package/types/react/src/components/player-callbacks.d.ts +6 -0
  203. package/types/react/src/components/player.d.ts +32 -0
  204. package/types/react/src/components/primitives/instances.d.ts +83 -0
  205. package/types/react/src/components/primitives/nodes.d.ts +15 -0
  206. package/types/react/src/components/primitives/slot.d.ts +11 -0
  207. package/types/react/src/components/provider.d.ts +26 -0
  208. package/types/react/src/components/text-track.d.ts +100 -0
  209. package/types/react/src/components/ui/buttons/airplay-button.d.ts +22 -0
  210. package/types/react/src/components/ui/buttons/caption-button.d.ts +24 -0
  211. package/types/react/src/components/ui/buttons/fullscreen-button.d.ts +24 -0
  212. package/types/react/src/components/ui/buttons/google-cast-button.d.ts +22 -0
  213. package/types/react/src/components/ui/buttons/live-button.d.ts +26 -0
  214. package/types/react/src/components/ui/buttons/mute-button.d.ts +30 -0
  215. package/types/react/src/components/ui/buttons/pip-button.d.ts +24 -0
  216. package/types/react/src/components/ui/buttons/play-button.d.ts +23 -0
  217. package/types/react/src/components/ui/buttons/seek-button.d.ts +25 -0
  218. package/types/react/src/components/ui/buttons/toggle-button.d.ts +22 -0
  219. package/types/react/src/components/ui/caption.d.ts +11 -0
  220. package/types/react/src/components/ui/captions.d.ts +20 -0
  221. package/types/react/src/components/ui/chapter-title.d.ts +20 -0
  222. package/types/react/src/components/ui/controls.d.ts +40 -0
  223. package/types/react/src/components/ui/gesture.d.ts +20 -0
  224. package/types/react/src/components/ui/menu.d.ts +102 -0
  225. package/types/react/src/components/ui/poster.d.ts +25 -0
  226. package/types/react/src/components/ui/radio-group.d.ts +39 -0
  227. package/types/react/src/components/ui/sliders/audio-gain-slider.d.ts +29 -0
  228. package/types/react/src/components/ui/sliders/quality-slider.d.ts +28 -0
  229. package/types/react/src/components/ui/sliders/slider-callbacks.d.ts +6 -0
  230. package/types/react/src/components/ui/sliders/slider-value.d.ts +9 -0
  231. package/types/react/src/components/ui/sliders/slider.d.ts +134 -0
  232. package/types/react/src/components/ui/sliders/speed-slider.d.ts +28 -0
  233. package/types/react/src/components/ui/sliders/time-slider.d.ts +124 -0
  234. package/types/react/src/components/ui/sliders/volume-slider.d.ts +29 -0
  235. package/types/react/src/components/ui/spinner.d.ts +31 -0
  236. package/types/react/src/components/ui/thumbnail.d.ts +26 -0
  237. package/types/react/src/components/ui/time.d.ts +20 -0
  238. package/types/react/src/components/ui/title.d.ts +15 -0
  239. package/types/react/src/components/ui/tooltip.d.ts +63 -0
  240. package/types/react/src/hooks/create-text-track.d.ts +7 -0
  241. package/types/react/src/hooks/options/use-audio-gain-options.d.ts +22 -0
  242. package/types/react/src/hooks/options/use-audio-options.d.ts +17 -0
  243. package/types/react/src/hooks/options/use-caption-options.d.ts +24 -0
  244. package/types/react/src/hooks/options/use-chapter-options.d.ts +18 -0
  245. package/types/react/src/hooks/options/use-playback-rate-options.d.ts +22 -0
  246. package/types/react/src/hooks/options/use-video-quality-options.d.ts +35 -0
  247. package/types/react/src/hooks/use-active-text-cues.d.ts +6 -0
  248. package/types/react/src/hooks/use-active-text-track.d.ts +5 -0
  249. package/types/react/src/hooks/use-chapter-title.d.ts +4 -0
  250. package/types/react/src/hooks/use-dom.d.ts +9 -0
  251. package/types/react/src/hooks/use-media-context.d.ts +1 -0
  252. package/types/react/src/hooks/use-media-player.d.ts +7 -0
  253. package/types/react/src/hooks/use-media-provider.d.ts +7 -0
  254. package/types/react/src/hooks/use-media-remote.d.ts +12 -0
  255. package/types/react/src/hooks/use-media-state.d.ts +15 -0
  256. package/types/react/src/hooks/use-signals.d.ts +5 -0
  257. package/types/react/src/hooks/use-slider-preview.d.ts +27 -0
  258. package/types/react/src/hooks/use-slider-state.d.ts +16 -0
  259. package/types/react/src/hooks/use-state.d.ts +18 -0
  260. package/types/react/src/hooks/use-text-cues.d.ts +6 -0
  261. package/types/react/src/hooks/use-thumbnails.d.ts +16 -0
  262. package/types/react/src/icon.d.ts +17 -0
  263. package/types/react/src/icons.d.ts +215 -0
  264. package/types/react/src/index.d.ts +78 -0
  265. package/types/react/src/providers/remotion/index.d.ts +7 -0
  266. package/types/react/src/providers/remotion/layout-engine.d.ts +8 -0
  267. package/types/react/src/providers/remotion/loader.d.ts +9 -0
  268. package/types/react/src/providers/remotion/playback-engine.d.ts +11 -0
  269. package/types/react/src/providers/remotion/provider.d.ts +26 -0
  270. package/types/react/src/providers/remotion/type-check.d.ts +6 -0
  271. package/types/react/src/providers/remotion/types.d.ts +91 -0
  272. package/types/react/src/providers/remotion/ui/context.d.ts +17 -0
  273. package/types/react/src/providers/remotion/ui/error-boundary.d.ts +21 -0
  274. package/types/react/src/providers/remotion/ui/poster.d.ts +18 -0
  275. package/types/react/src/providers/remotion/ui/slider-thumbnail.d.ts +17 -0
  276. package/types/react/src/providers/remotion/ui/thumbnail.d.ts +32 -0
  277. package/types/react/src/providers/remotion/validate.d.ts +12 -0
  278. package/types/react/src/source.d.ts +3 -0
  279. package/types/react/src/utils.d.ts +3 -0
  280. package/types/vidstack/src/core/api/src-types.d.ts +50 -0
  281. package/types/vidstack/src/utils/mime.d.ts +15 -0
  282. package/types/vidstack/src/utils/network.d.ts +17 -0
  283. package/types/vidstack/src/utils/support.d.ts +72 -0
  284. package/vite.config.ts +23 -0
@@ -0,0 +1,301 @@
1
+ import * as React from 'react';
2
+
3
+ import { isString, uppercaseFirstChar } from 'maverick.js/std';
4
+ import { getDownloadFile, isTrackCaptionKind } from 'vidstack';
5
+
6
+ import { useMediaState } from '../../../../hooks/use-media-state';
7
+ import { appendParamsToURL } from '../../../../utils';
8
+ import { AirPlayButton } from '../../../ui/buttons/airplay-button';
9
+ import { CaptionButton } from '../../../ui/buttons/caption-button';
10
+ import { FullscreenButton } from '../../../ui/buttons/fullscreen-button';
11
+ import { GoogleCastButton } from '../../../ui/buttons/google-cast-button';
12
+ import { LiveButton } from '../../../ui/buttons/live-button';
13
+ import { MuteButton } from '../../../ui/buttons/mute-button';
14
+ import { PIPButton } from '../../../ui/buttons/pip-button';
15
+ import { PlayButton } from '../../../ui/buttons/play-button';
16
+ import { SeekButton } from '../../../ui/buttons/seek-button';
17
+ import * as Tooltip from '../../../ui/tooltip';
18
+ import { useDefaultLayoutContext, useDefaultLayoutWord } from '../context';
19
+ import { DefaultTooltip } from './tooltip';
20
+
21
+ /* -------------------------------------------------------------------------------------------------
22
+ * Types
23
+ * -----------------------------------------------------------------------------------------------*/
24
+
25
+ interface DefaultMediaButtonProps {
26
+ tooltip: Tooltip.ContentProps['placement'];
27
+ }
28
+
29
+ /* -------------------------------------------------------------------------------------------------
30
+ * DefaultPlayButton
31
+ * -----------------------------------------------------------------------------------------------*/
32
+
33
+ function DefaultPlayButton({ tooltip }: DefaultMediaButtonProps) {
34
+ const { icons: Icons } = useDefaultLayoutContext(),
35
+ playText = useDefaultLayoutWord('Play'),
36
+ pauseText = useDefaultLayoutWord('Pause'),
37
+ $paused = useMediaState('paused'),
38
+ $ended = useMediaState('ended');
39
+ return (
40
+ <DefaultTooltip content={$paused ? playText : pauseText} placement={tooltip}>
41
+ <PlayButton className="vds-play-button vds-button" aria-label={playText}>
42
+ {$ended ? (
43
+ <Icons.PlayButton.Replay className="vds-icon" />
44
+ ) : $paused ? (
45
+ <Icons.PlayButton.Play className="vds-icon" />
46
+ ) : (
47
+ <Icons.PlayButton.Pause className="vds-icon" />
48
+ )}
49
+ </PlayButton>
50
+ </DefaultTooltip>
51
+ );
52
+ }
53
+
54
+ DefaultPlayButton.displayName = 'DefaultPlayButton';
55
+ export { DefaultPlayButton };
56
+
57
+ /* -------------------------------------------------------------------------------------------------
58
+ * DefaultMuteButton
59
+ * -----------------------------------------------------------------------------------------------*/
60
+
61
+ const DefaultMuteButton = React.forwardRef<HTMLButtonElement, DefaultMediaButtonProps>(
62
+ ({ tooltip }, forwardRef) => {
63
+ const { icons: Icons } = useDefaultLayoutContext(),
64
+ muteText = useDefaultLayoutWord('Mute'),
65
+ unmuteText = useDefaultLayoutWord('Unmute'),
66
+ $muted = useMediaState('muted'),
67
+ $volume = useMediaState('volume');
68
+ return (
69
+ <DefaultTooltip content={$muted ? unmuteText : muteText} placement={tooltip}>
70
+ <MuteButton className="vds-mute-button vds-button" aria-label={muteText} ref={forwardRef}>
71
+ {$muted || $volume == 0 ? (
72
+ <Icons.MuteButton.Mute className="vds-icon" />
73
+ ) : $volume < 0.5 ? (
74
+ <Icons.MuteButton.VolumeLow className="vds-icon" />
75
+ ) : (
76
+ <Icons.MuteButton.VolumeHigh className="vds-icon" />
77
+ )}
78
+ </MuteButton>
79
+ </DefaultTooltip>
80
+ );
81
+ },
82
+ );
83
+
84
+ DefaultMuteButton.displayName = 'DefaultMuteButton';
85
+ export { DefaultMuteButton };
86
+
87
+ /* -------------------------------------------------------------------------------------------------
88
+ * DefaultCaptionButton
89
+ * -----------------------------------------------------------------------------------------------*/
90
+
91
+ function DefaultCaptionButton({ tooltip }: DefaultMediaButtonProps) {
92
+ const { icons: Icons } = useDefaultLayoutContext(),
93
+ captionsText = useDefaultLayoutWord('Captions'),
94
+ onText = useDefaultLayoutWord('Closed-Captions On'),
95
+ offText = useDefaultLayoutWord('Closed-Captions Off'),
96
+ $track = useMediaState('textTrack'),
97
+ isOn = $track && isTrackCaptionKind($track);
98
+ return (
99
+ <DefaultTooltip content={isOn ? onText : offText} placement={tooltip}>
100
+ <CaptionButton className="vds-caption-button vds-button" aria-label={captionsText}>
101
+ {isOn ? (
102
+ <Icons.CaptionButton.On className="vds-icon" />
103
+ ) : (
104
+ <Icons.CaptionButton.Off className="vds-icon" />
105
+ )}
106
+ </CaptionButton>
107
+ </DefaultTooltip>
108
+ );
109
+ }
110
+
111
+ DefaultCaptionButton.displayName = 'DefaultCaptionButton';
112
+ export { DefaultCaptionButton };
113
+
114
+ /* -------------------------------------------------------------------------------------------------
115
+ * DefaultPIPButton
116
+ * -----------------------------------------------------------------------------------------------*/
117
+
118
+ function DefaultPIPButton({ tooltip }: DefaultMediaButtonProps) {
119
+ const { icons: Icons } = useDefaultLayoutContext(),
120
+ pipText = useDefaultLayoutWord('PiP'),
121
+ enterText = useDefaultLayoutWord('Enter PiP'),
122
+ exitText = useDefaultLayoutWord('Exit PiP'),
123
+ $pip = useMediaState('pictureInPicture');
124
+ return (
125
+ <DefaultTooltip content={$pip ? exitText : enterText} placement={tooltip}>
126
+ <PIPButton className="vds-pip-button vds-button" aria-label={pipText}>
127
+ {$pip ? (
128
+ <Icons.PIPButton.Exit className="vds-icon" />
129
+ ) : (
130
+ <Icons.PIPButton.Enter className="vds-icon" />
131
+ )}
132
+ </PIPButton>
133
+ </DefaultTooltip>
134
+ );
135
+ }
136
+
137
+ DefaultPIPButton.displayName = 'DefaultPIPButton';
138
+ export { DefaultPIPButton };
139
+
140
+ /* -------------------------------------------------------------------------------------------------
141
+ * DefaultFullscreenButton
142
+ * -----------------------------------------------------------------------------------------------*/
143
+
144
+ function DefaultFullscreenButton({ tooltip }: DefaultMediaButtonProps) {
145
+ const { icons: Icons } = useDefaultLayoutContext(),
146
+ fullscreenText = useDefaultLayoutWord('Fullscreen'),
147
+ enterText = useDefaultLayoutWord('Enter Fullscreen'),
148
+ exitText = useDefaultLayoutWord('Exit Fullscreen'),
149
+ $fullscreen = useMediaState('fullscreen');
150
+ return (
151
+ <DefaultTooltip content={$fullscreen ? exitText : enterText} placement={tooltip}>
152
+ <FullscreenButton className="vds-fullscreen-button vds-button" aria-label={fullscreenText}>
153
+ {$fullscreen ? (
154
+ <Icons.FullscreenButton.Exit className="vds-icon" />
155
+ ) : (
156
+ <Icons.FullscreenButton.Enter className="vds-icon" />
157
+ )}
158
+ </FullscreenButton>
159
+ </DefaultTooltip>
160
+ );
161
+ }
162
+
163
+ DefaultFullscreenButton.displayName = 'DefaultFullscreenButton';
164
+ export { DefaultFullscreenButton };
165
+
166
+ /* -------------------------------------------------------------------------------------------------
167
+ * DefaultSeekButton
168
+ * -----------------------------------------------------------------------------------------------*/
169
+
170
+ function DefaultSeekButton({
171
+ backward,
172
+ tooltip,
173
+ }: DefaultMediaButtonProps & { backward?: boolean }) {
174
+ const { icons: Icons, seekStep } = useDefaultLayoutContext(),
175
+ seekForwardText = useDefaultLayoutWord('Seek Forward'),
176
+ seekBackwardText = useDefaultLayoutWord('Seek Backward'),
177
+ seconds = (backward ? -1 : 1) * seekStep!,
178
+ label = seconds >= 0 ? seekForwardText : seekBackwardText;
179
+ return (
180
+ <DefaultTooltip content={label} placement={tooltip}>
181
+ <SeekButton className="vds-seek-button vds-button" seconds={seconds} aria-label={label}>
182
+ {seconds >= 0 ? (
183
+ <Icons.SeekButton.Forward className="vds-icon" />
184
+ ) : (
185
+ <Icons.SeekButton.Backward className="vds-icon" />
186
+ )}
187
+ </SeekButton>
188
+ </DefaultTooltip>
189
+ );
190
+ }
191
+
192
+ DefaultSeekButton.displayName = 'DefaultSeekButton';
193
+ export { DefaultSeekButton };
194
+
195
+ /* -------------------------------------------------------------------------------------------------
196
+ * DefaultAirPlayButton
197
+ * -----------------------------------------------------------------------------------------------*/
198
+
199
+ function DefaultAirPlayButton({ tooltip }: DefaultMediaButtonProps) {
200
+ const { icons: Icons } = useDefaultLayoutContext(),
201
+ airPlayText = useDefaultLayoutWord('AirPlay'),
202
+ $state = useMediaState('remotePlaybackState'),
203
+ stateText = useDefaultLayoutWord(uppercaseFirstChar($state) as Capitalize<RemotePlaybackState>),
204
+ label = `${airPlayText} ${stateText}`,
205
+ Icon =
206
+ ($state === 'connecting'
207
+ ? Icons.AirPlayButton.Connecting
208
+ : $state === 'connected'
209
+ ? Icons.AirPlayButton.Connected
210
+ : null) ?? Icons.AirPlayButton.Default;
211
+ return (
212
+ <DefaultTooltip content={airPlayText} placement={tooltip}>
213
+ <AirPlayButton className="vds-airplay-button vds-button" aria-label={label}>
214
+ <Icon className="vds-icon" />
215
+ </AirPlayButton>
216
+ </DefaultTooltip>
217
+ );
218
+ }
219
+
220
+ DefaultAirPlayButton.displayName = 'DefaultAirPlayButton';
221
+ export { DefaultAirPlayButton };
222
+
223
+ /* -------------------------------------------------------------------------------------------------
224
+ * DefaultGoogleCastButton
225
+ * -----------------------------------------------------------------------------------------------*/
226
+
227
+ function DefaultGoogleCastButton({ tooltip }: DefaultMediaButtonProps) {
228
+ const { icons: Icons } = useDefaultLayoutContext(),
229
+ googleCastText = useDefaultLayoutWord('Google Cast'),
230
+ $state = useMediaState('remotePlaybackState'),
231
+ stateText = useDefaultLayoutWord(uppercaseFirstChar($state) as Capitalize<RemotePlaybackState>),
232
+ label = `${googleCastText} ${stateText}`,
233
+ Icon =
234
+ ($state === 'connecting'
235
+ ? Icons.GoogleCastButton.Connecting
236
+ : $state === 'connected'
237
+ ? Icons.GoogleCastButton.Connected
238
+ : null) ?? Icons.GoogleCastButton.Default;
239
+ return (
240
+ <DefaultTooltip content={googleCastText} placement={tooltip}>
241
+ <GoogleCastButton className="vds-google-cast-button vds-button" aria-label={label}>
242
+ <Icon className="vds-icon" />
243
+ </GoogleCastButton>
244
+ </DefaultTooltip>
245
+ );
246
+ }
247
+
248
+ DefaultGoogleCastButton.displayName = 'DefaultGoogleCastButton';
249
+ export { DefaultGoogleCastButton };
250
+
251
+ /* -------------------------------------------------------------------------------------------------
252
+ * DefaultLiveButton
253
+ * -----------------------------------------------------------------------------------------------*/
254
+
255
+ function DefaultLiveButton() {
256
+ const $live = useMediaState('live'),
257
+ label = useDefaultLayoutWord('Skip To Live'),
258
+ liveText = useDefaultLayoutWord('LIVE');
259
+ return $live ? (
260
+ <LiveButton className="vds-live-button" aria-label={label}>
261
+ <span className="vds-live-button-text">{liveText}</span>
262
+ </LiveButton>
263
+ ) : null;
264
+ }
265
+
266
+ DefaultLiveButton.displayName = 'DefaultLiveButton';
267
+ export { DefaultLiveButton };
268
+
269
+ /* -------------------------------------------------------------------------------------------------
270
+ * DefaultDownloadButton
271
+ * -----------------------------------------------------------------------------------------------*/
272
+
273
+ function DefaultDownloadButton() {
274
+ const { download, icons: Icons } = useDefaultLayoutContext(),
275
+ $src = useMediaState('source'),
276
+ $title = useMediaState('title'),
277
+ file = getDownloadFile({
278
+ title: $title,
279
+ src: $src,
280
+ download,
281
+ }),
282
+ downloadText = useDefaultLayoutWord('Download');
283
+
284
+ return isString(file?.url) ? (
285
+ <DefaultTooltip content={downloadText} placement="top">
286
+ <a
287
+ role="button"
288
+ className="vds-download-button vds-button"
289
+ aria-label={downloadText}
290
+ href={appendParamsToURL(file.url, { download: file.name })}
291
+ download={file.name}
292
+ target="_blank"
293
+ >
294
+ {Icons.DownloadButton ? <Icons.DownloadButton.Default className="vds-icon" /> : null}
295
+ </a>
296
+ </DefaultTooltip>
297
+ ) : null;
298
+ }
299
+
300
+ DefaultDownloadButton.displayName = 'DefaultDownloadButton';
301
+ export { DefaultDownloadButton };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+
3
+ import { Captions } from '../../../ui/captions';
4
+ import { useDefaultLayoutWord } from '../context';
5
+
6
+ /* -------------------------------------------------------------------------------------------------
7
+ * DefaultCaptions
8
+ * -----------------------------------------------------------------------------------------------*/
9
+
10
+ function DefaultCaptions() {
11
+ const exampleText = useDefaultLayoutWord('Captions look like this');
12
+ return <Captions className="vds-captions" exampleText={exampleText} />;
13
+ }
14
+
15
+ DefaultCaptions.displayName = 'DefaultCaptions';
16
+ export { DefaultCaptions };
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+
3
+ /* -------------------------------------------------------------------------------------------------
4
+ * DefaultControlsSpacer
5
+ * -----------------------------------------------------------------------------------------------*/
6
+
7
+ function DefaultControlsSpacer() {
8
+ return <div className="vds-controls-spacer" />;
9
+ }
10
+
11
+ DefaultControlsSpacer.displayName = 'DefaultControlsSpacer';
12
+ export { DefaultControlsSpacer };
@@ -0,0 +1,132 @@
1
+ import * as React from 'react';
2
+
3
+ import { useContext } from 'maverick.js';
4
+ import { useSignal } from 'maverick.js/react';
5
+ import { camelToKebabCase } from 'maverick.js/std';
6
+ import { mediaContext } from 'vidstack';
7
+
8
+ import { useMediaState } from '../../../../hooks/use-media-state';
9
+ import { createComputed, createEffect } from '../../../../hooks/use-signals';
10
+ import { Primitive, type PrimitivePropsWithRef } from '../../../primitives/nodes';
11
+ import type { DefaultKeyboardDisplayIcons } from '../icons';
12
+
13
+ export interface DefaultKeyboardDisplayProps
14
+ extends Omit<PrimitivePropsWithRef<'div'>, 'disabled'> {
15
+ icons: Partial<DefaultKeyboardDisplayIcons>;
16
+ }
17
+
18
+ const DefaultKeyboardDisplay = React.forwardRef<HTMLElement, DefaultKeyboardDisplayProps>(
19
+ ({ icons: Icons, ...props }, forwardRef) => {
20
+ const [visible, setVisible] = React.useState(false),
21
+ [Icon, setIcon] = React.useState<any>(null),
22
+ [count, setCount] = React.useState(0),
23
+ $lastKeyboardAction = useMediaState('lastKeyboardAction');
24
+
25
+ React.useEffect(() => {
26
+ setCount((n) => n + 1);
27
+ }, [$lastKeyboardAction]);
28
+
29
+ const actionDataAttr = React.useMemo(() => {
30
+ const action = $lastKeyboardAction?.action;
31
+ return action && visible ? camelToKebabCase(action) : null;
32
+ }, [visible, $lastKeyboardAction]);
33
+
34
+ const className = React.useMemo(
35
+ () =>
36
+ `vds-kb-action${!visible ? ' hidden' : ''}${props.className ? ` ${props.className}` : ''}`,
37
+ [visible],
38
+ );
39
+
40
+ const $$text = createComputed(getText),
41
+ $text = useSignal($$text);
42
+
43
+ createEffect(() => {
44
+ const Icon = getIcon(Icons);
45
+ setIcon(() => Icon);
46
+ }, [Icons]);
47
+
48
+ React.useEffect(() => {
49
+ setVisible(!!$lastKeyboardAction);
50
+ const id = setTimeout(() => setVisible(false), 500);
51
+ return () => {
52
+ setVisible(false);
53
+ window.clearTimeout(id);
54
+ };
55
+ }, [$lastKeyboardAction]);
56
+
57
+ return Icon ? (
58
+ <Primitive.div
59
+ {...props}
60
+ className={className}
61
+ data-action={actionDataAttr}
62
+ ref={forwardRef as React.Ref<any>}
63
+ >
64
+ <div className="vds-kb-text-wrapper">
65
+ <div className="vds-kb-text">{$text}</div>
66
+ </div>
67
+ <div className="vds-kb-bezel" key={count}>
68
+ <div className="vds-kb-icon">
69
+ <Icon />
70
+ </div>
71
+ </div>
72
+ </Primitive.div>
73
+ ) : null;
74
+ },
75
+ );
76
+
77
+ DefaultKeyboardDisplay.displayName = 'DefaultKeyboardDisplay';
78
+ export { DefaultKeyboardDisplay };
79
+
80
+ function getText() {
81
+ const { $state } = useContext(mediaContext),
82
+ action = $state.lastKeyboardAction()?.action,
83
+ audioGain = $state.audioGain() ?? 1;
84
+ switch (action) {
85
+ case 'toggleMuted':
86
+ return $state.muted() ? '0%' : getVolumeText($state.volume(), audioGain);
87
+ case 'volumeUp':
88
+ case 'volumeDown':
89
+ return getVolumeText($state.volume(), audioGain);
90
+ default:
91
+ return '';
92
+ }
93
+ }
94
+
95
+ function getVolumeText(volume: number, gain: number) {
96
+ return `${Math.round(volume * gain * 100)}%`;
97
+ }
98
+
99
+ function getIcon(Icons: Partial<DefaultKeyboardDisplayIcons>) {
100
+ const { $state } = useContext(mediaContext),
101
+ action = $state.lastKeyboardAction()?.action;
102
+ switch (action) {
103
+ case 'togglePaused':
104
+ return !$state.paused() ? Icons.Play : Icons.Pause;
105
+ case 'toggleMuted':
106
+ return $state.muted() || $state.volume() === 0
107
+ ? Icons.Mute
108
+ : $state.volume() >= 0.5
109
+ ? Icons.VolumeUp
110
+ : Icons.VolumeDown;
111
+ case 'toggleFullscreen':
112
+ return $state.fullscreen() ? Icons.EnterFullscreen : Icons.ExitFullscreen;
113
+ case 'togglePictureInPicture':
114
+ return $state.pictureInPicture() ? Icons.EnterPiP : Icons.ExitPiP;
115
+ case 'toggleCaptions':
116
+ return $state.hasCaptions()
117
+ ? $state.textTrack()
118
+ ? Icons.CaptionsOn
119
+ : Icons.CaptionsOff
120
+ : null;
121
+ case 'volumeUp':
122
+ return Icons.VolumeUp;
123
+ case 'volumeDown':
124
+ return Icons.VolumeDown;
125
+ case 'seekForward':
126
+ return Icons.SeekForward;
127
+ case 'seekBackward':
128
+ return Icons.SeekBackward;
129
+ default:
130
+ return null;
131
+ }
132
+ }
@@ -0,0 +1,100 @@
1
+ import * as React from 'react';
2
+
3
+ import { useMediaState } from '../../../../../hooks/use-media-state';
4
+ import * as Menu from '../../../../ui/menu';
5
+ import { useDefaultLayoutContext, useDefaultLayoutWord } from '../../context';
6
+ import { slot, type DefaultLayoutMenuSlotName, type Slots } from '../../slots';
7
+ import { DefaultFontMenu } from './font-menu';
8
+ import { DefaultMenuCheckbox } from './items/menu-checkbox';
9
+ import { DefaultMenuButton, DefaultMenuItem, DefaultMenuSection } from './items/menu-items';
10
+
11
+ /* -------------------------------------------------------------------------------------------------
12
+ * DefaultAccessibilityMenu
13
+ * -----------------------------------------------------------------------------------------------*/
14
+
15
+ interface DefaultAccessibilityMenuProps {
16
+ slots?: Slots<DefaultLayoutMenuSlotName>;
17
+ }
18
+
19
+ function DefaultAccessibilityMenu({ slots }: DefaultAccessibilityMenuProps) {
20
+ const label = useDefaultLayoutWord('Accessibility'),
21
+ { icons: Icons } = useDefaultLayoutContext();
22
+
23
+ return (
24
+ <Menu.Root className="vds-accessibility-menu vds-menu">
25
+ <DefaultMenuButton label={label} Icon={Icons.Menu.Accessibility} />
26
+ <Menu.Content className="vds-menu-items">
27
+ {slot(slots, 'accessibilityMenuItemsStart', null)}
28
+
29
+ <DefaultMenuSection>
30
+ <DefaultAnnouncementsMenuCheckbox />
31
+ <DefaultKeyboardAnimationsMenuCheckbox />
32
+ </DefaultMenuSection>
33
+
34
+ <DefaultMenuSection>
35
+ <DefaultFontMenu />
36
+ </DefaultMenuSection>
37
+
38
+ {slot(slots, 'accessibilityMenuItemsEnd', null)}
39
+ </Menu.Content>
40
+ </Menu.Root>
41
+ );
42
+ }
43
+
44
+ DefaultAccessibilityMenu.displayName = 'DefaultAccessibilityMenu';
45
+ export { DefaultAccessibilityMenu };
46
+
47
+ /* -------------------------------------------------------------------------------------------------
48
+ * DefaultAnnouncementsMenuCheckbox
49
+ * -----------------------------------------------------------------------------------------------*/
50
+
51
+ function DefaultAnnouncementsMenuCheckbox() {
52
+ const { userPrefersAnnouncements } = useDefaultLayoutContext(),
53
+ label = useDefaultLayoutWord('Announcements');
54
+
55
+ function onChange(checked: boolean) {
56
+ userPrefersAnnouncements.set(checked);
57
+ }
58
+
59
+ return (
60
+ <DefaultMenuItem label={label}>
61
+ <DefaultMenuCheckbox
62
+ label={label}
63
+ defaultChecked
64
+ storageKey="vds-player::announcements"
65
+ onChange={onChange}
66
+ />
67
+ </DefaultMenuItem>
68
+ );
69
+ }
70
+
71
+ DefaultAnnouncementsMenuCheckbox.displayName = 'DefaultAnnouncementsMenuCheckbox';
72
+
73
+ /* -------------------------------------------------------------------------------------------------
74
+ * DefaultKeyboardAnimationsMenuCheckbox
75
+ * -----------------------------------------------------------------------------------------------*/
76
+
77
+ function DefaultKeyboardAnimationsMenuCheckbox() {
78
+ const $viewType = useMediaState('viewType'),
79
+ { userPrefersKeyboardAnimations, noKeyboardAnimations } = useDefaultLayoutContext(),
80
+ label = useDefaultLayoutWord('Keyboard Animations');
81
+
82
+ if ($viewType !== 'video' || noKeyboardAnimations) return null;
83
+
84
+ function onChange(checked: boolean) {
85
+ userPrefersKeyboardAnimations.set(checked);
86
+ }
87
+
88
+ return (
89
+ <DefaultMenuItem label={label}>
90
+ <DefaultMenuCheckbox
91
+ label={label}
92
+ defaultChecked
93
+ storageKey="vds-player::keyboard-animations"
94
+ onChange={onChange}
95
+ />
96
+ </DefaultMenuItem>
97
+ );
98
+ }
99
+
100
+ DefaultKeyboardAnimationsMenuCheckbox.displayName = 'DefaultKeyboardAnimationsMenuCheckbox';