@therealtinhtute/baroiplayer 1.0.0
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/LICENSE +21 -0
- package/README.md +384 -0
- package/dist/context/media.js +2 -0
- package/dist/context/media.js.map +1 -0
- package/dist/context/media.mjs +15 -0
- package/dist/context/media.mjs.map +1 -0
- package/dist/context/store.js +2 -0
- package/dist/context/store.js.map +1 -0
- package/dist/context/store.mjs +5 -0
- package/dist/context/store.mjs.map +1 -0
- package/dist/context-BMteAJDN.js +1140 -0
- package/dist/context-BMteAJDN.js.map +1 -0
- package/dist/context-DCJ_scmO.cjs +23 -0
- package/dist/context-DCJ_scmO.cjs.map +1 -0
- package/dist/core-events-B5W_j8yU.js +480 -0
- package/dist/core-events-B5W_j8yU.js.map +1 -0
- package/dist/core-events-CN0-Vhhq.cjs +2 -0
- package/dist/core-events-CN0-Vhhq.cjs.map +1 -0
- package/dist/core-plugins-Bq9KLany.js +696 -0
- package/dist/core-plugins-Bq9KLany.js.map +1 -0
- package/dist/core-plugins-CPDSHMiQ.cjs +2 -0
- package/dist/core-plugins-CPDSHMiQ.cjs.map +1 -0
- package/dist/core.js +37 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +1217 -0
- package/dist/core.mjs.map +1 -0
- package/dist/enhanced-components-DHv0MFvG.js +1073 -0
- package/dist/enhanced-components-DHv0MFvG.js.map +1 -0
- package/dist/enhanced-components-DTIObgB7.cjs +2 -0
- package/dist/enhanced-components-DTIObgB7.cjs.map +1 -0
- package/dist/hooks-C_r8wexn.cjs +4 -0
- package/dist/hooks-C_r8wexn.cjs.map +1 -0
- package/dist/hooks-Da2wVXlF.js +1630 -0
- package/dist/hooks-Da2wVXlF.js.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.js +112 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6126 -0
- package/dist/index.mjs.map +1 -0
- package/dist/minimal-components-DSq5sQpy.js +2002 -0
- package/dist/minimal-components-DSq5sQpy.js.map +1 -0
- package/dist/minimal-components-DflWiihN.cjs +2 -0
- package/dist/minimal-components-DflWiihN.cjs.map +1 -0
- package/dist/minimal-components.css +1 -0
- package/dist/mona-loading.gif +0 -0
- package/dist/performance-monitor-CUW6f5ll.cjs +2 -0
- package/dist/performance-monitor-CUW6f5ll.cjs.map +1 -0
- package/dist/performance-monitor-rMW1RgV3.js +302 -0
- package/dist/performance-monitor-rMW1RgV3.js.map +1 -0
- package/dist/utils-BnscpYYd.js +2798 -0
- package/dist/utils-BnscpYYd.js.map +1 -0
- package/dist/utils-D_czS_0K.cjs +9 -0
- package/dist/utils-D_czS_0K.cjs.map +1 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +7 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +114 -0
- package/src/adapters/videojs-adapter.tsx +470 -0
- package/src/assets/mona-loading.gif +0 -0
- package/src/components/AnimateLoading.tsx +115 -0
- package/src/components/LoadingState.tsx +248 -0
- package/src/components/accessibility/keyboard-help-overlay.tsx +213 -0
- package/src/components/audio-player.tsx +85 -0
- package/src/components/basic/index.ts +37 -0
- package/src/components/enhanced/advanced-features.tsx +316 -0
- package/src/components/enhanced/debug-panel.tsx +422 -0
- package/src/components/enhanced/enhanced-controls.tsx +600 -0
- package/src/components/enhanced/enhanced-media-player.tsx +509 -0
- package/src/components/enhanced/error-handling.tsx +345 -0
- package/src/components/enhanced/index.ts +39 -0
- package/src/components/enhanced/media-player-enhanced.tsx +349 -0
- package/src/components/examples/basic-video-player.tsx +55 -0
- package/src/components/examples/custom-controls-example.tsx +63 -0
- package/src/components/examples/enhanced-controls-example.tsx +114 -0
- package/src/components/examples/enhanced-media-player-example.tsx +293 -0
- package/src/components/examples/loading-states-demo.tsx +142 -0
- package/src/components/examples/react-19-demo.tsx +381 -0
- package/src/components/examples/volume-orientation-demo.tsx +114 -0
- package/src/components/icon-demo.tsx +209 -0
- package/src/components/icons/index.tsx +166 -0
- package/src/components/icons/svg-icons/ArrowLeftIcon.tsx +18 -0
- package/src/components/icons/svg-icons/ArrowRightIcon.tsx +18 -0
- package/src/components/icons/svg-icons/AudioIcon.tsx +22 -0
- package/src/components/icons/svg-icons/BackwardIcon.tsx +12 -0
- package/src/components/icons/svg-icons/CameraIcon.tsx +19 -0
- package/src/components/icons/svg-icons/CheckIcon.tsx +19 -0
- package/src/components/icons/svg-icons/EnablePiPIcon.tsx +17 -0
- package/src/components/icons/svg-icons/ForwardIcon.tsx +12 -0
- package/src/components/icons/svg-icons/FullscreenEnterIcon.tsx +23 -0
- package/src/components/icons/svg-icons/FullscreenExitIcon.tsx +23 -0
- package/src/components/icons/svg-icons/LoadingIcon.tsx +32 -0
- package/src/components/icons/svg-icons/PauseIcon.tsx +23 -0
- package/src/components/icons/svg-icons/PlayIcon.tsx +21 -0
- package/src/components/icons/svg-icons/PlaybackSpeedIcon.tsx +23 -0
- package/src/components/icons/svg-icons/QualityIcon.tsx +21 -0
- package/src/components/icons/svg-icons/SettingsIcon.tsx +12 -0
- package/src/components/icons/svg-icons/SliderIcon.tsx +21 -0
- package/src/components/icons/svg-icons/SubtitleIcon.tsx +21 -0
- package/src/components/icons/svg-icons/SubtitleOffIcon.tsx +25 -0
- package/src/components/icons/svg-icons/UnPiPIcon.tsx +17 -0
- package/src/components/icons/svg-icons/VolumeMutedIcon.tsx +16 -0
- package/src/components/icons/svg-icons/VolumeOneIcon.tsx +22 -0
- package/src/components/icons/svg-icons/VolumeThreeIcon.tsx +16 -0
- package/src/components/icons/svg-icons/VolumeTwoIcon.tsx +16 -0
- package/src/components/legacy.tsx +93 -0
- package/src/components/media-metadata-display.tsx +100 -0
- package/src/components/media-player-audio.tsx +39 -0
- package/src/components/media-player-controls.tsx +226 -0
- package/src/components/media-player-error.tsx +163 -0
- package/src/components/media-player-fullscreen.tsx +109 -0
- package/src/components/media-player-hls.tsx +111 -0
- package/src/components/media-player-loading.tsx +76 -0
- package/src/components/media-player-play.tsx +75 -0
- package/src/components/media-player-root.tsx +340 -0
- package/src/components/media-player-seek.tsx +168 -0
- package/src/components/media-player-time.tsx +99 -0
- package/src/components/media-player-tooltip.tsx +58 -0
- package/src/components/media-player-video.tsx +39 -0
- package/src/components/media-player-volume.tsx +155 -0
- package/src/components/media-player.tsx +257 -0
- package/src/components/media-suspense.tsx +362 -0
- package/src/components/player-settings-form.tsx +163 -0
- package/src/components/react-player-wrapper.tsx +651 -0
- package/src/components/simple-video-player.tsx +60 -0
- package/src/components/ui/enhanced-seek-bar.tsx +235 -0
- package/src/components/ui/fullscreen-button.tsx +60 -0
- package/src/components/ui/media-resource-preloader.tsx +395 -0
- package/src/components/ui/play-button.tsx +107 -0
- package/src/components/ui/seek-bar.tsx +161 -0
- package/src/components/ui/time-display.tsx +40 -0
- package/src/components/ui/volume-control.tsx +143 -0
- package/src/components/unified/base-media-player.tsx +246 -0
- package/src/components/unified/media-player.tsx +75 -0
- package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +561 -0
- package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +552 -0
- package/src/components/variants/minimal/MinimalControls.tsx +142 -0
- package/src/components/variants/minimal/MinimalLoading.tsx +32 -0
- package/src/components/variants/minimal/MinimalMediaPlayer.tsx +315 -0
- package/src/components/variants/minimal/MinimalOverlay.tsx +64 -0
- package/src/components/variants/minimal/MinimalPlayButton.tsx +65 -0
- package/src/components/variants/minimal/MinimalSeekBar.tsx +150 -0
- package/src/components/variants/minimal/MinimalVolumeControl.tsx +80 -0
- package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +210 -0
- package/src/components/variants/minimal/components/CenterPlayButton.tsx +22 -0
- package/src/components/variants/minimal/components/ControlBar.tsx +146 -0
- package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +361 -0
- package/src/components/variants/minimal/components/PlaybackControls.tsx +51 -0
- package/src/components/variants/minimal/components/RightControls.tsx +173 -0
- package/src/components/variants/minimal/components/SeekBar.tsx +131 -0
- package/src/components/variants/minimal/components/SettingsDropdown.tsx +70 -0
- package/src/components/variants/minimal/components/SubtitleDisplay.tsx +21 -0
- package/src/components/variants/minimal/components/TimeDisplay.tsx +18 -0
- package/src/components/variants/minimal/components/VideoElement.tsx +40 -0
- package/src/components/variants/minimal/components/VolumeControl.tsx +217 -0
- package/src/components/variants/minimal/index.ts +23 -0
- package/src/components/video-player.tsx +100 -0
- package/src/context/error-handling.ts +394 -0
- package/src/context/media-context.tsx +208 -0
- package/src/context/media-provider.tsx +265 -0
- package/src/context/media-store.ts +379 -0
- package/src/context/persistence.ts +453 -0
- package/src/core/events/event-system.ts +442 -0
- package/src/core/events/hooks.ts +302 -0
- package/src/core/events/index.ts +22 -0
- package/src/core/events/middleware.ts +269 -0
- package/src/core/index.ts +22 -0
- package/src/core/optimization/bundle-optimizer.tsx +308 -0
- package/src/core/performance/cicd.ts +96 -0
- package/src/core/performance/index.ts +38 -0
- package/src/core/performance/media-loading-optimizer.ts +538 -0
- package/src/core/performance/performance-budgets.ts +432 -0
- package/src/core/performance/performance-monitor.tsx +476 -0
- package/src/core/performance/performance-testing.ts +459 -0
- package/src/core/plugins/base-plugin.ts +224 -0
- package/src/core/plugins/enhanced-plugin-system.ts +411 -0
- package/src/core/plugins/examples/analytics-plugin.ts +242 -0
- package/src/core/plugins/index.ts +39 -0
- package/src/core/plugins/registry.ts +327 -0
- package/src/core/plugins/types.ts +159 -0
- package/src/core/plugins/utils.ts +316 -0
- package/src/core/progressive-loading.tsx +322 -0
- package/src/core/providers/enhanced-hls-provider.ts +339 -0
- package/src/core/providers/service-provider.tsx +168 -0
- package/src/core/utils.tsx +38 -0
- package/src/features/media-session/media-session-manager.ts +429 -0
- package/src/features/picture-in-picture/pip-manager.ts +429 -0
- package/src/features/playlist/playlist-manager.ts +606 -0
- package/src/features/subtitles/subtitle-manager.ts +441 -0
- package/src/features/subtitles/subtitle-parser.ts +280 -0
- package/src/features/thumbnails/thumbnail-generator.ts +519 -0
- package/src/hooks/accessibility/index.ts +27 -0
- package/src/hooks/accessibility/use-accessibility-preferences.ts +188 -0
- package/src/hooks/accessibility/use-focus-management.ts +176 -0
- package/src/hooks/accessibility/use-keyboard-shortcuts.ts +144 -0
- package/src/hooks/accessibility/use-screen-reader.ts +182 -0
- package/src/hooks/core/index.ts +47 -0
- package/src/hooks/legacy.ts +27 -0
- package/src/hooks/use-enhanced-media-player.ts +468 -0
- package/src/hooks/use-intelligent-preloading.ts +358 -0
- package/src/hooks/use-keyboard-controls.ts +115 -0
- package/src/hooks/use-media-actions.ts +175 -0
- package/src/hooks/use-media-metadata.ts +89 -0
- package/src/hooks/use-media-optimistic.ts +270 -0
- package/src/hooks/use-media-player.ts +312 -0
- package/src/hooks/use-media-state.ts +190 -0
- package/src/hooks/use-memory-optimization.ts +358 -0
- package/src/hooks/use-optimistic-controls.ts +92 -0
- package/src/hooks/use-optimized-media.ts +263 -0
- package/src/hooks/use-touch-gestures.ts +417 -0
- package/src/hooks/useEnhancedSubtitles.ts +258 -0
- package/src/hooks/useKeyboardShortcuts.ts +74 -0
- package/src/hooks/useMediaControls.ts +52 -0
- package/src/hooks/useScreenshot.ts +57 -0
- package/src/hooks/useSubtitles.ts +91 -0
- package/src/hooks/useVideoPlayer.ts +232 -0
- package/src/icons/components/FullscreenIcon.tsx +37 -0
- package/src/icons/components/SettingsIcon.tsx +38 -0
- package/src/icons/components/animated/LoadingIcon.tsx +43 -0
- package/src/icons/components/animated/PlayPauseIcon.tsx +50 -0
- package/src/icons/components/media/PauseIcon.tsx +39 -0
- package/src/icons/components/media/PlayIcon.tsx +38 -0
- package/src/icons/components/volume/VolumeIcon.tsx +39 -0
- package/src/icons/components/volume/VolumeOffIcon.tsx +39 -0
- package/src/icons/index.ts +56 -0
- package/src/icons/provider.tsx +64 -0
- package/src/icons/types.ts +40 -0
- package/src/index-enhanced.ts +35 -0
- package/src/index-legacy.ts +326 -0
- package/src/index.css +102 -0
- package/src/index.ts +216 -0
- package/src/lib/deprecation.ts +51 -0
- package/src/lib/format-time.ts +37 -0
- package/src/lib/index.ts +3 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/globals.css +462 -0
- package/src/styles/minimal-player.css +589 -0
- package/src/styles/pixel-art.css +46 -0
- package/src/styles/videojs.css +100 -0
- package/src/test/setup.ts +79 -0
- package/src/types/events.ts +47 -0
- package/src/types/formats.ts +95 -0
- package/src/types/index.ts +190 -0
- package/src/types/videojs-plugins.d.ts +14 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { memo, useState, useRef } from "react"
|
|
2
|
+
import { cn } from "../../../../lib/utils"
|
|
3
|
+
import type { BufferedRange } from "../../../../hooks/useVideoPlayer"
|
|
4
|
+
|
|
5
|
+
interface SeekBarProps {
|
|
6
|
+
currentTime: number
|
|
7
|
+
duration: number
|
|
8
|
+
bufferedRanges?: BufferedRange[]
|
|
9
|
+
isSeeking?: boolean
|
|
10
|
+
onSeek: (time: number) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const SeekBar = function SeekBar({
|
|
14
|
+
currentTime,
|
|
15
|
+
duration,
|
|
16
|
+
bufferedRanges = [],
|
|
17
|
+
isSeeking = false,
|
|
18
|
+
onSeek
|
|
19
|
+
}: SeekBarProps) {
|
|
20
|
+
const [isHovering, setIsHovering] = useState(false)
|
|
21
|
+
const [hoverPosition, setHoverPosition] = useState(0)
|
|
22
|
+
const [showRipple, setShowRipple] = useState(false)
|
|
23
|
+
const [ripplePosition, setRipplePosition] = useState({ x: 0, y: 0 })
|
|
24
|
+
const seekBarRef = useRef<HTMLDivElement>(null)
|
|
25
|
+
|
|
26
|
+
const progress = duration > 0 ? (currentTime / duration) * 100 : 0
|
|
27
|
+
|
|
28
|
+
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
29
|
+
if (duration === 0) return
|
|
30
|
+
|
|
31
|
+
const rect = e.currentTarget.getBoundingClientRect()
|
|
32
|
+
const position = (e.clientX - rect.left) / rect.width
|
|
33
|
+
const newTime = Math.max(0, Math.min(duration, position * duration))
|
|
34
|
+
|
|
35
|
+
// Add ripple effect
|
|
36
|
+
setRipplePosition({ x: e.clientX - rect.left, y: e.clientY - rect.top })
|
|
37
|
+
setShowRipple(true)
|
|
38
|
+
setTimeout(() => setShowRipple(false), 600)
|
|
39
|
+
|
|
40
|
+
onSeek(newTime)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
44
|
+
if (!seekBarRef.current) return
|
|
45
|
+
const rect = seekBarRef.current.getBoundingClientRect()
|
|
46
|
+
const position = ((e.clientX - rect.left) / rect.width) * 100
|
|
47
|
+
setHoverPosition(Math.max(0, Math.min(100, position)))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const handleMouseEnter = () => setIsHovering(true)
|
|
51
|
+
const handleMouseLeave = () => setIsHovering(false)
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="relative mb-3">
|
|
55
|
+
<div
|
|
56
|
+
ref={seekBarRef}
|
|
57
|
+
className={cn(
|
|
58
|
+
"minimal-seekbar group relative cursor-pointer",
|
|
59
|
+
isSeeking && "minimal-seekbar-seeking"
|
|
60
|
+
)}
|
|
61
|
+
onClick={handleClick}
|
|
62
|
+
onMouseMove={handleMouseMove}
|
|
63
|
+
onMouseEnter={handleMouseEnter}
|
|
64
|
+
onMouseLeave={handleMouseLeave}
|
|
65
|
+
>
|
|
66
|
+
{/* Buffered ranges */}
|
|
67
|
+
{bufferedRanges.map((range, index) => {
|
|
68
|
+
const startPercent = duration > 0 ? (range.start / duration) * 100 : 0
|
|
69
|
+
const widthPercent = duration > 0 ? ((range.end - range.start) / duration) * 100 : 0
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
key={index}
|
|
73
|
+
className="minimal-seekbar-buffered"
|
|
74
|
+
style={{
|
|
75
|
+
left: `${startPercent}%`,
|
|
76
|
+
width: `${widthPercent}%`
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
)
|
|
80
|
+
})}
|
|
81
|
+
|
|
82
|
+
{/* Progress bar */}
|
|
83
|
+
<div
|
|
84
|
+
className={cn(
|
|
85
|
+
"minimal-seekbar-progress",
|
|
86
|
+
isSeeking && "minimal-seekbar-progress-seeking"
|
|
87
|
+
)}
|
|
88
|
+
style={{ width: `${progress}%` }}
|
|
89
|
+
/>
|
|
90
|
+
|
|
91
|
+
{/* Hover indicator */}
|
|
92
|
+
{isHovering && !isSeeking && (
|
|
93
|
+
<div
|
|
94
|
+
className="minimal-seekbar-hover-indicator"
|
|
95
|
+
style={{ left: `${hoverPosition}%` }}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
|
|
99
|
+
{/* Thumb */}
|
|
100
|
+
<div
|
|
101
|
+
className={cn(
|
|
102
|
+
"minimal-seekbar-thumb",
|
|
103
|
+
(isHovering || isSeeking) && "opacity-100",
|
|
104
|
+
isSeeking && "minimal-seekbar-thumb-seeking"
|
|
105
|
+
)}
|
|
106
|
+
style={{ left: `${progress}%` }}
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
{/* Ripple effect */}
|
|
110
|
+
{showRipple && (
|
|
111
|
+
<div
|
|
112
|
+
className="minimal-seekbar-ripple"
|
|
113
|
+
style={{
|
|
114
|
+
left: ripplePosition.x,
|
|
115
|
+
top: ripplePosition.y
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{/* Seeking indicator */}
|
|
122
|
+
{isSeeking && (
|
|
123
|
+
<div className="-top-6 -translate-x-1/2 absolute left-1/2 transform">
|
|
124
|
+
<div className="rounded bg-black/80 px-2 py-1 text-white text-xs backdrop-blur-sm">
|
|
125
|
+
Seeking...
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { memo, useCallback } from "react"
|
|
2
|
+
import { cn } from "../../../../lib/utils"
|
|
3
|
+
import { defaultMinimalIcons } from "../../../icons"
|
|
4
|
+
|
|
5
|
+
interface SettingsDropdownProps {
|
|
6
|
+
showSettings: boolean
|
|
7
|
+
playbackRate: number
|
|
8
|
+
onToggleSettings: () => void
|
|
9
|
+
onChangePlaybackRate: (rate: number) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const SettingsDropdown = function SettingsDropdown({
|
|
13
|
+
showSettings,
|
|
14
|
+
playbackRate,
|
|
15
|
+
onToggleSettings,
|
|
16
|
+
onChangePlaybackRate
|
|
17
|
+
}: SettingsDropdownProps) {
|
|
18
|
+
const playbackRates = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]
|
|
19
|
+
|
|
20
|
+
const handleSettingsClick = useCallback((e: React.MouseEvent) => {
|
|
21
|
+
e.stopPropagation()
|
|
22
|
+
onToggleSettings()
|
|
23
|
+
}, [onToggleSettings])
|
|
24
|
+
|
|
25
|
+
const handleDropdownClick = useCallback((e: React.MouseEvent) => {
|
|
26
|
+
e.stopPropagation()
|
|
27
|
+
}, [])
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="relative" style={{ zIndex: showSettings ? 60 : "auto" }}>
|
|
31
|
+
<button
|
|
32
|
+
className={cn("minimal-btn h-9 w-9", showSettings && "text-cyan-500")}
|
|
33
|
+
onClick={handleSettingsClick}
|
|
34
|
+
aria-label="Settings"
|
|
35
|
+
>
|
|
36
|
+
{defaultMinimalIcons.settings && <defaultMinimalIcons.settings size={18} />}
|
|
37
|
+
</button>
|
|
38
|
+
|
|
39
|
+
{showSettings && (
|
|
40
|
+
<div
|
|
41
|
+
className="absolute right-0 mb-2 min-w-[200px] rounded-lg border border-gray-700 bg-gray-900 py-2 shadow-xl"
|
|
42
|
+
style={{
|
|
43
|
+
bottom: "100%",
|
|
44
|
+
zIndex: 1000
|
|
45
|
+
}}
|
|
46
|
+
onClick={handleDropdownClick}
|
|
47
|
+
>
|
|
48
|
+
<div className="px-3 py-1 text-gray-400 text-xs uppercase tracking-wider">
|
|
49
|
+
Speed
|
|
50
|
+
</div>
|
|
51
|
+
<div className="px-1">
|
|
52
|
+
{playbackRates.map((rate) => (
|
|
53
|
+
<button
|
|
54
|
+
key={rate}
|
|
55
|
+
className={cn(
|
|
56
|
+
"w-full rounded px-3 py-1.5 text-left text-sm transition-colors hover:bg-gray-800",
|
|
57
|
+
"text-white",
|
|
58
|
+
playbackRate === rate && "bg-cyan-700/20 text-cyan-400"
|
|
59
|
+
)}
|
|
60
|
+
onClick={() => onChangePlaybackRate(rate)}
|
|
61
|
+
>
|
|
62
|
+
{rate === 1 ? "Normal" : `${rate}x`}
|
|
63
|
+
</button>
|
|
64
|
+
))}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { memo } from "react"
|
|
2
|
+
|
|
3
|
+
interface SubtitleDisplayProps {
|
|
4
|
+
subtitlesEnabled: boolean
|
|
5
|
+
subtitleText: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const SubtitleDisplay = function SubtitleDisplay({
|
|
9
|
+
subtitlesEnabled,
|
|
10
|
+
subtitleText
|
|
11
|
+
}: SubtitleDisplayProps) {
|
|
12
|
+
if (!subtitlesEnabled || !subtitleText) return null
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="pointer-events-none absolute right-0 bottom-20 left-0 px-4 text-center">
|
|
16
|
+
<div className="inline-block rounded bg-black/75 px-4 py-2 font-medium text-lg text-white">
|
|
17
|
+
{subtitleText}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { memo } from "react"
|
|
2
|
+
import { formatTime } from "../../../../lib/format-time"
|
|
3
|
+
|
|
4
|
+
interface TimeDisplayProps {
|
|
5
|
+
currentTime: number
|
|
6
|
+
duration: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const TimeDisplay = function TimeDisplay({
|
|
10
|
+
currentTime,
|
|
11
|
+
duration
|
|
12
|
+
}: TimeDisplayProps) {
|
|
13
|
+
return (
|
|
14
|
+
<div className="font-mono text-sm text-white">
|
|
15
|
+
{formatTime(currentTime)} / {formatTime(duration)}
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { memo } from "react"
|
|
2
|
+
|
|
3
|
+
interface VideoElementProps {
|
|
4
|
+
videoRef: React.RefObject<HTMLVideoElement | null>
|
|
5
|
+
src: string
|
|
6
|
+
poster?: string
|
|
7
|
+
subtitleSrc?: string
|
|
8
|
+
subtitlesEnabled: boolean
|
|
9
|
+
crossOrigin?: "anonymous" | "use-credentials"
|
|
10
|
+
onTogglePlay: () => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const VideoElement = function VideoElement({
|
|
14
|
+
videoRef,
|
|
15
|
+
src,
|
|
16
|
+
poster,
|
|
17
|
+
subtitleSrc,
|
|
18
|
+
subtitlesEnabled,
|
|
19
|
+
crossOrigin,
|
|
20
|
+
onTogglePlay
|
|
21
|
+
}: VideoElementProps) {
|
|
22
|
+
return (
|
|
23
|
+
<video
|
|
24
|
+
ref={videoRef}
|
|
25
|
+
src={src}
|
|
26
|
+
poster={poster}
|
|
27
|
+
crossOrigin={crossOrigin}
|
|
28
|
+
className="h-full w-full object-contain"
|
|
29
|
+
onClick={onTogglePlay}
|
|
30
|
+
>
|
|
31
|
+
{subtitleSrc && (
|
|
32
|
+
<track
|
|
33
|
+
kind="subtitles"
|
|
34
|
+
src={subtitleSrc}
|
|
35
|
+
default={subtitlesEnabled}
|
|
36
|
+
/>
|
|
37
|
+
)}
|
|
38
|
+
</video>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import React, { memo, useCallback, useRef, useEffect } from "react"
|
|
2
|
+
import { cn } from "../../../../lib/utils"
|
|
3
|
+
import { defaultMinimalIcons } from "../../../icons"
|
|
4
|
+
|
|
5
|
+
interface VolumeControlProps {
|
|
6
|
+
volume: number
|
|
7
|
+
isMuted: boolean
|
|
8
|
+
showVolumeSlider: boolean
|
|
9
|
+
onToggleMute: () => void
|
|
10
|
+
onVolumeChange: (volume: number) => void
|
|
11
|
+
onShowVolumeSlider: (show: boolean) => void
|
|
12
|
+
orientation?: "horizontal" | "vertical"
|
|
13
|
+
className?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const VolumeControl = function VolumeControl({
|
|
17
|
+
volume,
|
|
18
|
+
isMuted,
|
|
19
|
+
showVolumeSlider,
|
|
20
|
+
onToggleMute,
|
|
21
|
+
onVolumeChange,
|
|
22
|
+
onShowVolumeSlider,
|
|
23
|
+
orientation = "horizontal",
|
|
24
|
+
className
|
|
25
|
+
}: VolumeControlProps) {
|
|
26
|
+
const VolumeIcon = defaultMinimalIcons.volume
|
|
27
|
+
const VolumeMutedIcon = defaultMinimalIcons.volumeMuted
|
|
28
|
+
const sliderRefHorizontal = useRef<HTMLDivElement>(null)
|
|
29
|
+
const sliderRefVertical = useRef<HTMLDivElement>(null)
|
|
30
|
+
const isDragging = useRef(false)
|
|
31
|
+
const [isDraggingState, setIsDraggingState] = React.useState(false)
|
|
32
|
+
const [isHovering, setIsHovering] = React.useState(false)
|
|
33
|
+
const hideTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
34
|
+
|
|
35
|
+
const handleVolumeChange = useCallback(
|
|
36
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
37
|
+
const newVolume = parseFloat(e.target.value)
|
|
38
|
+
onVolumeChange(newVolume)
|
|
39
|
+
},
|
|
40
|
+
[onVolumeChange]
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
const handleSliderClick = useCallback(
|
|
44
|
+
(e: React.MouseEvent<HTMLDivElement>, isVertical: boolean) => {
|
|
45
|
+
const sliderRef = isVertical ? sliderRefVertical : sliderRefHorizontal
|
|
46
|
+
if (!sliderRef.current) return
|
|
47
|
+
const rect = sliderRef.current.getBoundingClientRect()
|
|
48
|
+
|
|
49
|
+
let percentage: number
|
|
50
|
+
if (!isVertical) {
|
|
51
|
+
percentage = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width))
|
|
52
|
+
} else {
|
|
53
|
+
percentage = Math.max(0, Math.min(1, 1 - (e.clientY - rect.top) / rect.height))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onVolumeChange(percentage)
|
|
57
|
+
},
|
|
58
|
+
[onVolumeChange]
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
const handleMouseDown = useCallback((e: React.MouseEvent<HTMLDivElement>, isVertical: boolean) => {
|
|
62
|
+
e.preventDefault()
|
|
63
|
+
e.stopPropagation()
|
|
64
|
+
isDragging.current = true
|
|
65
|
+
setIsDraggingState(true)
|
|
66
|
+
handleSliderClick(e, isVertical)
|
|
67
|
+
}, [handleSliderClick])
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const handleMouseMove = (e: MouseEvent) => {
|
|
71
|
+
if (!isDragging.current) return
|
|
72
|
+
|
|
73
|
+
const sliderRef = orientation === "vertical" ? sliderRefVertical : sliderRefHorizontal
|
|
74
|
+
if (!sliderRef.current) return
|
|
75
|
+
|
|
76
|
+
const rect = sliderRef.current.getBoundingClientRect()
|
|
77
|
+
let percentage: number
|
|
78
|
+
|
|
79
|
+
if (orientation === "horizontal") {
|
|
80
|
+
percentage = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width))
|
|
81
|
+
} else {
|
|
82
|
+
percentage = Math.max(0, Math.min(1, 1 - (e.clientY - rect.top) / rect.height))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onVolumeChange(percentage)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const handleMouseUp = () => {
|
|
89
|
+
isDragging.current = false
|
|
90
|
+
setIsDraggingState(false)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (isDraggingState) {
|
|
94
|
+
document.addEventListener("mousemove", handleMouseMove)
|
|
95
|
+
document.addEventListener("mouseup", handleMouseUp)
|
|
96
|
+
|
|
97
|
+
return () => {
|
|
98
|
+
document.removeEventListener("mousemove", handleMouseMove)
|
|
99
|
+
document.removeEventListener("mouseup", handleMouseUp)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, [isDraggingState, orientation, onVolumeChange])
|
|
103
|
+
|
|
104
|
+
const handleMouseEnter = useCallback(() => {
|
|
105
|
+
if (hideTimeoutRef.current) {
|
|
106
|
+
clearTimeout(hideTimeoutRef.current)
|
|
107
|
+
}
|
|
108
|
+
setIsHovering(true)
|
|
109
|
+
onShowVolumeSlider(true)
|
|
110
|
+
}, [onShowVolumeSlider])
|
|
111
|
+
|
|
112
|
+
const handleMouseLeave = useCallback(() => {
|
|
113
|
+
// Add a small delay before hiding to prevent flickering
|
|
114
|
+
hideTimeoutRef.current = setTimeout(() => {
|
|
115
|
+
if (!isDragging.current) {
|
|
116
|
+
setIsHovering(false)
|
|
117
|
+
onShowVolumeSlider(false)
|
|
118
|
+
}
|
|
119
|
+
}, 200)
|
|
120
|
+
}, [onShowVolumeSlider])
|
|
121
|
+
|
|
122
|
+
// Clean up timeout on unmount
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
return () => {
|
|
125
|
+
if (hideTimeoutRef.current) {
|
|
126
|
+
clearTimeout(hideTimeoutRef.current)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [])
|
|
130
|
+
|
|
131
|
+
const volumePercentage = (isMuted ? 0 : volume) * 100
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div
|
|
135
|
+
className={cn(
|
|
136
|
+
"volume-control-wrapper",
|
|
137
|
+
orientation === "vertical" ? "relative" : "flex items-center gap-2",
|
|
138
|
+
className
|
|
139
|
+
)}
|
|
140
|
+
onMouseEnter={handleMouseEnter}
|
|
141
|
+
onMouseLeave={handleMouseLeave}
|
|
142
|
+
>
|
|
143
|
+
{/* Volume slider for vertical orientation (appears above) */}
|
|
144
|
+
{orientation === "vertical" && (
|
|
145
|
+
<div
|
|
146
|
+
className={cn(
|
|
147
|
+
"volume-slider-vertical",
|
|
148
|
+
"-translate-x-1/2 absolute bottom-full left-1/2 mb-2",
|
|
149
|
+
"transition-all duration-300 ease-out",
|
|
150
|
+
(showVolumeSlider || isHovering || isDraggingState)
|
|
151
|
+
? "pointer-events-auto translate-y-0 opacity-100"
|
|
152
|
+
: "pointer-events-none translate-y-2 opacity-0"
|
|
153
|
+
)}
|
|
154
|
+
>
|
|
155
|
+
<div className="rounded-lg bg-black/80 p-3 backdrop-blur-sm">
|
|
156
|
+
<div
|
|
157
|
+
ref={sliderRefVertical}
|
|
158
|
+
className="volume-slider-track-vertical group"
|
|
159
|
+
onMouseDown={(e) => handleMouseDown(e, true)}
|
|
160
|
+
onClick={(e) => handleSliderClick(e, true)}
|
|
161
|
+
>
|
|
162
|
+
<div
|
|
163
|
+
className="volume-slider-fill-vertical pointer-events-none"
|
|
164
|
+
style={{ height: `${volumePercentage}%` }}
|
|
165
|
+
/>
|
|
166
|
+
<div
|
|
167
|
+
className={cn("volume-slider-thumb-vertical pointer-events-none", isDraggingState && "active")}
|
|
168
|
+
style={{ bottom: `${volumePercentage}%` }}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
171
|
+
<div className="mt-2 text-center text-white/70 text-xs">
|
|
172
|
+
{Math.round(volumePercentage)}%
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
177
|
+
|
|
178
|
+
{/* Volume button */}
|
|
179
|
+
<button
|
|
180
|
+
className="minimal-btn h-10 w-10"
|
|
181
|
+
onClick={onToggleMute}
|
|
182
|
+
aria-label={isMuted ? "Unmute" : "Mute"}
|
|
183
|
+
>
|
|
184
|
+
{isMuted || volume === 0
|
|
185
|
+
? VolumeMutedIcon && <VolumeMutedIcon size={20} />
|
|
186
|
+
: VolumeIcon && <VolumeIcon size={20} />}
|
|
187
|
+
</button>
|
|
188
|
+
|
|
189
|
+
{/* Volume slider for horizontal orientation (appears beside) */}
|
|
190
|
+
{orientation === "horizontal" && (
|
|
191
|
+
<div
|
|
192
|
+
className={cn(
|
|
193
|
+
"volume-slider-horizontal-wrapper",
|
|
194
|
+
"overflow-hidden transition-all duration-300 ease-out",
|
|
195
|
+
(showVolumeSlider || isHovering || isDraggingState) ? "w-24 opacity-100" : "w-0 opacity-0"
|
|
196
|
+
)}
|
|
197
|
+
>
|
|
198
|
+
<div
|
|
199
|
+
ref={sliderRefHorizontal}
|
|
200
|
+
className="volume-slider-track-horizontal group"
|
|
201
|
+
onMouseDown={(e) => handleMouseDown(e, false)}
|
|
202
|
+
onClick={(e) => handleSliderClick(e, false)}
|
|
203
|
+
>
|
|
204
|
+
<div
|
|
205
|
+
className="volume-slider-fill-horizontal pointer-events-none"
|
|
206
|
+
style={{ width: `${volumePercentage}%` }}
|
|
207
|
+
/>
|
|
208
|
+
<div
|
|
209
|
+
className={cn("volume-slider-thumb-horizontal pointer-events-none", isDraggingState && "active")}
|
|
210
|
+
style={{ left: `${volumePercentage}%` }}
|
|
211
|
+
/>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
)}
|
|
215
|
+
</div>
|
|
216
|
+
)
|
|
217
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { MinimalMediaPlayer } from "./MinimalMediaPlayer"
|
|
2
|
+
export type { MinimalMediaPlayerProps } from "./MinimalMediaPlayer"
|
|
3
|
+
|
|
4
|
+
export { MinimalControls } from "./MinimalControls"
|
|
5
|
+
export type { MinimalControlsProps } from "./MinimalControls"
|
|
6
|
+
|
|
7
|
+
export { MinimalPlayButton } from "./MinimalPlayButton"
|
|
8
|
+
export type { MinimalPlayButtonProps } from "./MinimalPlayButton"
|
|
9
|
+
|
|
10
|
+
export { MinimalSeekBar } from "./MinimalSeekBar"
|
|
11
|
+
export type { MinimalSeekBarProps } from "./MinimalSeekBar"
|
|
12
|
+
|
|
13
|
+
export { MinimalVolumeControl } from "./MinimalVolumeControl"
|
|
14
|
+
export type { MinimalVolumeControlProps } from "./MinimalVolumeControl"
|
|
15
|
+
|
|
16
|
+
export { MinimalOverlay } from "./MinimalOverlay"
|
|
17
|
+
export type { MinimalOverlayProps } from "./MinimalOverlay"
|
|
18
|
+
|
|
19
|
+
export { MinimalLoading } from "./MinimalLoading"
|
|
20
|
+
export type { MinimalLoadingProps } from "./MinimalLoading"
|
|
21
|
+
|
|
22
|
+
export { SimpleMinimalPlayer } from "./SimpleMinimalPlayer"
|
|
23
|
+
export type { SimpleMinimalPlayerProps } from "./SimpleMinimalPlayer"
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from "react"
|
|
4
|
+
import { useKeyboardControls } from "../hooks/use-keyboard-controls"
|
|
5
|
+
import { useMediaPlayer } from "../hooks/use-media-player"
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
import type { VideoPlayerProps } from "../types/index"
|
|
8
|
+
|
|
9
|
+
export const VideoPlayer = forwardRef<HTMLDivElement, VideoPlayerProps>(
|
|
10
|
+
(
|
|
11
|
+
{
|
|
12
|
+
src,
|
|
13
|
+
poster,
|
|
14
|
+
width = "100%",
|
|
15
|
+
height = "auto",
|
|
16
|
+
aspectRatio = "16/9",
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
keyboardControls = true,
|
|
20
|
+
showControls = true,
|
|
21
|
+
customControls = false,
|
|
22
|
+
crossOrigin,
|
|
23
|
+
...options
|
|
24
|
+
},
|
|
25
|
+
ref
|
|
26
|
+
) => {
|
|
27
|
+
const { state, controls, mediaRef, containerRef } = useMediaPlayer({
|
|
28
|
+
src,
|
|
29
|
+
crossOrigin,
|
|
30
|
+
...options
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
useKeyboardControls({
|
|
34
|
+
enabled: keyboardControls,
|
|
35
|
+
state,
|
|
36
|
+
controls
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const renderSources = () => {
|
|
40
|
+
if (Array.isArray(src)) {
|
|
41
|
+
return src.map((source, index) => <source key={index} src={source} />)
|
|
42
|
+
}
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const containerStyle = {
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
aspectRatio: height === "auto" ? aspectRatio : undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const videoProps = {
|
|
53
|
+
ref: mediaRef as React.RefObject<HTMLVideoElement>,
|
|
54
|
+
controls: showControls && !customControls,
|
|
55
|
+
poster,
|
|
56
|
+
className: "w-full h-full object-contain bg-black",
|
|
57
|
+
...(Array.isArray(src) ? {} : { src })
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
ref={ref || containerRef}
|
|
63
|
+
style={containerStyle}
|
|
64
|
+
className={cn("relative overflow-hidden bg-black", "focus-within:outline-none", className)}
|
|
65
|
+
tabIndex={0}>
|
|
66
|
+
<video {...videoProps}>
|
|
67
|
+
{Array.isArray(src) && renderSources()}
|
|
68
|
+
Your browser does not support the video element.
|
|
69
|
+
</video>
|
|
70
|
+
|
|
71
|
+
{state.error && (
|
|
72
|
+
<div className="absolute inset-0 flex items-center justify-center bg-black/80">
|
|
73
|
+
<div className="text-center text-white">
|
|
74
|
+
<p className="font-semibold text-lg">Error</p>
|
|
75
|
+
<p className="text-sm opacity-80">{state.error}</p>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
|
|
80
|
+
{state.isLoading && (
|
|
81
|
+
<div className="absolute inset-0 flex items-center justify-center bg-black/50">
|
|
82
|
+
<div className="text-white">
|
|
83
|
+
<div className="h-8 w-8 animate-spin rounded-full border-white border-b-2"></div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
{customControls && typeof children === "function" && (
|
|
89
|
+
<div className="pointer-events-none absolute inset-0">
|
|
90
|
+
<div className="pointer-events-auto">{children({ state, controls })}</div>
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
|
|
94
|
+
{customControls && typeof children !== "function" && children}
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
VideoPlayer.displayName = "VideoPlayer"
|