@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.
- package/README.md +91 -73
- package/dist/components/icons/index.d.ts +36 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts +13 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts +4 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts +30 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-video.d.ts +16 -0
- package/dist/components/variants/gradient/gradient-video.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +786 -6271
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +3 -0
- package/package.json +110 -108
- package/src/components/variants/gradient/gradient-audio.tsx +47 -0
- package/src/components/variants/gradient/gradient-controls.tsx +254 -0
- package/src/components/variants/gradient/gradient-glyphs.test.tsx +69 -0
- package/src/components/variants/gradient/gradient-glyphs.tsx +129 -0
- package/src/components/variants/gradient/gradient-skin.css +211 -0
- package/src/components/variants/gradient/gradient-video.tsx +70 -0
- package/src/index.ts +5 -198
- package/src/test/accessibility-utils.ts +0 -59
- package/dist/context/media.js +0 -2
- package/dist/context/media.js.map +0 -1
- package/dist/context/media.mjs +0 -15
- package/dist/context/media.mjs.map +0 -1
- package/dist/context/store.js +0 -2
- package/dist/context/store.js.map +0 -1
- package/dist/context/store.mjs +0 -5
- package/dist/context/store.mjs.map +0 -1
- package/dist/context-BYwDoSRX.js +0 -1172
- package/dist/context-BYwDoSRX.js.map +0 -1
- package/dist/context-eNS62_ac.cjs +0 -23
- package/dist/context-eNS62_ac.cjs.map +0 -1
- package/dist/core-events-B1iM2F46.cjs +0 -2
- package/dist/core-events-B1iM2F46.cjs.map +0 -1
- package/dist/core-events-DunPHKRE.js +0 -484
- package/dist/core-events-DunPHKRE.js.map +0 -1
- package/dist/core-plugins-By-4-kGs.cjs +0 -2
- package/dist/core-plugins-By-4-kGs.cjs.map +0 -1
- package/dist/core-plugins-DSBWcTuX.js +0 -821
- package/dist/core-plugins-DSBWcTuX.js.map +0 -1
- package/dist/core.js +0 -37
- package/dist/core.js.map +0 -1
- package/dist/core.mjs +0 -1233
- package/dist/core.mjs.map +0 -1
- package/dist/enhanced-components-B_l3cist.js +0 -1142
- package/dist/enhanced-components-B_l3cist.js.map +0 -1
- package/dist/enhanced-components-BspFs9OO.cjs +0 -2
- package/dist/enhanced-components-BspFs9OO.cjs.map +0 -1
- package/dist/hooks-BXwI8QG6.cjs +0 -4
- package/dist/hooks-BXwI8QG6.cjs.map +0 -1
- package/dist/hooks-Bpi-jDiO.js +0 -1816
- package/dist/hooks-Bpi-jDiO.js.map +0 -1
- package/dist/minimal-components-C4z900Ro.js +0 -1926
- package/dist/minimal-components-C4z900Ro.js.map +0 -1
- package/dist/minimal-components-v4qBp6jv.cjs +0 -2
- package/dist/minimal-components-v4qBp6jv.cjs.map +0 -1
- package/dist/minimal-components.css +0 -1
- package/dist/mona-loading.gif +0 -0
- package/dist/performance-monitor-C5k6FDXw.js +0 -301
- package/dist/performance-monitor-C5k6FDXw.js.map +0 -1
- package/dist/performance-monitor-lJmuUjQQ.cjs +0 -2
- package/dist/performance-monitor-lJmuUjQQ.cjs.map +0 -1
- package/dist/utils-CFOue_9K.cjs +0 -9
- package/dist/utils-CFOue_9K.cjs.map +0 -1
- package/dist/utils-Dzpl2ArK.js +0 -2844
- package/dist/utils-Dzpl2ArK.js.map +0 -1
- package/dist/utils.js +0 -2
- package/dist/utils.js.map +0 -1
- package/dist/utils.mjs +0 -11
- package/dist/utils.mjs.map +0 -1
- package/src/adapters/videojs-adapter.tsx +0 -470
- package/src/assets/mona-loading.gif +0 -0
- package/src/components/AnimateLoading.tsx +0 -107
- package/src/components/LoadingState.tsx +0 -239
- package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
- package/src/components/__tests__/media-player-react19.test.tsx +0 -457
- package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
- package/src/components/audio-player.tsx +0 -85
- package/src/components/basic/index.ts +0 -37
- package/src/components/enhanced/advanced-features.tsx +0 -311
- package/src/components/enhanced/debug-panel.tsx +0 -448
- package/src/components/enhanced/enhanced-controls.tsx +0 -597
- package/src/components/enhanced/enhanced-media-player.tsx +0 -566
- package/src/components/enhanced/error-handling.tsx +0 -338
- package/src/components/enhanced/index.ts +0 -39
- package/src/components/enhanced/media-player-enhanced.tsx +0 -383
- package/src/components/examples/basic-video-player.tsx +0 -50
- package/src/components/examples/custom-controls-example.tsx +0 -63
- package/src/components/examples/enhanced-controls-example.tsx +0 -100
- package/src/components/examples/enhanced-media-player-example.tsx +0 -302
- package/src/components/examples/loading-states-demo.tsx +0 -142
- package/src/components/examples/react-19-demo.tsx +0 -353
- package/src/components/examples/volume-orientation-demo.tsx +0 -106
- package/src/components/icon-demo.tsx +0 -196
- package/src/components/legacy.tsx +0 -87
- package/src/components/media-metadata-display.tsx +0 -99
- package/src/components/media-player-audio.tsx +0 -39
- package/src/components/media-player-controls.tsx +0 -223
- package/src/components/media-player-error.tsx +0 -163
- package/src/components/media-player-fullscreen.tsx +0 -109
- package/src/components/media-player-hls.tsx +0 -111
- package/src/components/media-player-loading.tsx +0 -76
- package/src/components/media-player-play.tsx +0 -75
- package/src/components/media-player-root.tsx +0 -338
- package/src/components/media-player-seek.tsx +0 -168
- package/src/components/media-player-time.tsx +0 -99
- package/src/components/media-player-tooltip.tsx +0 -58
- package/src/components/media-player-video.tsx +0 -54
- package/src/components/media-player-volume.tsx +0 -155
- package/src/components/media-player.tsx +0 -292
- package/src/components/media-suspense.tsx +0 -344
- package/src/components/player-settings-form.tsx +0 -158
- package/src/components/react-player-wrapper.tsx +0 -651
- package/src/components/simple-video-player.tsx +0 -62
- package/src/components/ui/blur-poster.tsx +0 -93
- package/src/components/ui/empty-state.tsx +0 -91
- package/src/components/ui/enhanced-seek-bar.tsx +0 -254
- package/src/components/ui/error-state.tsx +0 -124
- package/src/components/ui/fullscreen-button.tsx +0 -81
- package/src/components/ui/loading-skeleton.tsx +0 -107
- package/src/components/ui/media-resource-preloader.tsx +0 -458
- package/src/components/ui/offline-message.tsx +0 -98
- package/src/components/ui/play-button.tsx +0 -99
- package/src/components/ui/seek-bar.tsx +0 -191
- package/src/components/ui/time-display.tsx +0 -61
- package/src/components/ui/volume-control.tsx +0 -190
- package/src/components/unified/base-media-player.tsx +0 -252
- package/src/components/unified/media-player.tsx +0 -75
- package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
- package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
- package/src/components/variants/minimal/MinimalControls.tsx +0 -124
- package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
- package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
- package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
- package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
- package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
- package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
- package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
- package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
- package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
- package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
- package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
- package/src/components/variants/minimal/components/RightControls.tsx +0 -164
- package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
- package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
- package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
- package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
- package/src/components/variants/minimal/components/VideoElement.tsx +0 -33
- package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
- package/src/components/variants/minimal/index.ts +0 -23
- package/src/components/video-player.tsx +0 -100
- package/src/context/__tests__/media-store.test.ts +0 -509
- package/src/context/error-handling.ts +0 -398
- package/src/context/media-context.tsx +0 -254
- package/src/context/media-provider.tsx +0 -264
- package/src/context/media-store.ts +0 -387
- package/src/context/persistence.ts +0 -462
- package/src/core/events/event-system.ts +0 -448
- package/src/core/events/hooks.ts +0 -325
- package/src/core/events/index.ts +0 -22
- package/src/core/events/middleware.ts +0 -286
- package/src/core/index.ts +0 -22
- package/src/core/optimization/bundle-optimizer.tsx +0 -312
- package/src/core/performance/cicd.ts +0 -98
- package/src/core/performance/index.ts +0 -38
- package/src/core/performance/media-loading-optimizer.ts +0 -544
- package/src/core/performance/performance-budgets.ts +0 -437
- package/src/core/performance/performance-monitor.tsx +0 -488
- package/src/core/performance/performance-testing.ts +0 -461
- package/src/core/plugins/__tests__/registry.test.ts +0 -595
- package/src/core/plugins/base-plugin.ts +0 -225
- package/src/core/plugins/enhanced-plugin-system.ts +0 -435
- package/src/core/plugins/examples/analytics-plugin.ts +0 -241
- package/src/core/plugins/index.ts +0 -39
- package/src/core/plugins/registry.ts +0 -546
- package/src/core/plugins/types.ts +0 -169
- package/src/core/plugins/utils.ts +0 -317
- package/src/core/progressive-loading.tsx +0 -331
- package/src/core/providers/enhanced-hls-provider.ts +0 -307
- package/src/core/providers/lazy-provider.tsx +0 -14
- package/src/core/providers/service-provider.tsx +0 -164
- package/src/core/utils.tsx +0 -34
- package/src/features/media-session/media-session-manager.ts +0 -411
- package/src/features/picture-in-picture/pip-manager.ts +0 -428
- package/src/features/playlist/playlist-manager.ts +0 -626
- package/src/features/subtitles/subtitle-manager.ts +0 -435
- package/src/features/subtitles/subtitle-parser.ts +0 -284
- package/src/features/thumbnails/thumbnail-generator.ts +0 -528
- package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
- package/src/hooks/__tests__/use-media-player.test.ts +0 -712
- package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
- package/src/hooks/accessibility/index.ts +0 -27
- package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
- package/src/hooks/accessibility/use-focus-management.ts +0 -183
- package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
- package/src/hooks/accessibility/use-screen-reader.ts +0 -212
- package/src/hooks/core/index.ts +0 -47
- package/src/hooks/legacy.ts +0 -21
- package/src/hooks/use-buffer-health.ts +0 -218
- package/src/hooks/use-enhanced-media-player.ts +0 -575
- package/src/hooks/use-focus-trap.tsx +0 -162
- package/src/hooks/use-intelligent-preloading.ts +0 -387
- package/src/hooks/use-keyboard-controls.ts +0 -115
- package/src/hooks/use-keyboard-shortcuts.ts +0 -255
- package/src/hooks/use-media-actions.ts +0 -184
- package/src/hooks/use-media-metadata.ts +0 -91
- package/src/hooks/use-media-optimistic.ts +0 -264
- package/src/hooks/use-media-player.ts +0 -343
- package/src/hooks/use-media-state.ts +0 -194
- package/src/hooks/use-memory-optimization.ts +0 -360
- package/src/hooks/use-network-status.ts +0 -124
- package/src/hooks/use-optimistic-controls.ts +0 -95
- package/src/hooks/use-optimized-media.ts +0 -283
- package/src/hooks/use-smart-preload.ts +0 -229
- package/src/hooks/use-touch-gestures.ts +0 -461
- package/src/hooks/useEnhancedSubtitles.ts +0 -258
- package/src/hooks/useKeyboardShortcuts.ts +0 -106
- package/src/hooks/useMediaControls.ts +0 -52
- package/src/hooks/useScreenshot.ts +0 -61
- package/src/hooks/useSubtitles.ts +0 -91
- package/src/hooks/useVideoPlayer.ts +0 -278
- package/src/icons/components/FullscreenIcon.tsx +0 -36
- package/src/icons/components/SettingsIcon.tsx +0 -37
- package/src/icons/components/animated/LoadingIcon.tsx +0 -27
- package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
- package/src/icons/components/media/PauseIcon.tsx +0 -38
- package/src/icons/components/media/PlayIcon.tsx +0 -37
- package/src/icons/components/volume/VolumeIcon.tsx +0 -38
- package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
- package/src/icons/index.ts +0 -56
- package/src/icons/provider.tsx +0 -58
- package/src/icons/types.ts +0 -60
- package/src/index-enhanced.ts +0 -35
- package/src/index-legacy.ts +0 -324
- package/src/index.css +0 -102
- package/src/lib/__tests__/async-utils.test.ts +0 -291
- package/src/lib/async-utils.ts +0 -194
- package/src/lib/deprecation.ts +0 -51
- package/src/lib/format-time.ts +0 -37
- package/src/lib/index.ts +0 -4
- package/src/lib/utils.ts +0 -6
- package/src/styles/globals.css +0 -462
- package/src/styles/minimal-player.css +0 -621
- package/src/styles/pixel-art.css +0 -41
- package/src/styles/videojs.css +0 -100
- package/src/types/events.ts +0 -47
- package/src/types/formats.ts +0 -79
- package/src/types/index.ts +0 -203
- package/src/types/videojs-plugins.d.ts +0 -14
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { Pause, Play } from "lucide-react"
|
|
4
|
-
import { forwardRef, memo, useMemo } from "react"
|
|
5
|
-
import { cn } from "../../lib/utils"
|
|
6
|
-
import type { PlayButtonProps } from "../../types/index"
|
|
7
|
-
|
|
8
|
-
const sizeVariants = {
|
|
9
|
-
sm: { button: "size-8", icon: 16 },
|
|
10
|
-
md: { button: "size-10", icon: 20 },
|
|
11
|
-
lg: { button: "size-12", icon: 24 },
|
|
12
|
-
xl: { button: "size-16", icon: 32 }
|
|
13
|
-
} as const
|
|
14
|
-
|
|
15
|
-
const PlayButtonComponent = memo(
|
|
16
|
-
forwardRef<HTMLButtonElement, PlayButtonProps>(
|
|
17
|
-
({ isPlaying, onToggle, disabled = false, size = "lg", className }, ref) => {
|
|
18
|
-
const sizeConfig = useMemo(() => sizeVariants[size] || sizeVariants.lg, [size])
|
|
19
|
-
|
|
20
|
-
const ariaLabel = useMemo(() => (isPlaying ? "Pause media" : "Play media"), [isPlaying])
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<button
|
|
24
|
-
ref={ref}
|
|
25
|
-
type="button"
|
|
26
|
-
onClick={onToggle}
|
|
27
|
-
disabled={disabled}
|
|
28
|
-
data-state={isPlaying ? "playing" : "paused"}
|
|
29
|
-
className={cn(
|
|
30
|
-
"group relative inline-flex items-center justify-center",
|
|
31
|
-
"glass-strong media-control rounded-full contain-layout",
|
|
32
|
-
"focus-ring touch-manipulation",
|
|
33
|
-
sizeConfig.button,
|
|
34
|
-
"text-[color:var(--media-text)] transition-all duration-300",
|
|
35
|
-
"bg-[color:var(--media-control-bg)] backdrop-blur-sm",
|
|
36
|
-
"border border-[color:var(--media-border)]/30",
|
|
37
|
-
"hover:bg-[color:var(--media-control-hover)]",
|
|
38
|
-
"hover:border-[color:var(--media-border)]/50",
|
|
39
|
-
"hover:shadow-[color:var(--media-bg)]/20 hover:shadow-lg",
|
|
40
|
-
"hover:-translate-y-0.5 hover:scale-105",
|
|
41
|
-
"active:bg-[color:var(--media-control-active)]",
|
|
42
|
-
"active:translate-y-0 active:scale-100",
|
|
43
|
-
"focus-visible:ring-2 focus-visible:ring-[color:var(--media-focus)]",
|
|
44
|
-
"focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--media-bg)]",
|
|
45
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
46
|
-
"disabled:hover:translate-y-0 disabled:hover:scale-100",
|
|
47
|
-
"disabled:hover:bg-[color:var(--media-control-bg)]",
|
|
48
|
-
className
|
|
49
|
-
)}
|
|
50
|
-
aria-label={ariaLabel}
|
|
51
|
-
aria-pressed={isPlaying}>
|
|
52
|
-
<div
|
|
53
|
-
className={cn(
|
|
54
|
-
"absolute inset-0 rounded-full opacity-0 transition-opacity duration-300",
|
|
55
|
-
"bg-gradient-to-br from-[color:var(--color-media-play)] to-[color:var(--color-media-pause)]",
|
|
56
|
-
"blur-sm group-hover:opacity-20",
|
|
57
|
-
isPlaying && "opacity-10"
|
|
58
|
-
)}
|
|
59
|
-
/>
|
|
60
|
-
|
|
61
|
-
{isPlaying ? (
|
|
62
|
-
<Pause
|
|
63
|
-
size={sizeConfig.icon}
|
|
64
|
-
className={cn(
|
|
65
|
-
"relative z-10 fill-current transition-all duration-200",
|
|
66
|
-
"text-[color:var(--color-media-pause)]",
|
|
67
|
-
"group-hover:scale-110 group-active:scale-95",
|
|
68
|
-
"drop-shadow-sm"
|
|
69
|
-
)}
|
|
70
|
-
/>
|
|
71
|
-
) : (
|
|
72
|
-
<Play
|
|
73
|
-
size={sizeConfig.icon}
|
|
74
|
-
className={cn(
|
|
75
|
-
"relative z-10 fill-current transition-all duration-200",
|
|
76
|
-
"ml-0.5 text-[color:var(--color-media-play)]",
|
|
77
|
-
"group-hover:scale-110 group-active:scale-95",
|
|
78
|
-
"drop-shadow-sm"
|
|
79
|
-
)}
|
|
80
|
-
/>
|
|
81
|
-
)}
|
|
82
|
-
|
|
83
|
-
<div
|
|
84
|
-
className={cn(
|
|
85
|
-
"absolute inset-0 rounded-full opacity-0",
|
|
86
|
-
"scale-75 bg-[color:var(--media-text)]/10",
|
|
87
|
-
"group-active:scale-100 group-active:opacity-100",
|
|
88
|
-
"transition-all duration-150 ease-out"
|
|
89
|
-
)}
|
|
90
|
-
/>
|
|
91
|
-
</button>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
)
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
PlayButtonComponent.displayName = "PlayButton"
|
|
98
|
-
|
|
99
|
-
export const PlayButton = PlayButtonComponent
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as Slider from "@radix-ui/react-slider"
|
|
4
|
-
import * as Tooltip from "@radix-ui/react-tooltip"
|
|
5
|
-
import { forwardRef, memo, useCallback, useDeferredValue, useMemo, useState } from "react"
|
|
6
|
-
import { formatTime } from "../../lib/format-time"
|
|
7
|
-
import { cn } from "../../lib/utils"
|
|
8
|
-
import type { SeekBarProps } from "../../types/index"
|
|
9
|
-
|
|
10
|
-
const SeekBarComponent = memo(
|
|
11
|
-
forwardRef<HTMLDivElement, SeekBarProps>(
|
|
12
|
-
({ currentTime, duration, buffered, onSeek, size = "sm", className }, ref) => {
|
|
13
|
-
const [isDragging, setIsDragging] = useState(false)
|
|
14
|
-
const [previewTime, setPreviewTime] = useState(0)
|
|
15
|
-
const [isHovering, setIsHovering] = useState(false)
|
|
16
|
-
|
|
17
|
-
// Defer non-critical updates for better performance
|
|
18
|
-
const deferredPreviewTime = useDeferredValue(previewTime)
|
|
19
|
-
|
|
20
|
-
// Memoize size configuration
|
|
21
|
-
const sizeConfig = useMemo(
|
|
22
|
-
() => ({
|
|
23
|
-
trackHeight: size === "sm" ? "h-1" : size === "md" ? "h-1.5" : "h-2",
|
|
24
|
-
thumbSize: size === "sm" ? "size-3" : size === "md" ? "size-4" : "size-5",
|
|
25
|
-
trackHoverHeight: "h-1.5"
|
|
26
|
-
}),
|
|
27
|
-
[size]
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
// Memoize expensive calculations
|
|
31
|
-
const progress = useMemo(
|
|
32
|
-
() => (duration > 0 ? (currentTime / duration) * 100 : 0),
|
|
33
|
-
[currentTime, duration]
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
// Calculate buffered ranges with memoization
|
|
37
|
-
const bufferedRanges = useMemo(() => {
|
|
38
|
-
const ranges = []
|
|
39
|
-
if (buffered && duration > 0) {
|
|
40
|
-
for (let i = 0; i < buffered.length; i++) {
|
|
41
|
-
const start = (buffered.start(i) / duration) * 100
|
|
42
|
-
const end = (buffered.end(i) / duration) * 100
|
|
43
|
-
ranges.push({ start, end })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return ranges
|
|
47
|
-
}, [buffered, duration])
|
|
48
|
-
|
|
49
|
-
// Memoized event handlers
|
|
50
|
-
const handleValueChange = useCallback(
|
|
51
|
-
([value]: number[]) => {
|
|
52
|
-
const time = ((value ?? 0) / 100) * duration
|
|
53
|
-
setPreviewTime(time)
|
|
54
|
-
if (isDragging) {
|
|
55
|
-
onSeek(time)
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
[duration, isDragging, onSeek]
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
const handleValueCommit = useCallback(
|
|
62
|
-
([value]: number[]) => {
|
|
63
|
-
const time = ((value ?? 0) / 100) * duration
|
|
64
|
-
onSeek(time)
|
|
65
|
-
setIsDragging(false)
|
|
66
|
-
},
|
|
67
|
-
[duration, onSeek]
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
const handlePointerDown = useCallback(() => {
|
|
71
|
-
setIsDragging(true)
|
|
72
|
-
}, [])
|
|
73
|
-
|
|
74
|
-
const handleMouseEnter = useCallback(() => setIsHovering(true), [])
|
|
75
|
-
const handleMouseLeave = useCallback(() => setIsHovering(false), [])
|
|
76
|
-
|
|
77
|
-
const formattedTime = useMemo(() => formatTime(currentTime), [currentTime])
|
|
78
|
-
const formattedDuration = useMemo(() => formatTime(duration), [duration])
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<div
|
|
82
|
-
ref={ref}
|
|
83
|
-
className={cn(
|
|
84
|
-
"media-container relative w-full text-[color:var(--media-text)]",
|
|
85
|
-
"touch-manipulation contain-layout",
|
|
86
|
-
className
|
|
87
|
-
)}
|
|
88
|
-
onMouseEnter={handleMouseEnter}
|
|
89
|
-
onMouseLeave={handleMouseLeave}
|
|
90
|
-
role="group"
|
|
91
|
-
aria-label="Seek bar">
|
|
92
|
-
<Tooltip.Provider>
|
|
93
|
-
<Tooltip.Root>
|
|
94
|
-
<Tooltip.Trigger asChild>
|
|
95
|
-
<div className="relative animate-enter">
|
|
96
|
-
<Slider.Root
|
|
97
|
-
className={cn(
|
|
98
|
-
"group relative flex w-full touch-none select-none items-center",
|
|
99
|
-
"focus-ring cursor-pointer",
|
|
100
|
-
sizeConfig.trackHeight
|
|
101
|
-
)}
|
|
102
|
-
value={[progress]}
|
|
103
|
-
max={100}
|
|
104
|
-
step={0.1}
|
|
105
|
-
onValueChange={handleValueChange}
|
|
106
|
-
onValueCommit={handleValueCommit}
|
|
107
|
-
onPointerDown={handlePointerDown}
|
|
108
|
-
aria-label="Seek to position"
|
|
109
|
-
aria-valuemin={0}
|
|
110
|
-
aria-valuemax={100}
|
|
111
|
-
aria-valuenow={Math.round(progress)}
|
|
112
|
-
aria-valuetext={`${formattedTime} of ${formattedDuration}`}
|
|
113
|
-
aria-orientation="horizontal">
|
|
114
|
-
<Slider.Track
|
|
115
|
-
className={cn(
|
|
116
|
-
"relative grow overflow-hidden rounded-full",
|
|
117
|
-
"bg-[color:var(--media-control-bg)]/40 backdrop-blur-sm",
|
|
118
|
-
"border border-[color:var(--media-border)]/20",
|
|
119
|
-
"shadow-inner transition-all duration-300 ease-out",
|
|
120
|
-
sizeConfig.trackHoverHeight,
|
|
121
|
-
"group-hover:bg-[color:var(--media-control-bg)]/60",
|
|
122
|
-
"group-hover:border-[color:var(--media-border)]/40"
|
|
123
|
-
)}>
|
|
124
|
-
{bufferedRanges.map((range, index) => (
|
|
125
|
-
<div
|
|
126
|
-
key={index}
|
|
127
|
-
className={cn(
|
|
128
|
-
"absolute h-full rounded-full transition-all duration-500",
|
|
129
|
-
"bg-[color:var(--color-media-buffered)] shadow-inner",
|
|
130
|
-
"opacity-60 group-hover:opacity-80"
|
|
131
|
-
)}
|
|
132
|
-
style={{
|
|
133
|
-
left: `${range.start}%`,
|
|
134
|
-
width: `${range.end - range.start}%`
|
|
135
|
-
}}
|
|
136
|
-
/>
|
|
137
|
-
))}
|
|
138
|
-
|
|
139
|
-
<Slider.Range
|
|
140
|
-
className={cn(
|
|
141
|
-
"absolute h-full rounded-full transition-all duration-300",
|
|
142
|
-
"bg-gradient-to-r from-[color:var(--color-media-progress)] to-[color:var(--color-brand-accent)]",
|
|
143
|
-
"shadow-[color:var(--color-brand-primary)]/20 shadow-lg",
|
|
144
|
-
"group-hover:shadow-xl"
|
|
145
|
-
)}
|
|
146
|
-
/>
|
|
147
|
-
</Slider.Track>
|
|
148
|
-
|
|
149
|
-
<Slider.Thumb
|
|
150
|
-
className={cn(
|
|
151
|
-
"block rounded-full border-white/20 bg-white",
|
|
152
|
-
"shadow-lg hover:shadow-xl",
|
|
153
|
-
sizeConfig.thumbSize,
|
|
154
|
-
"opacity-0 group-hover:opacity-100",
|
|
155
|
-
"hover:scale-110 hover:bg-white/95 active:scale-95",
|
|
156
|
-
"focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-white/50",
|
|
157
|
-
"focus:ring-offset-2 focus:ring-offset-black/20",
|
|
158
|
-
"transition-all duration-300 ease-out",
|
|
159
|
-
isDragging && "opacity-100"
|
|
160
|
-
)}
|
|
161
|
-
aria-label="Seek slider"
|
|
162
|
-
aria-valuetext={`${formattedTime} of ${formattedDuration}`}
|
|
163
|
-
/>
|
|
164
|
-
</Slider.Root>
|
|
165
|
-
</div>
|
|
166
|
-
</Tooltip.Trigger>
|
|
167
|
-
|
|
168
|
-
{isDragging && (
|
|
169
|
-
<Tooltip.Portal>
|
|
170
|
-
<Tooltip.Content
|
|
171
|
-
className={cn(
|
|
172
|
-
"rounded bg-black/80 px-2 py-1 text-sm text-white",
|
|
173
|
-
"fade-in-0 zoom-in-95 animate-in"
|
|
174
|
-
)}
|
|
175
|
-
sideOffset={10}>
|
|
176
|
-
{formatTime(previewTime)}
|
|
177
|
-
<Tooltip.Arrow className="fill-black/80" />
|
|
178
|
-
</Tooltip.Content>
|
|
179
|
-
</Tooltip.Portal>
|
|
180
|
-
)}
|
|
181
|
-
</Tooltip.Root>
|
|
182
|
-
</Tooltip.Provider>
|
|
183
|
-
</div>
|
|
184
|
-
)
|
|
185
|
-
}
|
|
186
|
-
)
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
SeekBarComponent.displayName = "SeekBar"
|
|
190
|
-
|
|
191
|
-
export const SeekBar = SeekBarComponent
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { forwardRef, memo, useMemo } from "react"
|
|
4
|
-
import { formatTime } from "../../lib/format-time"
|
|
5
|
-
import { cn } from "../../lib/utils"
|
|
6
|
-
import type { TimeDisplayProps } from "../../types/index"
|
|
7
|
-
|
|
8
|
-
const TimeDisplayComponent = memo(
|
|
9
|
-
forwardRef<HTMLDivElement, TimeDisplayProps>(function TimeDisplay(
|
|
10
|
-
{ currentTime, duration, showRemaining = false, size = "sm", className },
|
|
11
|
-
ref
|
|
12
|
-
) {
|
|
13
|
-
const current = useMemo(() => formatTime(currentTime), [currentTime])
|
|
14
|
-
const total = useMemo(() => formatTime(duration), [duration])
|
|
15
|
-
const remaining = useMemo(() => formatTime(duration - currentTime), [duration, currentTime])
|
|
16
|
-
|
|
17
|
-
const sizeClasses: Record<"sm" | "md" | "lg" | "xl", string> = {
|
|
18
|
-
sm: "text-xs",
|
|
19
|
-
md: "text-sm",
|
|
20
|
-
lg: "text-base",
|
|
21
|
-
xl: "text-lg"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const displayTime = useMemo(
|
|
25
|
-
() => (showRemaining ? `-${remaining}` : total),
|
|
26
|
-
[showRemaining, remaining, total]
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div
|
|
31
|
-
ref={ref}
|
|
32
|
-
className={cn(
|
|
33
|
-
"flex items-center font-mono text-white text-xs",
|
|
34
|
-
"rounded-lg backdrop-blur-sm",
|
|
35
|
-
"px-3 py-1.5",
|
|
36
|
-
sizeClasses[size],
|
|
37
|
-
"select-none",
|
|
38
|
-
className
|
|
39
|
-
)}
|
|
40
|
-
role="timer"
|
|
41
|
-
aria-label={`${showRemaining ? "Time remaining" : "Duration"}: ${displayTime}`}
|
|
42
|
-
aria-live="off">
|
|
43
|
-
<span className="tabular-nums" aria-label="Current time">
|
|
44
|
-
{current}
|
|
45
|
-
</span>
|
|
46
|
-
<span className="mx-1 text-white" aria-hidden="true">
|
|
47
|
-
/
|
|
48
|
-
</span>
|
|
49
|
-
<span
|
|
50
|
-
className="tabular-nums"
|
|
51
|
-
aria-label={showRemaining ? "Time remaining" : "Total duration"}>
|
|
52
|
-
{displayTime}
|
|
53
|
-
</span>
|
|
54
|
-
</div>
|
|
55
|
-
)
|
|
56
|
-
})
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
TimeDisplayComponent.displayName = "TimeDisplay"
|
|
60
|
-
|
|
61
|
-
export const TimeDisplay = TimeDisplayComponent
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as Slider from "@radix-ui/react-slider"
|
|
4
|
-
import * as Tooltip from "@radix-ui/react-tooltip"
|
|
5
|
-
import { Volume1, Volume2, VolumeX } from "lucide-react"
|
|
6
|
-
import { forwardRef, memo, useCallback, useMemo } from "react"
|
|
7
|
-
import { cn } from "../../lib/utils"
|
|
8
|
-
import type { VolumeControlProps } from "../../types/index"
|
|
9
|
-
|
|
10
|
-
const sizeConfig = {
|
|
11
|
-
md: {
|
|
12
|
-
button: "size-10",
|
|
13
|
-
icon: 18,
|
|
14
|
-
slider: "h-6",
|
|
15
|
-
thumb: "size-3",
|
|
16
|
-
track: "h-1"
|
|
17
|
-
},
|
|
18
|
-
lg: {
|
|
19
|
-
button: "size-12",
|
|
20
|
-
icon: 22,
|
|
21
|
-
slider: "h-7",
|
|
22
|
-
thumb: "size-4",
|
|
23
|
-
track: "h-1.5"
|
|
24
|
-
},
|
|
25
|
-
xl: {
|
|
26
|
-
button: "size-14",
|
|
27
|
-
icon: 26,
|
|
28
|
-
slider: "h-8",
|
|
29
|
-
thumb: "size-5",
|
|
30
|
-
track: "h-2"
|
|
31
|
-
}
|
|
32
|
-
} as const
|
|
33
|
-
|
|
34
|
-
const VolumeControlComponent = memo(
|
|
35
|
-
forwardRef<HTMLDivElement, VolumeControlProps>(function VolumeControl(
|
|
36
|
-
{ volume, isMuted, onVolumeChange, onToggleMute, size = "lg", className },
|
|
37
|
-
ref
|
|
38
|
-
) {
|
|
39
|
-
const VolumeIcon = useMemo(() => {
|
|
40
|
-
if (isMuted || volume === 0) {
|
|
41
|
-
return VolumeX
|
|
42
|
-
} else if (volume < 0.5) {
|
|
43
|
-
return Volume1
|
|
44
|
-
}
|
|
45
|
-
return Volume2
|
|
46
|
-
}, [isMuted, volume])
|
|
47
|
-
|
|
48
|
-
const buttonSizes: Record<"md" | "lg" | "xl", string> = useMemo(
|
|
49
|
-
() => ({
|
|
50
|
-
md: "h-11 w-11",
|
|
51
|
-
lg: "h-12 w-12",
|
|
52
|
-
xl: "h-14 w-14"
|
|
53
|
-
}),
|
|
54
|
-
[]
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
const iconSizes: Record<"md" | "lg" | "xl", string> = useMemo(
|
|
58
|
-
() => ({
|
|
59
|
-
md: "h-5 w-5",
|
|
60
|
-
lg: "h-6 w-6",
|
|
61
|
-
xl: "h-7 w-7"
|
|
62
|
-
}),
|
|
63
|
-
[]
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
const sliderHeight: Record<"md" | "lg" | "xl", string> = useMemo(
|
|
67
|
-
() => ({
|
|
68
|
-
md: "h-6",
|
|
69
|
-
lg: "h-7",
|
|
70
|
-
xl: "h-8"
|
|
71
|
-
}),
|
|
72
|
-
[]
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
const thumbSize: Record<"md" | "lg" | "xl", string> = useMemo(
|
|
76
|
-
() => ({
|
|
77
|
-
md: "h-4 w-4",
|
|
78
|
-
lg: "h-4 w-4",
|
|
79
|
-
xl: "h-5 w-5"
|
|
80
|
-
}),
|
|
81
|
-
[]
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
const trackHeight: Record<"md" | "lg" | "xl", string> = useMemo(
|
|
85
|
-
() => ({
|
|
86
|
-
md: "h-1.5",
|
|
87
|
-
lg: "h-2",
|
|
88
|
-
xl: "h-2.5"
|
|
89
|
-
}),
|
|
90
|
-
[]
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
const sliderValue = useMemo(() => [isMuted ? 0 : volume], [isMuted, volume])
|
|
94
|
-
const percentageText = useMemo(
|
|
95
|
-
() => Math.round((isMuted ? 0 : volume) * 100),
|
|
96
|
-
[isMuted, volume]
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
const handleToggleClick = useCallback(() => {
|
|
100
|
-
onToggleMute()
|
|
101
|
-
}, [onToggleMute])
|
|
102
|
-
|
|
103
|
-
const handleSliderChange = useCallback(
|
|
104
|
-
([value]: number[]) => {
|
|
105
|
-
onVolumeChange(value ?? 0)
|
|
106
|
-
},
|
|
107
|
-
[onVolumeChange]
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
const ariaLabel = isMuted ? "Unmute" : "Mute"
|
|
111
|
-
const tooltipText = ariaLabel
|
|
112
|
-
|
|
113
|
-
return (
|
|
114
|
-
<div ref={ref} className={cn("flex items-center space-x-3 text-white", className)}>
|
|
115
|
-
<Tooltip.Provider>
|
|
116
|
-
<Tooltip.Root>
|
|
117
|
-
<Tooltip.Trigger asChild>
|
|
118
|
-
<button
|
|
119
|
-
type="button"
|
|
120
|
-
onClick={handleToggleClick}
|
|
121
|
-
className={cn(
|
|
122
|
-
"inline-flex items-center justify-center rounded-lg bg-transparent p-0 text-white transition-all hover:text-cyan-700 active:scale-95",
|
|
123
|
-
"focus:outline-none focus:ring-2 focus:ring-white/50 focus:ring-offset-2 focus:ring-offset-black/20",
|
|
124
|
-
buttonSizes[size]
|
|
125
|
-
)}
|
|
126
|
-
aria-label={ariaLabel}
|
|
127
|
-
aria-pressed={isMuted}>
|
|
128
|
-
<VolumeIcon className={cn(iconSizes[size])} />
|
|
129
|
-
</button>
|
|
130
|
-
</Tooltip.Trigger>
|
|
131
|
-
<Tooltip.Portal>
|
|
132
|
-
<Tooltip.Content
|
|
133
|
-
className={cn(
|
|
134
|
-
"rounded bg-black/80 px-2 py-1 text-sm text-white",
|
|
135
|
-
"fade-in-0 zoom-in-95 animate-in"
|
|
136
|
-
)}
|
|
137
|
-
sideOffset={5}>
|
|
138
|
-
{tooltipText}
|
|
139
|
-
<Tooltip.Arrow className="fill-black/80" />
|
|
140
|
-
</Tooltip.Content>
|
|
141
|
-
</Tooltip.Portal>
|
|
142
|
-
</Tooltip.Root>
|
|
143
|
-
</Tooltip.Provider>
|
|
144
|
-
|
|
145
|
-
<div className="w-32">
|
|
146
|
-
<Slider.Root
|
|
147
|
-
className={cn(
|
|
148
|
-
"group relative flex w-full touch-none select-none items-center",
|
|
149
|
-
sliderHeight[size]
|
|
150
|
-
)}
|
|
151
|
-
value={sliderValue}
|
|
152
|
-
max={1}
|
|
153
|
-
step={0.01}
|
|
154
|
-
onValueChange={handleSliderChange}
|
|
155
|
-
aria-label="Volume"
|
|
156
|
-
aria-valuemin={0}
|
|
157
|
-
aria-valuemax={1}
|
|
158
|
-
aria-valuenow={volume}
|
|
159
|
-
aria-valuetext={`${percentageText} percent`}>
|
|
160
|
-
<Slider.Track
|
|
161
|
-
className={cn(
|
|
162
|
-
"relative grow rounded-full bg-white/20 shadow-inner transition-all duration-300 group-hover:bg-white/30",
|
|
163
|
-
"border border-white/10",
|
|
164
|
-
trackHeight[size]
|
|
165
|
-
)}>
|
|
166
|
-
<Slider.Range className="absolute h-full rounded-full bg-white shadow-sm" />
|
|
167
|
-
</Slider.Track>
|
|
168
|
-
<Slider.Thumb
|
|
169
|
-
className={cn(
|
|
170
|
-
"block rounded-full border-2 border-white/20 bg-white shadow-lg",
|
|
171
|
-
"transition-all duration-300 ease-out hover:scale-110 hover:bg-white/95 active:scale-95",
|
|
172
|
-
"focus:outline-none focus:ring-2 focus:ring-white/50 focus:ring-offset-2 focus:ring-offset-black/20",
|
|
173
|
-
thumbSize[size]
|
|
174
|
-
)}
|
|
175
|
-
aria-label="Volume"
|
|
176
|
-
/>
|
|
177
|
-
</Slider.Root>
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
<span className="w-10 text-right text-sm text-white" aria-hidden="true">
|
|
181
|
-
{percentageText}
|
|
182
|
-
</span>
|
|
183
|
-
</div>
|
|
184
|
-
)
|
|
185
|
-
})
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
VolumeControlComponent.displayName = "VolumeControl"
|
|
189
|
-
|
|
190
|
-
export const VolumeControl = VolumeControlComponent
|