@therealtinhtute/baroiplayer 1.2.1 → 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 +90 -71
- 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 +1 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +750 -5640
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +3 -0
- package/package.json +110 -114
- 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 -1
- package/dist/context/media.mjs +0 -3
- package/dist/context/store.js +0 -1
- package/dist/context/store.mjs +0 -3
- package/dist/context-Bzd5QCKM.cjs +0 -7
- package/dist/context-Bzd5QCKM.cjs.map +0 -1
- package/dist/context-DD_SH4tT.js +0 -1053
- package/dist/context-DD_SH4tT.js.map +0 -1
- package/dist/core-events-BRnLMB7s.cjs +0 -2
- package/dist/core-events-BRnLMB7s.cjs.map +0 -1
- package/dist/core-events-v_mKdj5p.js +0 -417
- package/dist/core-events-v_mKdj5p.js.map +0 -1
- package/dist/core-plugins-CMBv-yVh.cjs +0 -2
- package/dist/core-plugins-CMBv-yVh.cjs.map +0 -1
- package/dist/core-plugins-CqCxLkbd.js +0 -754
- package/dist/core-plugins-CqCxLkbd.js.map +0 -1
- package/dist/core.js +0 -15
- package/dist/core.js.map +0 -1
- package/dist/core.mjs +0 -960
- package/dist/core.mjs.map +0 -1
- package/dist/enhanced-components-BwjBqSA1.js +0 -2858
- package/dist/enhanced-components-BwjBqSA1.js.map +0 -1
- package/dist/enhanced-components-C-ka-XLp.cjs +0 -2
- package/dist/enhanced-components-C-ka-XLp.cjs.map +0 -1
- package/dist/hooks-B-IIWPJr.js +0 -1842
- package/dist/hooks-B-IIWPJr.js.map +0 -1
- package/dist/hooks-DcHzmBwA.cjs +0 -4
- package/dist/hooks-DcHzmBwA.cjs.map +0 -1
- package/dist/minimal-components-BYsMQde5.js +0 -1610
- package/dist/minimal-components-BYsMQde5.js.map +0 -1
- package/dist/minimal-components-CsxQbDp7.cjs +0 -2
- package/dist/minimal-components-CsxQbDp7.cjs.map +0 -1
- package/dist/minimal-components.css +0 -1
- package/dist/mona-loading.gif +0 -0
- package/dist/performance-monitor-DCSijLJg.js +0 -312
- package/dist/performance-monitor-DCSijLJg.js.map +0 -1
- package/dist/performance-monitor-wNFKmqMr.cjs +0 -2
- package/dist/performance-monitor-wNFKmqMr.cjs.map +0 -1
- package/dist/rolldown-runtime-BmowowmI.js +0 -14
- package/dist/rolldown-runtime-mLOUI7ql.cjs +0 -1
- package/dist/utils-D2gQ7c2R.js +0 -64
- package/dist/utils-D2gQ7c2R.js.map +0 -1
- package/dist/utils-DJaAwiZ9.cjs +0 -2
- package/dist/utils-DJaAwiZ9.cjs.map +0 -1
- package/dist/utils.js +0 -1
- package/dist/utils.mjs +0 -3
- package/src/adapters/videojs-adapter.tsx +0 -470
- package/src/assets/mona-loading.gif +0 -0
- package/src/components/AnimateLoading.tsx +0 -111
- 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 -141
- package/src/components/examples/react-19-demo.tsx +0 -349
- package/src/components/examples/volume-orientation-demo.tsx +0 -105
- 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 -96
- 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 -35
- 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 -545
- 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 -77
- 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/assets.d.ts +0 -29
- 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,85 +0,0 @@
|
|
|
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 { AudioPlayerProps } from "../types/index"
|
|
8
|
-
|
|
9
|
-
export const AudioPlayer = forwardRef<HTMLDivElement, AudioPlayerProps>(
|
|
10
|
-
(
|
|
11
|
-
{
|
|
12
|
-
src,
|
|
13
|
-
className,
|
|
14
|
-
children,
|
|
15
|
-
keyboardControls = true,
|
|
16
|
-
showControls = true,
|
|
17
|
-
customControls = false,
|
|
18
|
-
...options
|
|
19
|
-
},
|
|
20
|
-
ref
|
|
21
|
-
) => {
|
|
22
|
-
const { state, controls, mediaRef, containerRef } = useMediaPlayer({
|
|
23
|
-
src,
|
|
24
|
-
...options
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
useKeyboardControls({
|
|
28
|
-
enabled: keyboardControls,
|
|
29
|
-
state,
|
|
30
|
-
controls
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const renderSources = () => {
|
|
34
|
-
if (Array.isArray(src)) {
|
|
35
|
-
return src.map((source, index) => <source key={index} src={source} />)
|
|
36
|
-
}
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const audioProps = {
|
|
41
|
-
ref: mediaRef as React.RefObject<HTMLAudioElement>,
|
|
42
|
-
controls: showControls && !customControls,
|
|
43
|
-
className: "w-full",
|
|
44
|
-
...(Array.isArray(src) ? {} : { src })
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div
|
|
49
|
-
ref={ref || containerRef}
|
|
50
|
-
className={cn("relative", "focus-within:outline-none", className)}
|
|
51
|
-
tabIndex={0}>
|
|
52
|
-
<audio {...audioProps}>
|
|
53
|
-
{Array.isArray(src) && renderSources()}
|
|
54
|
-
Your browser does not support the audio element.
|
|
55
|
-
</audio>
|
|
56
|
-
|
|
57
|
-
{state.error && (
|
|
58
|
-
<div className="mt-2 rounded-md border border-red-300 bg-red-100 p-3">
|
|
59
|
-
<div className="text-red-800">
|
|
60
|
-
<p className="font-semibold">Error</p>
|
|
61
|
-
<p className="text-sm">{state.error}</p>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
)}
|
|
65
|
-
|
|
66
|
-
{state.isLoading && (
|
|
67
|
-
<div className="mt-2 rounded-md border border-gray-300 bg-gray-100 p-3">
|
|
68
|
-
<div className="flex items-center space-x-2 text-gray-600">
|
|
69
|
-
<div className="h-4 w-4 animate-spin rounded-full border-gray-600 border-b-2"></div>
|
|
70
|
-
<span className="text-sm">Loading...</span>
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
)}
|
|
74
|
-
|
|
75
|
-
{customControls && typeof children === "function" && (
|
|
76
|
-
<div className="mt-2">{children({ state, controls })}</div>
|
|
77
|
-
)}
|
|
78
|
-
|
|
79
|
-
{customControls && typeof children !== "function" && <div className="mt-2">{children}</div>}
|
|
80
|
-
</div>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
AudioPlayer.displayName = "AudioPlayer"
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Basic Media Player Components
|
|
2
|
-
export { AudioPlayer } from "../audio-player"
|
|
3
|
-
export { MediaPlayer } from "../media-player"
|
|
4
|
-
export { VideoPlayer } from "../video-player"
|
|
5
|
-
export { SimpleVideoPlayer } from "../simple-video-player"
|
|
6
|
-
|
|
7
|
-
// Modern React Player
|
|
8
|
-
export { ModernMediaPlayer } from "../react-player-wrapper"
|
|
9
|
-
export type { ModernMediaPlayerProps } from "../react-player-wrapper"
|
|
10
|
-
|
|
11
|
-
// Basic UI Components
|
|
12
|
-
export { FullscreenButton } from "../ui/fullscreen-button"
|
|
13
|
-
export { PlayButton } from "../ui/play-button"
|
|
14
|
-
export { SeekBar } from "../ui/seek-bar"
|
|
15
|
-
export { TimeDisplay } from "../ui/time-display"
|
|
16
|
-
export { VolumeControl } from "../ui/volume-control"
|
|
17
|
-
|
|
18
|
-
// DiceUI-style Basic Components
|
|
19
|
-
export { MediaPlayerAudio } from "../media-player-audio"
|
|
20
|
-
export {
|
|
21
|
-
MediaPlayerControls,
|
|
22
|
-
MediaPlayerControlsOverlay
|
|
23
|
-
} from "../media-player-controls"
|
|
24
|
-
export { MediaPlayerError } from "../media-player-error"
|
|
25
|
-
export { MediaPlayerFullscreen } from "../media-player-fullscreen"
|
|
26
|
-
export { MediaPlayerLoading } from "../media-player-loading"
|
|
27
|
-
export { MediaPlayerPlay } from "../media-player-play"
|
|
28
|
-
export { MediaPlayerRoot } from "../media-player-root"
|
|
29
|
-
export { MediaPlayerSeek } from "../media-player-seek"
|
|
30
|
-
export { MediaPlayerTime } from "../media-player-time"
|
|
31
|
-
export { MediaPlayerTooltip } from "../media-player-tooltip"
|
|
32
|
-
export { MediaPlayerVideo } from "../media-player-video"
|
|
33
|
-
export { MediaPlayerVolume } from "../media-player-volume"
|
|
34
|
-
|
|
35
|
-
// Basic Examples
|
|
36
|
-
export { BasicVideoPlayer } from "../examples/basic-video-player"
|
|
37
|
-
export { CustomControlsExample } from "../examples/custom-controls-example"
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React from "react"
|
|
4
|
-
import { MediaActionTypes, useMediaDispatch, useMediaSelector } from "../../context/media-context"
|
|
5
|
-
import { formatTime } from "../../lib/format-time"
|
|
6
|
-
import { cn } from "../../lib/utils"
|
|
7
|
-
|
|
8
|
-
// Types for advanced features
|
|
9
|
-
export interface Chapter {
|
|
10
|
-
id: string
|
|
11
|
-
title: string
|
|
12
|
-
startTime: number
|
|
13
|
-
endTime: number
|
|
14
|
-
thumbnail?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface QualityLevel {
|
|
18
|
-
id: string
|
|
19
|
-
label: string
|
|
20
|
-
width: number
|
|
21
|
-
height: number
|
|
22
|
-
bitrate?: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface Subtitle {
|
|
26
|
-
id: string
|
|
27
|
-
label: string
|
|
28
|
-
language: string
|
|
29
|
-
src: string
|
|
30
|
-
default?: boolean
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Quality selector component
|
|
34
|
-
export const QualitySelector = function QualitySelector({
|
|
35
|
-
qualities,
|
|
36
|
-
currentQuality,
|
|
37
|
-
onQualityChange,
|
|
38
|
-
className
|
|
39
|
-
}: {
|
|
40
|
-
qualities: QualityLevel[]
|
|
41
|
-
currentQuality: string
|
|
42
|
-
onQualityChange: (qualityId: string) => void
|
|
43
|
-
className?: string
|
|
44
|
-
}) {
|
|
45
|
-
const [isOpen, setIsOpen] = React.useState(false)
|
|
46
|
-
|
|
47
|
-
const currentQualityLabel = React.useMemo(() => {
|
|
48
|
-
return qualities.find((q) => q.id === currentQuality)?.label || "Auto"
|
|
49
|
-
}, [qualities, currentQuality])
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div className={cn("relative", className)}>
|
|
53
|
-
<button
|
|
54
|
-
type="button"
|
|
55
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
56
|
-
className="flex items-center gap-2 rounded-lg bg-black/50 px-3 py-2 text-white transition-colors hover:bg-black/70"
|
|
57
|
-
aria-label="Select quality">
|
|
58
|
-
<svg viewBox="0 0 24 24" fill="currentColor" className="h-4 w-4">
|
|
59
|
-
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" />
|
|
60
|
-
</svg>
|
|
61
|
-
<span className="text-sm">{currentQualityLabel}</span>
|
|
62
|
-
<svg
|
|
63
|
-
viewBox="0 0 24 24"
|
|
64
|
-
fill="currentColor"
|
|
65
|
-
className={cn("h-4 w-4 transition-transform", isOpen && "rotate-180")}>
|
|
66
|
-
<path d="M7 10l5 5 5-5z" />
|
|
67
|
-
</svg>
|
|
68
|
-
</button>
|
|
69
|
-
|
|
70
|
-
{isOpen && (
|
|
71
|
-
<div className="absolute right-0 bottom-full mb-2 min-w-32 rounded-lg border border-white/20 bg-black/90 py-2 backdrop-blur-sm">
|
|
72
|
-
{qualities.map((quality) => (
|
|
73
|
-
<button
|
|
74
|
-
key={quality.id}
|
|
75
|
-
onClick={() => {
|
|
76
|
-
onQualityChange(quality.id)
|
|
77
|
-
setIsOpen(false)
|
|
78
|
-
}}
|
|
79
|
-
className={cn(
|
|
80
|
-
"w-full px-4 py-2 text-left text-sm text-white transition-colors hover:bg-white/10",
|
|
81
|
-
quality.id === currentQuality && "bg-primary/20 text-primary"
|
|
82
|
-
)}>
|
|
83
|
-
{quality.label}
|
|
84
|
-
{quality.bitrate && (
|
|
85
|
-
<span className="ml-2 text-white/60 text-xs">
|
|
86
|
-
({Math.round(quality.bitrate / 1000)}k)
|
|
87
|
-
</span>
|
|
88
|
-
)}
|
|
89
|
-
</button>
|
|
90
|
-
))}
|
|
91
|
-
</div>
|
|
92
|
-
)}
|
|
93
|
-
</div>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Subtitle selector component
|
|
98
|
-
export const SubtitleSelector = function SubtitleSelector({
|
|
99
|
-
subtitles,
|
|
100
|
-
currentSubtitle,
|
|
101
|
-
onSubtitleChange,
|
|
102
|
-
className
|
|
103
|
-
}: {
|
|
104
|
-
subtitles: Subtitle[]
|
|
105
|
-
currentSubtitle: string | null
|
|
106
|
-
onSubtitleChange: (subtitleId: string | null) => void
|
|
107
|
-
className?: string
|
|
108
|
-
}) {
|
|
109
|
-
const [isOpen, setIsOpen] = React.useState(false)
|
|
110
|
-
|
|
111
|
-
const currentSubtitleLabel = React.useMemo(() => {
|
|
112
|
-
if (!currentSubtitle) return "Off"
|
|
113
|
-
return subtitles.find((s) => s.id === currentSubtitle)?.label || "Off"
|
|
114
|
-
}, [subtitles, currentSubtitle])
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<div className={cn("relative", className)}>
|
|
118
|
-
<button
|
|
119
|
-
type="button"
|
|
120
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
121
|
-
className="flex items-center gap-2 rounded-lg bg-black/50 px-3 py-2 text-white transition-colors hover:bg-black/70"
|
|
122
|
-
aria-label="Select subtitles">
|
|
123
|
-
<svg viewBox="0 0 24 24" fill="currentColor" className="h-4 w-4">
|
|
124
|
-
<path d="M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM4 12h4v2H4v-2zm10 6H4v-2h10v2zm6 0h-4v-2h4v2zm0-4H10v-2h10v2z" />
|
|
125
|
-
</svg>
|
|
126
|
-
<span className="text-sm">{currentSubtitleLabel}</span>
|
|
127
|
-
<svg
|
|
128
|
-
viewBox="0 0 24 24"
|
|
129
|
-
fill="currentColor"
|
|
130
|
-
className={cn("h-4 w-4 transition-transform", isOpen && "rotate-180")}>
|
|
131
|
-
<path d="M7 10l5 5 5-5z" />
|
|
132
|
-
</svg>
|
|
133
|
-
</button>
|
|
134
|
-
|
|
135
|
-
{isOpen && (
|
|
136
|
-
<div className="absolute right-0 bottom-full mb-2 min-w-32 rounded-lg border border-white/20 bg-black/90 py-2 backdrop-blur-sm">
|
|
137
|
-
<button
|
|
138
|
-
onClick={() => {
|
|
139
|
-
onSubtitleChange(null)
|
|
140
|
-
setIsOpen(false)
|
|
141
|
-
}}
|
|
142
|
-
className={cn(
|
|
143
|
-
"w-full px-4 py-2 text-left text-sm text-white transition-colors hover:bg-white/10",
|
|
144
|
-
!currentSubtitle && "bg-primary/20 text-primary"
|
|
145
|
-
)}>
|
|
146
|
-
Off
|
|
147
|
-
</button>
|
|
148
|
-
{subtitles.map((subtitle) => (
|
|
149
|
-
<button
|
|
150
|
-
key={subtitle.id}
|
|
151
|
-
onClick={() => {
|
|
152
|
-
onSubtitleChange(subtitle.id)
|
|
153
|
-
setIsOpen(false)
|
|
154
|
-
}}
|
|
155
|
-
className={cn(
|
|
156
|
-
"w-full px-4 py-2 text-left text-sm text-white transition-colors hover:bg-white/10",
|
|
157
|
-
subtitle.id === currentSubtitle && "bg-primary/20 text-primary"
|
|
158
|
-
)}>
|
|
159
|
-
{subtitle.label}
|
|
160
|
-
</button>
|
|
161
|
-
))}
|
|
162
|
-
</div>
|
|
163
|
-
)}
|
|
164
|
-
</div>
|
|
165
|
-
)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Playback speed selector
|
|
169
|
-
export const PlaybackSpeedSelector = function PlaybackSpeedSelector({
|
|
170
|
-
className
|
|
171
|
-
}: {
|
|
172
|
-
className?: string
|
|
173
|
-
}) {
|
|
174
|
-
const dispatch = useMediaDispatch()
|
|
175
|
-
const playbackRate = useMediaSelector((state) => state.playbackRate)
|
|
176
|
-
const [isOpen, setIsOpen] = React.useState(false)
|
|
177
|
-
|
|
178
|
-
const speeds = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]
|
|
179
|
-
|
|
180
|
-
const handleSpeedChange = React.useCallback(
|
|
181
|
-
(speed: number) => {
|
|
182
|
-
dispatch({ type: MediaActionTypes.SET_PLAYBACK_RATE, detail: speed })
|
|
183
|
-
setIsOpen(false)
|
|
184
|
-
},
|
|
185
|
-
[dispatch]
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
return (
|
|
189
|
-
<div className={cn("relative", className)}>
|
|
190
|
-
<button
|
|
191
|
-
type="button"
|
|
192
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
193
|
-
className="flex items-center gap-2 rounded-lg bg-black/50 px-3 py-2 text-white transition-colors hover:bg-black/70"
|
|
194
|
-
aria-label="Select playback speed">
|
|
195
|
-
<svg viewBox="0 0 24 24" fill="currentColor" className="h-4 w-4">
|
|
196
|
-
<path d="M13,8A4,4 0 0,0 9,12A4,4 0 0,0 13,16A4,4 0 0,0 17,12A4,4 0 0,0 13,8M13,14A2,2 0 0,1 11,12A2,2 0 0,1 13,10A2,2 0 0,1 15,12A2,2 0 0,1 13,14M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4Z" />
|
|
197
|
-
</svg>
|
|
198
|
-
<span className="text-sm">{playbackRate}x</span>
|
|
199
|
-
<svg
|
|
200
|
-
viewBox="0 0 24 24"
|
|
201
|
-
fill="currentColor"
|
|
202
|
-
className={cn("h-4 w-4 transition-transform", isOpen && "rotate-180")}>
|
|
203
|
-
<path d="M7 10l5 5 5-5z" />
|
|
204
|
-
</svg>
|
|
205
|
-
</button>
|
|
206
|
-
|
|
207
|
-
{isOpen && (
|
|
208
|
-
<div className="absolute right-0 bottom-full mb-2 min-w-20 rounded-lg border border-white/20 bg-black/90 py-2 backdrop-blur-sm">
|
|
209
|
-
{speeds.map((speed) => (
|
|
210
|
-
<button
|
|
211
|
-
key={speed}
|
|
212
|
-
onClick={() => handleSpeedChange(speed)}
|
|
213
|
-
className={cn(
|
|
214
|
-
"w-full px-4 py-2 text-left text-sm text-white transition-colors hover:bg-white/10",
|
|
215
|
-
speed === playbackRate && "bg-primary/20 text-primary"
|
|
216
|
-
)}>
|
|
217
|
-
{speed}x
|
|
218
|
-
</button>
|
|
219
|
-
))}
|
|
220
|
-
</div>
|
|
221
|
-
)}
|
|
222
|
-
</div>
|
|
223
|
-
)
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Chapters component
|
|
227
|
-
export const ChaptersPanel = function ChaptersPanel({
|
|
228
|
-
chapters,
|
|
229
|
-
onChapterSelect,
|
|
230
|
-
className
|
|
231
|
-
}: {
|
|
232
|
-
chapters: Chapter[]
|
|
233
|
-
onChapterSelect: (chapter: Chapter) => void
|
|
234
|
-
className?: string
|
|
235
|
-
}) {
|
|
236
|
-
const currentTime = useMediaSelector((state) => state.currentTime)
|
|
237
|
-
|
|
238
|
-
const currentChapter = React.useMemo(() => {
|
|
239
|
-
return chapters.find(
|
|
240
|
-
(chapter) => currentTime >= chapter.startTime && currentTime < chapter.endTime
|
|
241
|
-
)
|
|
242
|
-
}, [chapters, currentTime])
|
|
243
|
-
|
|
244
|
-
return (
|
|
245
|
-
<div
|
|
246
|
-
className={cn(
|
|
247
|
-
"rounded-lg border border-white/20 bg-black/90 p-4 backdrop-blur-sm",
|
|
248
|
-
className
|
|
249
|
-
)}>
|
|
250
|
-
<h3 className="mb-3 font-semibold text-white">Chapters</h3>
|
|
251
|
-
<div className="max-h-64 space-y-2 overflow-y-auto">
|
|
252
|
-
{chapters.map((chapter) => (
|
|
253
|
-
<button
|
|
254
|
-
key={chapter.id}
|
|
255
|
-
onClick={() => onChapterSelect(chapter)}
|
|
256
|
-
className={cn(
|
|
257
|
-
"flex w-full items-center gap-3 rounded-lg p-3 text-left transition-colors",
|
|
258
|
-
"hover:bg-white/10",
|
|
259
|
-
chapter.id === currentChapter?.id && "border border-primary/30 bg-primary/20"
|
|
260
|
-
)}>
|
|
261
|
-
{chapter.thumbnail && (
|
|
262
|
-
<img
|
|
263
|
-
src={chapter.thumbnail}
|
|
264
|
-
alt={chapter.title}
|
|
265
|
-
className="h-9 w-16 rounded object-cover"
|
|
266
|
-
/>
|
|
267
|
-
)}
|
|
268
|
-
<div className="min-w-0 flex-1">
|
|
269
|
-
<div className="truncate font-medium text-white">{chapter.title}</div>
|
|
270
|
-
<div className="text-sm text-white/60">
|
|
271
|
-
{formatTime(chapter.startTime)} - {formatTime(chapter.endTime)}
|
|
272
|
-
</div>
|
|
273
|
-
</div>
|
|
274
|
-
</button>
|
|
275
|
-
))}
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
)
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Picture-in-Picture button
|
|
282
|
-
export const PictureInPictureButton = function PictureInPictureButton({
|
|
283
|
-
className
|
|
284
|
-
}: {
|
|
285
|
-
className?: string
|
|
286
|
-
}) {
|
|
287
|
-
const dispatch = useMediaDispatch()
|
|
288
|
-
const isPictureInPicture = useMediaSelector((state) => state.isPictureInPicture)
|
|
289
|
-
|
|
290
|
-
const handleTogglePiP = React.useCallback(() => {
|
|
291
|
-
dispatch({
|
|
292
|
-
type: isPictureInPicture ? MediaActionTypes.EXIT_PIP : MediaActionTypes.ENTER_PIP
|
|
293
|
-
})
|
|
294
|
-
}, [dispatch, isPictureInPicture])
|
|
295
|
-
|
|
296
|
-
return (
|
|
297
|
-
<button
|
|
298
|
-
type="button"
|
|
299
|
-
onClick={handleTogglePiP}
|
|
300
|
-
className={cn(
|
|
301
|
-
"flex h-10 w-10 items-center justify-center rounded-full text-white",
|
|
302
|
-
"transition-colors hover:bg-white/10",
|
|
303
|
-
className
|
|
304
|
-
)}
|
|
305
|
-
aria-label={isPictureInPicture ? "Exit Picture-in-Picture" : "Enter Picture-in-Picture"}>
|
|
306
|
-
<svg viewBox="0 0 24 24" fill="currentColor" className="h-5 w-5">
|
|
307
|
-
<path d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z" />
|
|
308
|
-
</svg>
|
|
309
|
-
</button>
|
|
310
|
-
)
|
|
311
|
-
}
|