@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,338 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React from "react"
|
|
4
|
-
import { MediaActionTypes, useMediaDispatch, useMediaSelector } from "../../context/media-context"
|
|
5
|
-
import { cn } from "../../lib/utils"
|
|
6
|
-
|
|
7
|
-
// Enhanced loading component with skeleton and progress
|
|
8
|
-
export const EnhancedLoading = function EnhancedLoading({
|
|
9
|
-
className,
|
|
10
|
-
showProgress = false,
|
|
11
|
-
message = "Loading..."
|
|
12
|
-
}: {
|
|
13
|
-
className?: string
|
|
14
|
-
showProgress?: boolean
|
|
15
|
-
message?: string
|
|
16
|
-
}) {
|
|
17
|
-
const isLoading = useMediaSelector((state) => state.isLoading)
|
|
18
|
-
const [progress, setProgress] = React.useState(0)
|
|
19
|
-
|
|
20
|
-
// Simulate loading progress for better UX
|
|
21
|
-
React.useEffect(() => {
|
|
22
|
-
if (!isLoading) {
|
|
23
|
-
setProgress(0)
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const interval = setInterval(() => {
|
|
28
|
-
setProgress((prev) => {
|
|
29
|
-
if (prev >= 90) return prev
|
|
30
|
-
return prev + Math.random() * 10
|
|
31
|
-
})
|
|
32
|
-
}, 200)
|
|
33
|
-
|
|
34
|
-
return () => clearInterval(interval)
|
|
35
|
-
}, [isLoading])
|
|
36
|
-
|
|
37
|
-
if (!isLoading) return null
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
className={cn(
|
|
42
|
-
"absolute inset-0 z-40 flex items-center justify-center bg-black/50 backdrop-blur-sm",
|
|
43
|
-
className
|
|
44
|
-
)}>
|
|
45
|
-
<div className="flex flex-col items-center gap-4 text-white">
|
|
46
|
-
{/* Spinner */}
|
|
47
|
-
<div className="relative">
|
|
48
|
-
<div className="h-12 w-12 animate-spin rounded-full border-4 border-white/20 border-t-white" />
|
|
49
|
-
{showProgress && (
|
|
50
|
-
<div className="absolute inset-0 flex items-center justify-center">
|
|
51
|
-
<span className="font-medium text-xs">{Math.round(progress)}%</span>
|
|
52
|
-
</div>
|
|
53
|
-
)}
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
{/* Message */}
|
|
57
|
-
<div className="text-center">
|
|
58
|
-
<p className="font-medium text-sm">{message}</p>
|
|
59
|
-
{showProgress && (
|
|
60
|
-
<div className="mt-2 h-1 w-48 overflow-hidden rounded-full bg-white/20">
|
|
61
|
-
<div
|
|
62
|
-
className="h-full bg-primary transition-all duration-300 ease-out"
|
|
63
|
-
style={{ width: `${progress}%` }}
|
|
64
|
-
/>
|
|
65
|
-
</div>
|
|
66
|
-
)}
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Enhanced error component with retry and detailed messages
|
|
74
|
-
export const EnhancedError = function EnhancedError({
|
|
75
|
-
className,
|
|
76
|
-
onRetry,
|
|
77
|
-
showDetails = false
|
|
78
|
-
}: {
|
|
79
|
-
className?: string
|
|
80
|
-
onRetry?: () => void
|
|
81
|
-
showDetails?: boolean
|
|
82
|
-
}) {
|
|
83
|
-
const error = useMediaSelector((state) => state.error)
|
|
84
|
-
const dispatch = useMediaDispatch()
|
|
85
|
-
const [showFullError, setShowFullError] = React.useState(false)
|
|
86
|
-
|
|
87
|
-
const handleRetry = React.useCallback(() => {
|
|
88
|
-
dispatch({ type: MediaActionTypes.SET_ERROR, detail: null })
|
|
89
|
-
onRetry?.()
|
|
90
|
-
}, [dispatch, onRetry])
|
|
91
|
-
|
|
92
|
-
const handleDismiss = React.useCallback(() => {
|
|
93
|
-
dispatch({ type: MediaActionTypes.SET_ERROR, detail: null })
|
|
94
|
-
}, [dispatch])
|
|
95
|
-
|
|
96
|
-
if (!error) return null
|
|
97
|
-
|
|
98
|
-
// Parse error types for better user messages
|
|
99
|
-
const getErrorMessage = (error: string) => {
|
|
100
|
-
if (error.includes("network") || error.includes("fetch")) {
|
|
101
|
-
return {
|
|
102
|
-
title: "Network Error",
|
|
103
|
-
message: "Unable to load the video. Please check your internet connection.",
|
|
104
|
-
icon: "🌐"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (error.includes("format") || error.includes("codec")) {
|
|
108
|
-
return {
|
|
109
|
-
title: "Format Not Supported",
|
|
110
|
-
message: "This video format is not supported by your browser.",
|
|
111
|
-
icon: "🎥"
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (error.includes("permission") || error.includes("cors")) {
|
|
115
|
-
return {
|
|
116
|
-
title: "Access Denied",
|
|
117
|
-
message: "Unable to access the video due to permission restrictions.",
|
|
118
|
-
icon: "🔒"
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
title: "Playback Error",
|
|
123
|
-
message: "An error occurred while trying to play the video.",
|
|
124
|
-
icon: "⚠️"
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const errorInfo = getErrorMessage(error)
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<div
|
|
132
|
-
className={cn(
|
|
133
|
-
"absolute inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",
|
|
134
|
-
className
|
|
135
|
-
)}>
|
|
136
|
-
<div className="mx-4 max-w-md rounded-lg border border-red-500/20 bg-black/90 p-6 text-center">
|
|
137
|
-
{/* Error icon */}
|
|
138
|
-
<div className="mb-4 text-4xl">{errorInfo.icon}</div>
|
|
139
|
-
|
|
140
|
-
{/* Error title */}
|
|
141
|
-
<h3 className="mb-2 font-semibold text-lg text-white">{errorInfo.title}</h3>
|
|
142
|
-
|
|
143
|
-
{/* Error message */}
|
|
144
|
-
<p className="mb-4 text-sm text-white/80">{errorInfo.message}</p>
|
|
145
|
-
|
|
146
|
-
{/* Error details (collapsible) */}
|
|
147
|
-
{showDetails && (
|
|
148
|
-
<div className="mb-4">
|
|
149
|
-
<button
|
|
150
|
-
onClick={() => setShowFullError(!showFullError)}
|
|
151
|
-
className="text-white/60 text-xs transition-colors hover:text-white/80">
|
|
152
|
-
{showFullError ? "Hide" : "Show"} technical details
|
|
153
|
-
</button>
|
|
154
|
-
{showFullError && (
|
|
155
|
-
<div className="mt-2 rounded border border-red-500/30 bg-red-900/20 p-3">
|
|
156
|
-
<code className="break-all text-red-300 text-xs">{error}</code>
|
|
157
|
-
</div>
|
|
158
|
-
)}
|
|
159
|
-
</div>
|
|
160
|
-
)}
|
|
161
|
-
|
|
162
|
-
{/* Action buttons */}
|
|
163
|
-
<div className="flex justify-center gap-3">
|
|
164
|
-
{onRetry && (
|
|
165
|
-
<button
|
|
166
|
-
onClick={handleRetry}
|
|
167
|
-
className="rounded-lg bg-primary px-4 py-2 font-medium text-sm text-white transition-colors hover:bg-primary/80">
|
|
168
|
-
Try Again
|
|
169
|
-
</button>
|
|
170
|
-
)}
|
|
171
|
-
<button
|
|
172
|
-
onClick={handleDismiss}
|
|
173
|
-
className="rounded-lg bg-white/10 px-4 py-2 font-medium text-sm text-white transition-colors hover:bg-white/20">
|
|
174
|
-
Dismiss
|
|
175
|
-
</button>
|
|
176
|
-
</div>
|
|
177
|
-
</div>
|
|
178
|
-
</div>
|
|
179
|
-
)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Error boundary component for React errors
|
|
183
|
-
interface ErrorBoundaryState {
|
|
184
|
-
hasError: boolean
|
|
185
|
-
error?: Error
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export class MediaPlayerErrorBoundary extends React.Component<
|
|
189
|
-
{
|
|
190
|
-
children: React.ReactNode
|
|
191
|
-
fallback?: React.ComponentType<{ error: Error; retry: () => void }>
|
|
192
|
-
},
|
|
193
|
-
ErrorBoundaryState
|
|
194
|
-
> {
|
|
195
|
-
constructor(props: any) {
|
|
196
|
-
super(props)
|
|
197
|
-
this.state = { hasError: false }
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
|
201
|
-
return { hasError: true, error }
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
|
205
|
-
console.error("MediaPlayer Error:", error, errorInfo)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
retry = () => {
|
|
209
|
-
this.setState({ hasError: false, error: undefined })
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
render() {
|
|
213
|
-
if (this.state.hasError) {
|
|
214
|
-
if (this.props.fallback) {
|
|
215
|
-
const Fallback = this.props.fallback
|
|
216
|
-
return <Fallback error={this.state.error!} retry={this.retry} />
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<div className="absolute inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm">
|
|
221
|
-
<div className="mx-4 max-w-md rounded-lg border border-red-500/20 bg-black/90 p-6 text-center">
|
|
222
|
-
<div className="mb-4 text-4xl">💥</div>
|
|
223
|
-
<h3 className="mb-2 font-semibold text-lg text-white">Something went wrong</h3>
|
|
224
|
-
<p className="mb-4 text-sm text-white/80">
|
|
225
|
-
The media player encountered an unexpected error.
|
|
226
|
-
</p>
|
|
227
|
-
<button
|
|
228
|
-
onClick={this.retry}
|
|
229
|
-
className="rounded-lg bg-primary px-4 py-2 font-medium text-sm text-white transition-colors hover:bg-primary/80">
|
|
230
|
-
Reload Player
|
|
231
|
-
</button>
|
|
232
|
-
</div>
|
|
233
|
-
</div>
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return this.props.children
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Connection status indicator
|
|
242
|
-
export const ConnectionStatus = function ConnectionStatus({
|
|
243
|
-
className
|
|
244
|
-
}: {
|
|
245
|
-
className?: string
|
|
246
|
-
}) {
|
|
247
|
-
const [isOnline, setIsOnline] = React.useState(navigator.onLine)
|
|
248
|
-
const [showOfflineMessage, setShowOfflineMessage] = React.useState(false)
|
|
249
|
-
|
|
250
|
-
React.useEffect(() => {
|
|
251
|
-
const handleOnline = () => {
|
|
252
|
-
setIsOnline(true)
|
|
253
|
-
setShowOfflineMessage(false)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const handleOffline = () => {
|
|
257
|
-
setIsOnline(false)
|
|
258
|
-
setShowOfflineMessage(true)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
window.addEventListener("online", handleOnline)
|
|
262
|
-
window.addEventListener("offline", handleOffline)
|
|
263
|
-
|
|
264
|
-
return () => {
|
|
265
|
-
window.removeEventListener("online", handleOnline)
|
|
266
|
-
window.removeEventListener("offline", handleOffline)
|
|
267
|
-
}
|
|
268
|
-
}, [])
|
|
269
|
-
|
|
270
|
-
if (!showOfflineMessage) return null
|
|
271
|
-
|
|
272
|
-
return (
|
|
273
|
-
<div
|
|
274
|
-
className={cn(
|
|
275
|
-
"absolute top-4 right-4 left-4 z-50 rounded-lg border border-orange-400/30 bg-orange-500/90 p-3 backdrop-blur-sm",
|
|
276
|
-
className
|
|
277
|
-
)}>
|
|
278
|
-
<div className="flex items-center gap-3 text-white">
|
|
279
|
-
<div className="h-2 w-2 animate-pulse rounded-full bg-orange-300" />
|
|
280
|
-
<span className="font-medium text-sm">You're offline. Video playback may be affected.</span>
|
|
281
|
-
</div>
|
|
282
|
-
</div>
|
|
283
|
-
)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Buffer health indicator
|
|
287
|
-
export const BufferHealthIndicator = function BufferHealthIndicator({
|
|
288
|
-
className
|
|
289
|
-
}: {
|
|
290
|
-
className?: string
|
|
291
|
-
}) {
|
|
292
|
-
const buffered = useMediaSelector((state) => state.buffered)
|
|
293
|
-
const currentTime = useMediaSelector((state) => state.currentTime)
|
|
294
|
-
const duration = useMediaSelector((state) => state.duration)
|
|
295
|
-
|
|
296
|
-
const bufferHealth = React.useMemo(() => {
|
|
297
|
-
if (!buffered || duration === 0) return 0
|
|
298
|
-
|
|
299
|
-
let bufferedAhead = 0
|
|
300
|
-
for (let i = 0; i < buffered.length; i++) {
|
|
301
|
-
const start = buffered.start(i)
|
|
302
|
-
const end = buffered.end(i)
|
|
303
|
-
if (start <= currentTime && end > currentTime) {
|
|
304
|
-
bufferedAhead = end - currentTime
|
|
305
|
-
break
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return Math.min(100, (bufferedAhead / 30) * 100) // 30 seconds = 100%
|
|
310
|
-
}, [buffered, currentTime, duration])
|
|
311
|
-
|
|
312
|
-
const getHealthColor = (health: number) => {
|
|
313
|
-
if (health > 70) return "bg-green-500"
|
|
314
|
-
if (health > 30) return "bg-yellow-500"
|
|
315
|
-
return "bg-red-500"
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (bufferHealth > 80) return null // Don't show when buffer is healthy
|
|
319
|
-
|
|
320
|
-
return (
|
|
321
|
-
<div
|
|
322
|
-
className={cn(
|
|
323
|
-
"absolute top-4 right-4 z-40 rounded-lg border border-white/20 bg-black/80 p-2 backdrop-blur-sm",
|
|
324
|
-
className
|
|
325
|
-
)}>
|
|
326
|
-
<div className="flex items-center gap-2 text-white text-xs">
|
|
327
|
-
<span>Buffer:</span>
|
|
328
|
-
<div className="h-1 w-16 overflow-hidden rounded-full bg-white/20">
|
|
329
|
-
<div
|
|
330
|
-
className={cn("h-full transition-all duration-300", getHealthColor(bufferHealth))}
|
|
331
|
-
style={{ width: `${bufferHealth}%` }}
|
|
332
|
-
/>
|
|
333
|
-
</div>
|
|
334
|
-
<span>{Math.round(bufferHealth)}%</span>
|
|
335
|
-
</div>
|
|
336
|
-
</div>
|
|
337
|
-
)
|
|
338
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Enhanced Components with Advanced Features
|
|
2
|
-
export {
|
|
3
|
-
ChaptersPanel,
|
|
4
|
-
PictureInPictureButton,
|
|
5
|
-
PlaybackSpeedSelector,
|
|
6
|
-
QualitySelector,
|
|
7
|
-
SubtitleSelector
|
|
8
|
-
} from "./advanced-features"
|
|
9
|
-
|
|
10
|
-
// Enhanced Control Components
|
|
11
|
-
export {
|
|
12
|
-
EnhancedPlayButton,
|
|
13
|
-
EnhancedSeekBar,
|
|
14
|
-
EnhancedTimeDisplay,
|
|
15
|
-
EnhancedVolumeControl,
|
|
16
|
-
EnhancedBackwardButton,
|
|
17
|
-
EnhancedForwardButton,
|
|
18
|
-
EnhancedControlBar
|
|
19
|
-
} from "./enhanced-controls"
|
|
20
|
-
|
|
21
|
-
// Enhanced Error Handling
|
|
22
|
-
export {
|
|
23
|
-
BufferHealthIndicator,
|
|
24
|
-
ConnectionStatus,
|
|
25
|
-
EnhancedError,
|
|
26
|
-
EnhancedLoading,
|
|
27
|
-
MediaPlayerErrorBoundary
|
|
28
|
-
} from "./error-handling"
|
|
29
|
-
|
|
30
|
-
// Main Enhanced Media Player
|
|
31
|
-
export { EnhancedMediaPlayer } from "./media-player-enhanced"
|
|
32
|
-
|
|
33
|
-
// Enhanced Examples
|
|
34
|
-
export {
|
|
35
|
-
EnhancedControlsExample,
|
|
36
|
-
CustomEnhancedControlsExample,
|
|
37
|
-
SkipButtonsOnlyExample
|
|
38
|
-
} from "../examples/enhanced-controls-example"
|
|
39
|
-
export type { EnhancedControlsExampleProps } from "../examples/enhanced-controls-example"
|