@therealtinhtute/baroiplayer 1.2.0 → 2.0.0-beta.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 (305) hide show
  1. package/README.md +91 -73
  2. package/dist/components/icons/index.d.ts +36 -0
  3. package/dist/components/icons/index.d.ts.map +1 -0
  4. package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts +4 -0
  5. package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts.map +1 -0
  6. package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts +5 -0
  7. package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts.map +1 -0
  8. package/dist/components/icons/svg-icons/AudioIcon.d.ts +5 -0
  9. package/dist/components/icons/svg-icons/AudioIcon.d.ts.map +1 -0
  10. package/dist/components/icons/svg-icons/BackwardIcon.d.ts +5 -0
  11. package/dist/components/icons/svg-icons/BackwardIcon.d.ts.map +1 -0
  12. package/dist/components/icons/svg-icons/CameraIcon.d.ts +5 -0
  13. package/dist/components/icons/svg-icons/CameraIcon.d.ts.map +1 -0
  14. package/dist/components/icons/svg-icons/CheckIcon.d.ts +5 -0
  15. package/dist/components/icons/svg-icons/CheckIcon.d.ts.map +1 -0
  16. package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts +4 -0
  17. package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts.map +1 -0
  18. package/dist/components/icons/svg-icons/ForwardIcon.d.ts +5 -0
  19. package/dist/components/icons/svg-icons/ForwardIcon.d.ts.map +1 -0
  20. package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts +5 -0
  21. package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts.map +1 -0
  22. package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts +5 -0
  23. package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts.map +1 -0
  24. package/dist/components/icons/svg-icons/LoadingIcon.d.ts +5 -0
  25. package/dist/components/icons/svg-icons/LoadingIcon.d.ts.map +1 -0
  26. package/dist/components/icons/svg-icons/PauseIcon.d.ts +5 -0
  27. package/dist/components/icons/svg-icons/PauseIcon.d.ts.map +1 -0
  28. package/dist/components/icons/svg-icons/PlayIcon.d.ts +5 -0
  29. package/dist/components/icons/svg-icons/PlayIcon.d.ts.map +1 -0
  30. package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts +5 -0
  31. package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts.map +1 -0
  32. package/dist/components/icons/svg-icons/QualityIcon.d.ts +5 -0
  33. package/dist/components/icons/svg-icons/QualityIcon.d.ts.map +1 -0
  34. package/dist/components/icons/svg-icons/SettingsIcon.d.ts +5 -0
  35. package/dist/components/icons/svg-icons/SettingsIcon.d.ts.map +1 -0
  36. package/dist/components/icons/svg-icons/SliderIcon.d.ts +5 -0
  37. package/dist/components/icons/svg-icons/SliderIcon.d.ts.map +1 -0
  38. package/dist/components/icons/svg-icons/SubtitleIcon.d.ts +5 -0
  39. package/dist/components/icons/svg-icons/SubtitleIcon.d.ts.map +1 -0
  40. package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts +5 -0
  41. package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts.map +1 -0
  42. package/dist/components/icons/svg-icons/UnPiPIcon.d.ts +4 -0
  43. package/dist/components/icons/svg-icons/UnPiPIcon.d.ts.map +1 -0
  44. package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts +5 -0
  45. package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts.map +1 -0
  46. package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts +5 -0
  47. package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts.map +1 -0
  48. package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts +5 -0
  49. package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts.map +1 -0
  50. package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts +5 -0
  51. package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts.map +1 -0
  52. package/dist/components/variants/gradient/gradient-audio.d.ts +13 -0
  53. package/dist/components/variants/gradient/gradient-audio.d.ts.map +1 -0
  54. package/dist/components/variants/gradient/gradient-controls.d.ts +4 -0
  55. package/dist/components/variants/gradient/gradient-controls.d.ts.map +1 -0
  56. package/dist/components/variants/gradient/gradient-glyphs.d.ts +30 -0
  57. package/dist/components/variants/gradient/gradient-glyphs.d.ts.map +1 -0
  58. package/dist/components/variants/gradient/gradient-video.d.ts +16 -0
  59. package/dist/components/variants/gradient/gradient-video.d.ts.map +1 -0
  60. package/dist/index.css +1 -1
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +2 -112
  64. package/dist/index.js.map +1 -1
  65. package/dist/index.mjs +786 -6271
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/package.json +3 -0
  68. package/package.json +110 -108
  69. package/src/components/variants/gradient/gradient-audio.tsx +47 -0
  70. package/src/components/variants/gradient/gradient-controls.tsx +254 -0
  71. package/src/components/variants/gradient/gradient-glyphs.test.tsx +69 -0
  72. package/src/components/variants/gradient/gradient-glyphs.tsx +129 -0
  73. package/src/components/variants/gradient/gradient-skin.css +211 -0
  74. package/src/components/variants/gradient/gradient-video.tsx +70 -0
  75. package/src/index.ts +5 -198
  76. package/src/test/accessibility-utils.ts +0 -59
  77. package/dist/context/media.js +0 -2
  78. package/dist/context/media.js.map +0 -1
  79. package/dist/context/media.mjs +0 -15
  80. package/dist/context/media.mjs.map +0 -1
  81. package/dist/context/store.js +0 -2
  82. package/dist/context/store.js.map +0 -1
  83. package/dist/context/store.mjs +0 -5
  84. package/dist/context/store.mjs.map +0 -1
  85. package/dist/context-BYwDoSRX.js +0 -1172
  86. package/dist/context-BYwDoSRX.js.map +0 -1
  87. package/dist/context-eNS62_ac.cjs +0 -23
  88. package/dist/context-eNS62_ac.cjs.map +0 -1
  89. package/dist/core-events-B1iM2F46.cjs +0 -2
  90. package/dist/core-events-B1iM2F46.cjs.map +0 -1
  91. package/dist/core-events-DunPHKRE.js +0 -484
  92. package/dist/core-events-DunPHKRE.js.map +0 -1
  93. package/dist/core-plugins-By-4-kGs.cjs +0 -2
  94. package/dist/core-plugins-By-4-kGs.cjs.map +0 -1
  95. package/dist/core-plugins-DSBWcTuX.js +0 -821
  96. package/dist/core-plugins-DSBWcTuX.js.map +0 -1
  97. package/dist/core.js +0 -37
  98. package/dist/core.js.map +0 -1
  99. package/dist/core.mjs +0 -1233
  100. package/dist/core.mjs.map +0 -1
  101. package/dist/enhanced-components-B_l3cist.js +0 -1142
  102. package/dist/enhanced-components-B_l3cist.js.map +0 -1
  103. package/dist/enhanced-components-BspFs9OO.cjs +0 -2
  104. package/dist/enhanced-components-BspFs9OO.cjs.map +0 -1
  105. package/dist/hooks-BXwI8QG6.cjs +0 -4
  106. package/dist/hooks-BXwI8QG6.cjs.map +0 -1
  107. package/dist/hooks-Bpi-jDiO.js +0 -1816
  108. package/dist/hooks-Bpi-jDiO.js.map +0 -1
  109. package/dist/minimal-components-C4z900Ro.js +0 -1926
  110. package/dist/minimal-components-C4z900Ro.js.map +0 -1
  111. package/dist/minimal-components-v4qBp6jv.cjs +0 -2
  112. package/dist/minimal-components-v4qBp6jv.cjs.map +0 -1
  113. package/dist/minimal-components.css +0 -1
  114. package/dist/mona-loading.gif +0 -0
  115. package/dist/performance-monitor-C5k6FDXw.js +0 -301
  116. package/dist/performance-monitor-C5k6FDXw.js.map +0 -1
  117. package/dist/performance-monitor-lJmuUjQQ.cjs +0 -2
  118. package/dist/performance-monitor-lJmuUjQQ.cjs.map +0 -1
  119. package/dist/utils-CFOue_9K.cjs +0 -9
  120. package/dist/utils-CFOue_9K.cjs.map +0 -1
  121. package/dist/utils-Dzpl2ArK.js +0 -2844
  122. package/dist/utils-Dzpl2ArK.js.map +0 -1
  123. package/dist/utils.js +0 -2
  124. package/dist/utils.js.map +0 -1
  125. package/dist/utils.mjs +0 -11
  126. package/dist/utils.mjs.map +0 -1
  127. package/src/adapters/videojs-adapter.tsx +0 -470
  128. package/src/assets/mona-loading.gif +0 -0
  129. package/src/components/AnimateLoading.tsx +0 -107
  130. package/src/components/LoadingState.tsx +0 -239
  131. package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
  132. package/src/components/__tests__/media-player-react19.test.tsx +0 -457
  133. package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
  134. package/src/components/audio-player.tsx +0 -85
  135. package/src/components/basic/index.ts +0 -37
  136. package/src/components/enhanced/advanced-features.tsx +0 -311
  137. package/src/components/enhanced/debug-panel.tsx +0 -448
  138. package/src/components/enhanced/enhanced-controls.tsx +0 -597
  139. package/src/components/enhanced/enhanced-media-player.tsx +0 -566
  140. package/src/components/enhanced/error-handling.tsx +0 -338
  141. package/src/components/enhanced/index.ts +0 -39
  142. package/src/components/enhanced/media-player-enhanced.tsx +0 -383
  143. package/src/components/examples/basic-video-player.tsx +0 -50
  144. package/src/components/examples/custom-controls-example.tsx +0 -63
  145. package/src/components/examples/enhanced-controls-example.tsx +0 -100
  146. package/src/components/examples/enhanced-media-player-example.tsx +0 -302
  147. package/src/components/examples/loading-states-demo.tsx +0 -142
  148. package/src/components/examples/react-19-demo.tsx +0 -353
  149. package/src/components/examples/volume-orientation-demo.tsx +0 -106
  150. package/src/components/icon-demo.tsx +0 -196
  151. package/src/components/legacy.tsx +0 -87
  152. package/src/components/media-metadata-display.tsx +0 -99
  153. package/src/components/media-player-audio.tsx +0 -39
  154. package/src/components/media-player-controls.tsx +0 -223
  155. package/src/components/media-player-error.tsx +0 -163
  156. package/src/components/media-player-fullscreen.tsx +0 -109
  157. package/src/components/media-player-hls.tsx +0 -111
  158. package/src/components/media-player-loading.tsx +0 -76
  159. package/src/components/media-player-play.tsx +0 -75
  160. package/src/components/media-player-root.tsx +0 -338
  161. package/src/components/media-player-seek.tsx +0 -168
  162. package/src/components/media-player-time.tsx +0 -99
  163. package/src/components/media-player-tooltip.tsx +0 -58
  164. package/src/components/media-player-video.tsx +0 -54
  165. package/src/components/media-player-volume.tsx +0 -155
  166. package/src/components/media-player.tsx +0 -292
  167. package/src/components/media-suspense.tsx +0 -344
  168. package/src/components/player-settings-form.tsx +0 -158
  169. package/src/components/react-player-wrapper.tsx +0 -651
  170. package/src/components/simple-video-player.tsx +0 -62
  171. package/src/components/ui/blur-poster.tsx +0 -93
  172. package/src/components/ui/empty-state.tsx +0 -91
  173. package/src/components/ui/enhanced-seek-bar.tsx +0 -254
  174. package/src/components/ui/error-state.tsx +0 -124
  175. package/src/components/ui/fullscreen-button.tsx +0 -81
  176. package/src/components/ui/loading-skeleton.tsx +0 -107
  177. package/src/components/ui/media-resource-preloader.tsx +0 -458
  178. package/src/components/ui/offline-message.tsx +0 -98
  179. package/src/components/ui/play-button.tsx +0 -99
  180. package/src/components/ui/seek-bar.tsx +0 -191
  181. package/src/components/ui/time-display.tsx +0 -61
  182. package/src/components/ui/volume-control.tsx +0 -190
  183. package/src/components/unified/base-media-player.tsx +0 -252
  184. package/src/components/unified/media-player.tsx +0 -75
  185. package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
  186. package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
  187. package/src/components/variants/minimal/MinimalControls.tsx +0 -124
  188. package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
  189. package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
  190. package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
  191. package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
  192. package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
  193. package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
  194. package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
  195. package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
  196. package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
  197. package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
  198. package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
  199. package/src/components/variants/minimal/components/RightControls.tsx +0 -164
  200. package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
  201. package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
  202. package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
  203. package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
  204. package/src/components/variants/minimal/components/VideoElement.tsx +0 -33
  205. package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
  206. package/src/components/variants/minimal/index.ts +0 -23
  207. package/src/components/video-player.tsx +0 -100
  208. package/src/context/__tests__/media-store.test.ts +0 -509
  209. package/src/context/error-handling.ts +0 -398
  210. package/src/context/media-context.tsx +0 -254
  211. package/src/context/media-provider.tsx +0 -264
  212. package/src/context/media-store.ts +0 -387
  213. package/src/context/persistence.ts +0 -462
  214. package/src/core/events/event-system.ts +0 -448
  215. package/src/core/events/hooks.ts +0 -325
  216. package/src/core/events/index.ts +0 -22
  217. package/src/core/events/middleware.ts +0 -286
  218. package/src/core/index.ts +0 -22
  219. package/src/core/optimization/bundle-optimizer.tsx +0 -312
  220. package/src/core/performance/cicd.ts +0 -98
  221. package/src/core/performance/index.ts +0 -38
  222. package/src/core/performance/media-loading-optimizer.ts +0 -544
  223. package/src/core/performance/performance-budgets.ts +0 -437
  224. package/src/core/performance/performance-monitor.tsx +0 -488
  225. package/src/core/performance/performance-testing.ts +0 -461
  226. package/src/core/plugins/__tests__/registry.test.ts +0 -595
  227. package/src/core/plugins/base-plugin.ts +0 -225
  228. package/src/core/plugins/enhanced-plugin-system.ts +0 -435
  229. package/src/core/plugins/examples/analytics-plugin.ts +0 -241
  230. package/src/core/plugins/index.ts +0 -39
  231. package/src/core/plugins/registry.ts +0 -546
  232. package/src/core/plugins/types.ts +0 -169
  233. package/src/core/plugins/utils.ts +0 -317
  234. package/src/core/progressive-loading.tsx +0 -331
  235. package/src/core/providers/enhanced-hls-provider.ts +0 -307
  236. package/src/core/providers/lazy-provider.tsx +0 -14
  237. package/src/core/providers/service-provider.tsx +0 -164
  238. package/src/core/utils.tsx +0 -34
  239. package/src/features/media-session/media-session-manager.ts +0 -411
  240. package/src/features/picture-in-picture/pip-manager.ts +0 -428
  241. package/src/features/playlist/playlist-manager.ts +0 -626
  242. package/src/features/subtitles/subtitle-manager.ts +0 -435
  243. package/src/features/subtitles/subtitle-parser.ts +0 -284
  244. package/src/features/thumbnails/thumbnail-generator.ts +0 -528
  245. package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
  246. package/src/hooks/__tests__/use-media-player.test.ts +0 -712
  247. package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
  248. package/src/hooks/accessibility/index.ts +0 -27
  249. package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
  250. package/src/hooks/accessibility/use-focus-management.ts +0 -183
  251. package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
  252. package/src/hooks/accessibility/use-screen-reader.ts +0 -212
  253. package/src/hooks/core/index.ts +0 -47
  254. package/src/hooks/legacy.ts +0 -21
  255. package/src/hooks/use-buffer-health.ts +0 -218
  256. package/src/hooks/use-enhanced-media-player.ts +0 -575
  257. package/src/hooks/use-focus-trap.tsx +0 -162
  258. package/src/hooks/use-intelligent-preloading.ts +0 -387
  259. package/src/hooks/use-keyboard-controls.ts +0 -115
  260. package/src/hooks/use-keyboard-shortcuts.ts +0 -255
  261. package/src/hooks/use-media-actions.ts +0 -184
  262. package/src/hooks/use-media-metadata.ts +0 -91
  263. package/src/hooks/use-media-optimistic.ts +0 -264
  264. package/src/hooks/use-media-player.ts +0 -343
  265. package/src/hooks/use-media-state.ts +0 -194
  266. package/src/hooks/use-memory-optimization.ts +0 -360
  267. package/src/hooks/use-network-status.ts +0 -124
  268. package/src/hooks/use-optimistic-controls.ts +0 -95
  269. package/src/hooks/use-optimized-media.ts +0 -283
  270. package/src/hooks/use-smart-preload.ts +0 -229
  271. package/src/hooks/use-touch-gestures.ts +0 -461
  272. package/src/hooks/useEnhancedSubtitles.ts +0 -258
  273. package/src/hooks/useKeyboardShortcuts.ts +0 -106
  274. package/src/hooks/useMediaControls.ts +0 -52
  275. package/src/hooks/useScreenshot.ts +0 -61
  276. package/src/hooks/useSubtitles.ts +0 -91
  277. package/src/hooks/useVideoPlayer.ts +0 -278
  278. package/src/icons/components/FullscreenIcon.tsx +0 -36
  279. package/src/icons/components/SettingsIcon.tsx +0 -37
  280. package/src/icons/components/animated/LoadingIcon.tsx +0 -27
  281. package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
  282. package/src/icons/components/media/PauseIcon.tsx +0 -38
  283. package/src/icons/components/media/PlayIcon.tsx +0 -37
  284. package/src/icons/components/volume/VolumeIcon.tsx +0 -38
  285. package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
  286. package/src/icons/index.ts +0 -56
  287. package/src/icons/provider.tsx +0 -58
  288. package/src/icons/types.ts +0 -60
  289. package/src/index-enhanced.ts +0 -35
  290. package/src/index-legacy.ts +0 -324
  291. package/src/index.css +0 -102
  292. package/src/lib/__tests__/async-utils.test.ts +0 -291
  293. package/src/lib/async-utils.ts +0 -194
  294. package/src/lib/deprecation.ts +0 -51
  295. package/src/lib/format-time.ts +0 -37
  296. package/src/lib/index.ts +0 -4
  297. package/src/lib/utils.ts +0 -6
  298. package/src/styles/globals.css +0 -462
  299. package/src/styles/minimal-player.css +0 -621
  300. package/src/styles/pixel-art.css +0 -41
  301. package/src/styles/videojs.css +0 -100
  302. package/src/types/events.ts +0 -47
  303. package/src/types/formats.ts +0 -79
  304. package/src/types/index.ts +0 -203
  305. package/src/types/videojs-plugins.d.ts +0 -14
@@ -1,168 +0,0 @@
1
- "use client"
2
-
3
- import { Slider } from "@rp/ui/components/slider"
4
- import React from "react"
5
- import {
6
- MediaActionTypes,
7
- useMediaContext,
8
- useMediaDispatch,
9
- useMediaSelector
10
- } from "../context/media-context"
11
- import { formatTime } from "../lib/format-time"
12
- import { cn } from "../lib/utils"
13
-
14
- export interface MediaPlayerSeekProps {
15
- className?: string
16
- disabled?: boolean
17
- withTime?: boolean
18
- withoutTooltip?: boolean
19
- tooltipTimeVariant?: "current" | "remaining" | "duration"
20
- asChild?: boolean
21
- children?: React.ReactNode
22
- }
23
-
24
- export function MediaPlayerSeek({
25
- className,
26
- disabled = false,
27
- withTime = true,
28
- withoutTooltip = false,
29
- tooltipTimeVariant = "current",
30
- asChild = false,
31
- children,
32
- ...props
33
- }: MediaPlayerSeekProps) {
34
- const context = useMediaContext()
35
- const dispatch = useMediaDispatch()
36
-
37
- const currentTime = useMediaSelector((state) => state.currentTime)
38
- const duration = useMediaSelector((state) => state.duration)
39
- const buffered = useMediaSelector((state) => state.buffered)
40
- const isDisabled = disabled || useMediaSelector((state) => state.error !== null)
41
-
42
- const [isDragging, setIsDragging] = React.useState(false)
43
- const [previewTime, setPreviewTime] = React.useState<number | null>(null)
44
-
45
- const seekableStart = 0
46
- const seekableEnd = duration || 0
47
- const progress = seekableEnd > 0 ? (currentTime / seekableEnd) * 100 : 0
48
-
49
- // Calculate buffered ranges
50
- const bufferedRanges = React.useMemo(() => {
51
- if (!buffered || !seekableEnd) return []
52
-
53
- const ranges: Array<{ start: number; end: number }> = []
54
- for (let i = 0; i < buffered.length; i++) {
55
- const start = (buffered.start(i) / seekableEnd) * 100
56
- const end = (buffered.end(i) / seekableEnd) * 100
57
- ranges.push({ start, end })
58
- }
59
- return ranges
60
- }, [buffered, seekableEnd])
61
-
62
- const handleValueChange = React.useCallback(
63
- (values: number[]) => {
64
- const time = values[0] || 0
65
- setPreviewTime(time)
66
-
67
- if (isDragging) {
68
- dispatch({
69
- type: MediaActionTypes.SEEK,
70
- detail: time
71
- })
72
- }
73
- },
74
- [dispatch, isDragging]
75
- )
76
-
77
- const handleValueCommit = React.useCallback(
78
- (values: number[]) => {
79
- const time = values[0]
80
- setIsDragging(false)
81
- setPreviewTime(null)
82
-
83
- dispatch({
84
- type: MediaActionTypes.SEEK,
85
- detail: time
86
- })
87
- },
88
- [dispatch]
89
- )
90
-
91
- const handlePointerDown = React.useCallback(() => {
92
- setIsDragging(true)
93
- }, [])
94
-
95
- const getTooltipTime = React.useCallback(
96
- (time: number) => {
97
- switch (tooltipTimeVariant) {
98
- case "remaining":
99
- return formatTime(Math.max(0, seekableEnd - time))
100
- case "duration":
101
- return formatTime(seekableEnd)
102
- default:
103
- return formatTime(time)
104
- }
105
- },
106
- [tooltipTimeVariant, seekableEnd]
107
- )
108
-
109
- const sliderProps = {
110
- "aria-controls": context.mediaId,
111
- "aria-valuetext": `${formatTime(currentTime)} of ${formatTime(duration)}`,
112
- "data-slot": "media-player-seek",
113
- disabled: isDisabled,
114
- min: seekableStart,
115
- max: seekableEnd,
116
- step: 0.1,
117
- value: [previewTime ?? currentTime],
118
- onValueChange: handleValueChange,
119
- onValueCommit: handleValueCommit,
120
- onPointerDown: handlePointerDown,
121
- className: cn(
122
- "relative flex w-full touch-none select-none items-center",
123
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
124
- className
125
- ),
126
- ...props
127
- }
128
-
129
- const sliderContent = (
130
- <>
131
- {/* Track */}
132
- <div className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
133
- {/* Buffered ranges */}
134
- {bufferedRanges.map((range, index) => (
135
- <div
136
- key={index}
137
- className="absolute h-full bg-secondary/60"
138
- style={{
139
- left: `${range.start}%`,
140
- width: `${range.end - range.start}%`
141
- }}
142
- />
143
- ))}
144
-
145
- {/* Progress */}
146
- <div className="h-full bg-primary transition-all" style={{ width: `${progress}%` }} />
147
- </div>
148
-
149
- {/* Thumb */}
150
- <div
151
- className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
152
- style={{
153
- transform: `translateX(-50%)`,
154
- left: `${progress}%`
155
- }}
156
- />
157
- </>
158
- )
159
-
160
- if (asChild) {
161
- const child = React.Children.only(children) as React.ReactElement
162
- return React.cloneElement(child, sliderProps as any, sliderContent)
163
- }
164
-
165
- return <Slider {...sliderProps}>{sliderContent}</Slider>
166
- }
167
-
168
- MediaPlayerSeek.displayName = "MediaPlayerSeek"
@@ -1,99 +0,0 @@
1
- "use client"
2
-
3
- import React from "react"
4
- import { useMediaContext, useMediaSelector } from "../context/media-context"
5
- import { formatTime } from "../lib/format-time"
6
- import { cn } from "../lib/utils"
7
-
8
- export interface MediaPlayerTimeProps {
9
- variant?: "current" | "duration" | "remaining" | "current-duration"
10
- className?: string
11
- asChild?: boolean
12
- children?: React.ReactNode
13
- }
14
-
15
- export function MediaPlayerTime({
16
- variant = "current-duration",
17
- className,
18
- asChild = false,
19
- children,
20
- ...props
21
- }: MediaPlayerTimeProps) {
22
- const context = useMediaContext()
23
- const currentTime = useMediaSelector((state) => state.currentTime)
24
- const duration = useMediaSelector((state) => state.duration)
25
-
26
- const times = React.useMemo(() => {
27
- if (variant === "remaining") {
28
- return {
29
- remaining: formatTime(Math.max(0, duration - currentTime))
30
- }
31
- }
32
-
33
- if (variant === "duration") {
34
- return {
35
- duration: formatTime(duration)
36
- }
37
- }
38
-
39
- if (variant === "current") {
40
- return {
41
- current: formatTime(currentTime)
42
- }
43
- }
44
-
45
- return {
46
- current: formatTime(currentTime),
47
- duration: formatTime(duration)
48
- }
49
- }, [variant, currentTime, duration])
50
-
51
- const timeProps = {
52
- "data-slot": "media-player-time",
53
- "data-variant": variant,
54
- dir: context.dir,
55
- className: cn("text-sm text-foreground/80 tabular-nums", className),
56
- ...props
57
- }
58
-
59
- if (variant !== "current-duration") {
60
- const content = times[variant as keyof typeof times]
61
-
62
- if (asChild) {
63
- const child = React.Children.only(children) as React.ReactElement
64
- return React.cloneElement(child, timeProps as any, content)
65
- }
66
-
67
- return <time {...timeProps}>{content}</time>
68
- }
69
-
70
- const content = (
71
- <>
72
- <time>{times.current}</time>
73
- <span className="text-foreground/60">/</span>
74
- <time>{times.duration}</time>
75
- </>
76
- )
77
-
78
- if (asChild) {
79
- const child = React.Children.only(children) as React.ReactElement
80
- return React.cloneElement(
81
- child,
82
- {
83
- ...timeProps,
84
- className: cn("flex items-center gap-1 text-foreground/80 text-sm", className)
85
- } as any,
86
- content
87
- )
88
- }
89
-
90
- return (
91
- <div
92
- {...timeProps}
93
- className={cn("flex items-center gap-1 text-foreground/80 text-sm", className)}>
94
- {content}
95
- </div>
96
- )
97
- }
98
-
99
- MediaPlayerTime.displayName = "MediaPlayerTime"
@@ -1,58 +0,0 @@
1
- "use client"
2
-
3
- import { Tooltip, TooltipContent, TooltipTrigger } from "@rp/ui/components/tooltip"
4
- import React from "react"
5
- import { useMediaContext } from "../context/media-context"
6
-
7
- export interface MediaPlayerTooltipProps {
8
- children: React.ReactNode
9
- tooltip?: string
10
- shortcut?: string | string[]
11
- delayDuration?: number
12
- sideOffset?: number
13
- }
14
-
15
- export function MediaPlayerTooltip({
16
- children,
17
- tooltip,
18
- shortcut,
19
- delayDuration,
20
- sideOffset
21
- }: MediaPlayerTooltipProps) {
22
- const context = useMediaContext()
23
-
24
- if (context.withoutTooltip || !tooltip) {
25
- return <>{children}</>
26
- }
27
-
28
- const tooltipDelayDuration = delayDuration ?? context.tooltipDelayDuration
29
- const tooltipSideOffset = sideOffset ?? context.tooltipSideOffset
30
-
31
- return (
32
- <Tooltip delayDuration={tooltipDelayDuration}>
33
- <TooltipTrigger asChild>{children}</TooltipTrigger>
34
- <TooltipContent sideOffset={tooltipSideOffset} className="flex items-center gap-2 text-sm">
35
- <span>{tooltip}</span>
36
- {shortcut && (
37
- <div className="flex items-center gap-1">
38
- {Array.isArray(shortcut) ? (
39
- shortcut.map((key, index) => (
40
- <kbd
41
- key={index}
42
- className="pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-medium font-mono text-[10px] text-muted-foreground opacity-100">
43
- {key}
44
- </kbd>
45
- ))
46
- ) : (
47
- <kbd className="pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-medium font-mono text-[10px] text-muted-foreground opacity-100">
48
- {shortcut}
49
- </kbd>
50
- )}
51
- </div>
52
- )}
53
- </TooltipContent>
54
- </Tooltip>
55
- )
56
- }
57
-
58
- MediaPlayerTooltip.displayName = "MediaPlayerTooltip"
@@ -1,54 +0,0 @@
1
- "use client"
2
-
3
- import React from "react"
4
- import { useMediaContext } from "../context/media-context"
5
-
6
- // Utility function to compose refs
7
- function composeRefs<T>(...refs: Array<React.Ref<T> | undefined>) {
8
- return (node: T | null) => {
9
- refs.forEach((ref) => {
10
- if (typeof ref === "function") {
11
- ref(node)
12
- } else if (ref) {
13
- ;(ref as React.MutableRefObject<T | null>).current = node
14
- }
15
- })
16
- }
17
- }
18
-
19
- export interface MediaPlayerVideoProps extends React.VideoHTMLAttributes<HTMLVideoElement> {
20
- asChild?: boolean
21
- }
22
-
23
- export function MediaPlayerVideo({
24
- asChild = false,
25
- className,
26
- children,
27
- ...props
28
- }: MediaPlayerVideoProps) {
29
- const context = useMediaContext()
30
-
31
- // Create a ref that will be composed with the context mediaRef when mounted
32
- const combinedRef = React.useMemo(
33
- () => composeRefs(context.mediaRef),
34
- [context.mediaRef]
35
- )
36
-
37
- if (asChild) {
38
- // When asChild is true, clone the child element and add our props
39
- const child = React.Children.only(children) as React.ReactElement
40
- return React.cloneElement(child, {
41
- ...props,
42
- ref: combinedRef,
43
- "data-slot": "media-player-video"
44
- } as any)
45
- }
46
-
47
- return (
48
- <video ref={combinedRef} data-slot="media-player-video" className={className} {...props}>
49
- {children}
50
- </video>
51
- )
52
- }
53
-
54
- MediaPlayerVideo.displayName = "MediaPlayerVideo"
@@ -1,155 +0,0 @@
1
- "use client"
2
-
3
- import { Button } from "@rp/ui/components/button"
4
- import { Slider } from "@rp/ui/components/slider"
5
- import { Volume1Icon, Volume2Icon, VolumeXIcon } from "lucide-react"
6
- import React from "react"
7
- import {
8
- MediaActionTypes,
9
- useMediaContext,
10
- useMediaDispatch,
11
- useMediaSelector
12
- } from "../context/media-context"
13
- import { cn } from "../lib/utils"
14
- import { MediaPlayerTooltip } from "./media-player-tooltip"
15
-
16
- export interface MediaPlayerVolumeProps {
17
- className?: string
18
- disabled?: boolean
19
- asChild?: boolean
20
- expandable?: boolean
21
- children?: React.ReactNode
22
- }
23
-
24
- export function MediaPlayerVolume({
25
- className,
26
- disabled = false,
27
- asChild = false,
28
- expandable = true,
29
- children,
30
- ...props
31
- }: MediaPlayerVolumeProps) {
32
- const context = useMediaContext()
33
- const dispatch = useMediaDispatch()
34
-
35
- const volume = useMediaSelector((state) => state.volume)
36
- const isMuted = useMediaSelector((state) => state.isMuted)
37
- const isDisabled = disabled || useMediaSelector((state) => state.error !== null)
38
-
39
- // Determine volume level for icon
40
- const volumeLevel = React.useMemo(() => {
41
- if (isMuted || volume === 0) return 0
42
- if (volume < 0.5) return 1
43
- return 2
44
- }, [volume, isMuted])
45
-
46
- const handleMuteToggle = React.useCallback(() => {
47
- dispatch({
48
- type: MediaActionTypes.TOGGLE_MUTE
49
- })
50
- }, [dispatch])
51
-
52
- const handleVolumeChange = React.useCallback(
53
- (values: number[]) => {
54
- const newVolume = values[0]
55
- dispatch({
56
- type: MediaActionTypes.SET_VOLUME,
57
- detail: newVolume
58
- })
59
- },
60
- [dispatch]
61
- )
62
-
63
- const handleVolumeCommit = React.useCallback(
64
- (values: number[]) => {
65
- const newVolume = values[0]
66
- dispatch({
67
- type: MediaActionTypes.SET_VOLUME,
68
- detail: newVolume
69
- })
70
- },
71
- [dispatch]
72
- )
73
-
74
- const VolumeIcon = volumeLevel === 0 ? VolumeXIcon : volumeLevel === 1 ? Volume1Icon : Volume2Icon
75
-
76
- const containerProps = {
77
- "data-disabled": isDisabled ? "" : undefined,
78
- "data-slot": "media-player-volume",
79
- className: cn(
80
- "group flex items-center",
81
- expandable ? "gap-2 transition-all duration-200 hover:gap-3" : "gap-2",
82
- className
83
- ),
84
- ...props
85
- }
86
-
87
- const buttonProps = {
88
- type: "button" as const,
89
- "aria-controls": context.mediaId,
90
- "aria-label": isMuted ? "Unmute" : "Mute",
91
- "aria-pressed": isMuted,
92
- "data-slot": "media-player-volume-button",
93
- "data-state": isMuted ? "muted" : "unmuted",
94
- variant: "ghost" as const,
95
- size: "icon" as const,
96
- className: "size-8 shrink-0",
97
- disabled: isDisabled,
98
- onClick: handleMuteToggle
99
- }
100
-
101
- const sliderProps = {
102
- "aria-controls": context.mediaId,
103
- "aria-valuetext": `Volume ${Math.round(volume * 100)}%`,
104
- "data-slot": "media-player-volume-slider",
105
- min: 0,
106
- max: 1,
107
- step: 0.01,
108
- value: [isMuted ? 0 : volume],
109
- onValueChange: handleVolumeChange,
110
- onValueCommit: handleVolumeCommit,
111
- disabled: isDisabled,
112
- className: cn(
113
- "relative flex touch-none select-none items-center",
114
- expandable
115
- ? "w-0 opacity-0 transition-all duration-200 group-hover:w-20 group-hover:opacity-100"
116
- : "w-20",
117
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
118
- )
119
- }
120
-
121
- const content = (
122
- <div {...containerProps}>
123
- <MediaPlayerTooltip tooltip={isMuted ? "Unmute" : "Mute"} shortcut="M">
124
- <Button {...buttonProps}>
125
- <VolumeIcon className="size-4" />
126
- </Button>
127
- </MediaPlayerTooltip>
128
-
129
- <Slider {...sliderProps}>
130
- <div className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
131
- <div
132
- className="h-full bg-primary transition-all"
133
- style={{ width: `${(isMuted ? 0 : volume) * 100}%` }}
134
- />
135
- </div>
136
- <div
137
- className="block h-4 w-4 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
138
- style={{
139
- transform: `translateX(-50%)`,
140
- left: `${(isMuted ? 0 : volume) * 100}%`
141
- }}
142
- />
143
- </Slider>
144
- </div>
145
- )
146
-
147
- if (asChild) {
148
- const child = React.Children.only(children) as React.ReactElement
149
- return React.cloneElement(child, containerProps as any, content)
150
- }
151
-
152
- return content
153
- }
154
-
155
- MediaPlayerVolume.displayName = "MediaPlayerVolume"