@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,95 +0,0 @@
|
|
|
1
|
-
import { useOptimistic, useTransition } from "react"
|
|
2
|
-
|
|
3
|
-
export interface MediaState {
|
|
4
|
-
isPlaying: boolean
|
|
5
|
-
volume: number
|
|
6
|
-
currentTime: number
|
|
7
|
-
playbackRate: number
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function useOptimisticMediaState(
|
|
11
|
-
initialState: MediaState,
|
|
12
|
-
mediaElement?: HTMLMediaElement | null
|
|
13
|
-
) {
|
|
14
|
-
const [isPending, startTransition] = useTransition()
|
|
15
|
-
|
|
16
|
-
// Optimistic state for each property
|
|
17
|
-
const [optimisticPlaying, setOptimisticPlaying] = useOptimistic(
|
|
18
|
-
initialState.isPlaying,
|
|
19
|
-
(_, value: boolean) => value
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
const [optimisticVolume, setOptimisticVolume] = useOptimistic(
|
|
23
|
-
initialState.volume,
|
|
24
|
-
(_, value: number) => value
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
const [optimisticTime, setOptimisticTime] = useOptimistic(
|
|
28
|
-
initialState.currentTime,
|
|
29
|
-
(_, value: number) => value
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const [optimisticRate, setOptimisticRate] = useOptimistic(
|
|
33
|
-
initialState.playbackRate,
|
|
34
|
-
(_, value: number) => value
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
// Wrapped actions with optimistic updates
|
|
38
|
-
const actions = {
|
|
39
|
-
togglePlay: async () => {
|
|
40
|
-
const newState = !optimisticPlaying
|
|
41
|
-
setOptimisticPlaying(newState)
|
|
42
|
-
|
|
43
|
-
startTransition(async () => {
|
|
44
|
-
if (mediaElement) {
|
|
45
|
-
if (newState) {
|
|
46
|
-
await mediaElement.play()
|
|
47
|
-
} else {
|
|
48
|
-
mediaElement.pause()
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
setVolume: async (volume: number) => {
|
|
55
|
-
setOptimisticVolume(volume)
|
|
56
|
-
|
|
57
|
-
startTransition(async () => {
|
|
58
|
-
if (mediaElement) {
|
|
59
|
-
mediaElement.volume = volume
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
seek: async (time: number) => {
|
|
65
|
-
setOptimisticTime(time)
|
|
66
|
-
|
|
67
|
-
startTransition(async () => {
|
|
68
|
-
if (mediaElement) {
|
|
69
|
-
mediaElement.currentTime = time
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
setPlaybackRate: async (rate: number) => {
|
|
75
|
-
setOptimisticRate(rate)
|
|
76
|
-
|
|
77
|
-
startTransition(async () => {
|
|
78
|
-
if (mediaElement) {
|
|
79
|
-
mediaElement.playbackRate = rate
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
state: {
|
|
87
|
-
isPlaying: optimisticPlaying,
|
|
88
|
-
volume: optimisticVolume,
|
|
89
|
-
currentTime: optimisticTime,
|
|
90
|
-
playbackRate: optimisticRate
|
|
91
|
-
},
|
|
92
|
-
actions,
|
|
93
|
-
isPending
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React from "react"
|
|
4
|
-
import { MediaActionTypes, useMediaDispatch, useMediaSelector } from "../context/media-context"
|
|
5
|
-
|
|
6
|
-
// Optimized hook for media state with memoized selectors
|
|
7
|
-
export function useOptimizedMediaState() {
|
|
8
|
-
// Memoized selectors to prevent unnecessary re-renders
|
|
9
|
-
const isPlaying = useMediaSelector(React.useCallback((state) => state.isPlaying, []))
|
|
10
|
-
const currentTime = useMediaSelector(React.useCallback((state) => state.currentTime, []))
|
|
11
|
-
const duration = useMediaSelector(React.useCallback((state) => state.duration, []))
|
|
12
|
-
const volume = useMediaSelector(React.useCallback((state) => state.volume, []))
|
|
13
|
-
const isMuted = useMediaSelector(React.useCallback((state) => state.isMuted, []))
|
|
14
|
-
const isLoading = useMediaSelector(React.useCallback((state) => state.isLoading, []))
|
|
15
|
-
const error = useMediaSelector(React.useCallback((state) => state.error, []))
|
|
16
|
-
const isFullscreen = useMediaSelector(React.useCallback((state) => state.isFullscreen, []))
|
|
17
|
-
const isPictureInPicture = useMediaSelector(
|
|
18
|
-
React.useCallback((state) => state.isPictureInPicture, [])
|
|
19
|
-
)
|
|
20
|
-
const buffered = useMediaSelector(React.useCallback((state) => state.buffered, []))
|
|
21
|
-
const playbackRate = useMediaSelector(React.useCallback((state) => state.playbackRate, []))
|
|
22
|
-
|
|
23
|
-
// Derived state with memoization
|
|
24
|
-
const progress = React.useMemo(() => {
|
|
25
|
-
return duration > 0 ? (currentTime / duration) * 100 : 0
|
|
26
|
-
}, [currentTime, duration])
|
|
27
|
-
|
|
28
|
-
const remainingTime = React.useMemo(() => {
|
|
29
|
-
return Math.max(0, duration - currentTime)
|
|
30
|
-
}, [duration, currentTime])
|
|
31
|
-
|
|
32
|
-
const bufferedRanges = React.useMemo(() => {
|
|
33
|
-
if (!buffered || duration === 0) return []
|
|
34
|
-
const ranges = []
|
|
35
|
-
for (let i = 0; i < buffered.length; i++) {
|
|
36
|
-
ranges.push({
|
|
37
|
-
start: (buffered.start(i) / duration) * 100,
|
|
38
|
-
end: (buffered.end(i) / duration) * 100
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
return ranges
|
|
42
|
-
}, [buffered, duration])
|
|
43
|
-
|
|
44
|
-
const canPlay = React.useMemo(() => {
|
|
45
|
-
return !isLoading && !error && duration > 0
|
|
46
|
-
}, [isLoading, error, duration])
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
// Basic state
|
|
50
|
-
isPlaying,
|
|
51
|
-
currentTime,
|
|
52
|
-
duration,
|
|
53
|
-
volume,
|
|
54
|
-
isMuted,
|
|
55
|
-
isLoading,
|
|
56
|
-
error,
|
|
57
|
-
isFullscreen,
|
|
58
|
-
isPictureInPicture,
|
|
59
|
-
buffered,
|
|
60
|
-
playbackRate,
|
|
61
|
-
|
|
62
|
-
// Derived state
|
|
63
|
-
progress,
|
|
64
|
-
remainingTime,
|
|
65
|
-
bufferedRanges,
|
|
66
|
-
canPlay
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Optimized hook for media controls with memoized callbacks
|
|
71
|
-
export function useOptimizedMediaControls() {
|
|
72
|
-
const dispatch = useMediaDispatch()
|
|
73
|
-
|
|
74
|
-
// Memoized control functions
|
|
75
|
-
const play = React.useCallback(() => {
|
|
76
|
-
dispatch({ type: MediaActionTypes.PLAY })
|
|
77
|
-
}, [dispatch])
|
|
78
|
-
|
|
79
|
-
const pause = React.useCallback(() => {
|
|
80
|
-
dispatch({ type: MediaActionTypes.PAUSE })
|
|
81
|
-
}, [dispatch])
|
|
82
|
-
|
|
83
|
-
const toggle = React.useCallback(() => {
|
|
84
|
-
dispatch({ type: MediaActionTypes.PLAY })
|
|
85
|
-
}, [dispatch])
|
|
86
|
-
|
|
87
|
-
const seek = React.useCallback(
|
|
88
|
-
(time: number) => {
|
|
89
|
-
dispatch({ type: MediaActionTypes.SEEK, detail: time })
|
|
90
|
-
},
|
|
91
|
-
[dispatch]
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
const setVolume = React.useCallback(
|
|
95
|
-
(volume: number) => {
|
|
96
|
-
dispatch({ type: MediaActionTypes.SET_VOLUME, detail: volume })
|
|
97
|
-
},
|
|
98
|
-
[dispatch]
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
const mute = React.useCallback(() => {
|
|
102
|
-
dispatch({ type: MediaActionTypes.MUTE })
|
|
103
|
-
}, [dispatch])
|
|
104
|
-
|
|
105
|
-
const unmute = React.useCallback(() => {
|
|
106
|
-
dispatch({ type: MediaActionTypes.UNMUTE })
|
|
107
|
-
}, [dispatch])
|
|
108
|
-
|
|
109
|
-
const toggleMute = React.useCallback(() => {
|
|
110
|
-
dispatch({ type: MediaActionTypes.TOGGLE_MUTE })
|
|
111
|
-
}, [dispatch])
|
|
112
|
-
|
|
113
|
-
const enterFullscreen = React.useCallback(() => {
|
|
114
|
-
dispatch({ type: MediaActionTypes.ENTER_FULLSCREEN })
|
|
115
|
-
}, [dispatch])
|
|
116
|
-
|
|
117
|
-
const exitFullscreen = React.useCallback(() => {
|
|
118
|
-
dispatch({ type: MediaActionTypes.EXIT_FULLSCREEN })
|
|
119
|
-
}, [dispatch])
|
|
120
|
-
|
|
121
|
-
const toggleFullscreen = React.useCallback(() => {
|
|
122
|
-
dispatch({ type: MediaActionTypes.ENTER_FULLSCREEN })
|
|
123
|
-
}, [dispatch])
|
|
124
|
-
|
|
125
|
-
const enterPictureInPicture = React.useCallback(() => {
|
|
126
|
-
dispatch({ type: MediaActionTypes.ENTER_PIP })
|
|
127
|
-
}, [dispatch])
|
|
128
|
-
|
|
129
|
-
const exitPictureInPicture = React.useCallback(() => {
|
|
130
|
-
dispatch({ type: MediaActionTypes.EXIT_PIP })
|
|
131
|
-
}, [dispatch])
|
|
132
|
-
|
|
133
|
-
const togglePictureInPicture = React.useCallback(() => {
|
|
134
|
-
dispatch({ type: MediaActionTypes.ENTER_PIP })
|
|
135
|
-
}, [dispatch])
|
|
136
|
-
|
|
137
|
-
const setPlaybackRate = React.useCallback(
|
|
138
|
-
(rate: number) => {
|
|
139
|
-
dispatch({ type: MediaActionTypes.SET_PLAYBACK_RATE, detail: rate })
|
|
140
|
-
},
|
|
141
|
-
[dispatch]
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
const skipForward = React.useCallback(
|
|
145
|
-
(seconds: number = 10) => {
|
|
146
|
-
dispatch({ type: MediaActionTypes.SEEK, detail: seconds })
|
|
147
|
-
},
|
|
148
|
-
[dispatch]
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
const skipBackward = React.useCallback(
|
|
152
|
-
(seconds: number = 10) => {
|
|
153
|
-
dispatch({ type: MediaActionTypes.SEEK, detail: -seconds })
|
|
154
|
-
},
|
|
155
|
-
[dispatch]
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
play,
|
|
160
|
-
pause,
|
|
161
|
-
toggle,
|
|
162
|
-
seek,
|
|
163
|
-
setVolume,
|
|
164
|
-
mute,
|
|
165
|
-
unmute,
|
|
166
|
-
toggleMute,
|
|
167
|
-
enterFullscreen,
|
|
168
|
-
exitFullscreen,
|
|
169
|
-
toggleFullscreen,
|
|
170
|
-
enterPictureInPicture,
|
|
171
|
-
exitPictureInPicture,
|
|
172
|
-
togglePictureInPicture,
|
|
173
|
-
setPlaybackRate,
|
|
174
|
-
skipForward,
|
|
175
|
-
skipBackward
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Hook for debounced seek operations
|
|
180
|
-
export function useDebouncedSeek(delay: number = 100) {
|
|
181
|
-
const dispatch = useMediaDispatch()
|
|
182
|
-
const timeoutRef = React.useRef<NodeJS.Timeout | null>(null)
|
|
183
|
-
|
|
184
|
-
const debouncedSeek = React.useCallback(
|
|
185
|
-
(time: number) => {
|
|
186
|
-
if (timeoutRef.current) {
|
|
187
|
-
clearTimeout(timeoutRef.current)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
timeoutRef.current = setTimeout(() => {
|
|
191
|
-
dispatch({ type: MediaActionTypes.SEEK, detail: time })
|
|
192
|
-
}, delay)
|
|
193
|
-
},
|
|
194
|
-
[dispatch, delay]
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
React.useEffect(() => {
|
|
198
|
-
return () => {
|
|
199
|
-
if (timeoutRef.current) {
|
|
200
|
-
clearTimeout(timeoutRef.current)
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}, [])
|
|
204
|
-
|
|
205
|
-
return debouncedSeek
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Hook for throttled volume changes
|
|
209
|
-
export function useThrottledVolume(delay: number = 50) {
|
|
210
|
-
const dispatch = useMediaDispatch()
|
|
211
|
-
const lastUpdateRef = React.useRef<number>(0)
|
|
212
|
-
|
|
213
|
-
const throttledSetVolume = React.useCallback(
|
|
214
|
-
(volume: number) => {
|
|
215
|
-
const now = Date.now()
|
|
216
|
-
if (now - lastUpdateRef.current >= delay) {
|
|
217
|
-
dispatch({ type: MediaActionTypes.SET_VOLUME, detail: volume })
|
|
218
|
-
lastUpdateRef.current = now
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
[dispatch, delay]
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
return throttledSetVolume
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Hook for optimized time formatting
|
|
228
|
-
export function useFormattedTime(time: number) {
|
|
229
|
-
return React.useMemo(() => {
|
|
230
|
-
const hours = Math.floor(time / 3600)
|
|
231
|
-
const minutes = Math.floor((time % 3600) / 60)
|
|
232
|
-
const seconds = Math.floor(time % 60)
|
|
233
|
-
|
|
234
|
-
if (hours > 0) {
|
|
235
|
-
return `${hours}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`
|
|
236
|
-
}
|
|
237
|
-
return `${minutes}:${seconds.toString().padStart(2, "0")}`
|
|
238
|
-
}, [time])
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Hook for intersection observer (for lazy loading)
|
|
242
|
-
export function useIntersectionObserver(
|
|
243
|
-
elementRef: React.RefObject<Element>,
|
|
244
|
-
options?: IntersectionObserverInit
|
|
245
|
-
) {
|
|
246
|
-
const [isIntersecting, setIsIntersecting] = React.useState(false)
|
|
247
|
-
|
|
248
|
-
React.useEffect(() => {
|
|
249
|
-
const element = elementRef.current
|
|
250
|
-
if (!element) return
|
|
251
|
-
|
|
252
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
253
|
-
setIsIntersecting(entry?.isIntersecting ?? false)
|
|
254
|
-
}, options)
|
|
255
|
-
|
|
256
|
-
observer.observe(element)
|
|
257
|
-
|
|
258
|
-
return () => {
|
|
259
|
-
observer.unobserve(element)
|
|
260
|
-
}
|
|
261
|
-
}, [elementRef, options])
|
|
262
|
-
|
|
263
|
-
return isIntersecting
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Hook for media queries (responsive behavior)
|
|
267
|
-
export function useMediaQuery(query: string) {
|
|
268
|
-
const [matches, setMatches] = React.useState(false)
|
|
269
|
-
|
|
270
|
-
React.useEffect(() => {
|
|
271
|
-
const mediaQuery = window.matchMedia(query)
|
|
272
|
-
setMatches(mediaQuery.matches)
|
|
273
|
-
|
|
274
|
-
const handler = (event: MediaQueryListEvent) => {
|
|
275
|
-
setMatches(event.matches)
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
mediaQuery.addEventListener("change", handler)
|
|
279
|
-
return () => mediaQuery.removeEventListener("change", handler)
|
|
280
|
-
}, [query])
|
|
281
|
-
|
|
282
|
-
return matches
|
|
283
|
-
}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from "react"
|
|
2
|
-
import type { RefObject } from "react"
|
|
3
|
-
|
|
4
|
-
export interface PreloadSource {
|
|
5
|
-
src: string
|
|
6
|
-
type: string
|
|
7
|
-
priority: number
|
|
8
|
-
preloadedAt?: number
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface UseSmartPreloadOptions {
|
|
12
|
-
enabled?: boolean
|
|
13
|
-
maxConcurrent?: number
|
|
14
|
-
preloadAheadTime?: number
|
|
15
|
-
onPreloadComplete?: (src: string) => void
|
|
16
|
-
onPreloadError?: (src: string, error: Error) => void
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface UseSmartPreloadReturn {
|
|
20
|
-
preload: (src: string, type: string, priority?: number) => Promise<void>
|
|
21
|
-
preloadSources: (sources: PreloadSource[]) => Promise<void>
|
|
22
|
-
cancelPreload: (src: string) => void
|
|
23
|
-
cancelAllPreloads: () => void
|
|
24
|
-
isPreloading: (src: string) => boolean
|
|
25
|
-
getPreloadProgress: (src: string) => number | null
|
|
26
|
-
preloadQueue: PreloadSource[]
|
|
27
|
-
preloadedSources: string[]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const DEFAULT_OPTIONS: UseSmartPreloadOptions = {
|
|
31
|
-
enabled: true,
|
|
32
|
-
maxConcurrent: 2,
|
|
33
|
-
preloadAheadTime: 30,
|
|
34
|
-
onPreloadComplete: undefined,
|
|
35
|
-
onPreloadError: undefined
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function useSmartPreload(options: UseSmartPreloadOptions = {}): UseSmartPreloadReturn {
|
|
39
|
-
const opts = { ...DEFAULT_OPTIONS, ...options }
|
|
40
|
-
const [preloadQueue, setPreloadQueue] = useState<PreloadSource[]>([])
|
|
41
|
-
const [preloadedSources, setPreloadedSources] = useState<string[]>([])
|
|
42
|
-
const [inProgress, setInProgress] = useState<Map<string, Promise<void>>>(new Map())
|
|
43
|
-
const progressRef = useRef<Map<string, number>>(new Map())
|
|
44
|
-
const activeCountRef = useRef(0)
|
|
45
|
-
|
|
46
|
-
const preloadFile = useCallback(
|
|
47
|
-
async (source: PreloadSource): Promise<void> => {
|
|
48
|
-
const { src, type } = source
|
|
49
|
-
|
|
50
|
-
if (inProgress.has(src)) {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
progressRef.current.set(src, 0)
|
|
55
|
-
|
|
56
|
-
const preloadPromise = (async () => {
|
|
57
|
-
try {
|
|
58
|
-
const response = await fetch(src, {
|
|
59
|
-
method: "HEAD"
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
if (!response.ok) {
|
|
63
|
-
throw new Error(`Failed to preload: ${response.status}`)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
progressRef.current.set(src, 100)
|
|
67
|
-
setPreloadedSources((prev) => [...prev, src])
|
|
68
|
-
opts.onPreloadComplete?.(src)
|
|
69
|
-
} catch (error) {
|
|
70
|
-
progressRef.current.delete(src)
|
|
71
|
-
opts.onPreloadError?.(src, error as Error)
|
|
72
|
-
throw error
|
|
73
|
-
} finally {
|
|
74
|
-
setInProgress((prev) => {
|
|
75
|
-
const next = new Map(prev)
|
|
76
|
-
next.delete(src)
|
|
77
|
-
return next
|
|
78
|
-
})
|
|
79
|
-
activeCountRef.current--
|
|
80
|
-
}
|
|
81
|
-
})()
|
|
82
|
-
|
|
83
|
-
setInProgress((prev) => new Map(prev).set(src, preloadPromise))
|
|
84
|
-
activeCountRef.current++
|
|
85
|
-
|
|
86
|
-
return preloadPromise
|
|
87
|
-
},
|
|
88
|
-
[opts]
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
const processQueue = useCallback(() => {
|
|
92
|
-
setPreloadQueue((currentQueue) => {
|
|
93
|
-
if (currentQueue.length === 0 || activeCountRef.current >= (opts.maxConcurrent || 2)) {
|
|
94
|
-
return currentQueue
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const nextQueue = [...currentQueue]
|
|
98
|
-
const toPreload: PreloadSource[] = []
|
|
99
|
-
const remaining: PreloadSource[] = []
|
|
100
|
-
|
|
101
|
-
for (const source of nextQueue) {
|
|
102
|
-
if (toPreload.length < (opts.maxConcurrent || 2) - activeCountRef.current) {
|
|
103
|
-
if (!inProgress.has(source.src)) {
|
|
104
|
-
toPreload.push({ ...source, preloadedAt: Date.now() })
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
remaining.push(source)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
toPreload.forEach((source) => {
|
|
112
|
-
preloadFile(source).catch(() => {})
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
return remaining
|
|
116
|
-
})
|
|
117
|
-
}, [opts.maxConcurrent, preloadFile, inProgress])
|
|
118
|
-
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
processQueue()
|
|
121
|
-
}, [preloadQueue.length, inProgress.size])
|
|
122
|
-
|
|
123
|
-
const preload = useCallback(
|
|
124
|
-
async (src: string, type: string, priority = 0): Promise<void> => {
|
|
125
|
-
if (!opts.enabled) return
|
|
126
|
-
|
|
127
|
-
const newSource: PreloadSource = { src, type, priority }
|
|
128
|
-
|
|
129
|
-
setPreloadQueue((current) => {
|
|
130
|
-
const existing = current.find((s) => s.src === src)
|
|
131
|
-
if (existing) {
|
|
132
|
-
if (priority > existing.priority) {
|
|
133
|
-
return current.map((s) => (s.src === src ? { ...s, priority } : s))
|
|
134
|
-
}
|
|
135
|
-
return current
|
|
136
|
-
}
|
|
137
|
-
return [...current, newSource].sort((a, b) => b.priority - a.priority)
|
|
138
|
-
})
|
|
139
|
-
},
|
|
140
|
-
[opts.enabled, opts.preloadAheadTime]
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
const preloadSources = useCallback(
|
|
144
|
-
async (sources: PreloadSource[]): Promise<void> => {
|
|
145
|
-
const sorted = [...sources].sort((a, b) => b.priority - a.priority)
|
|
146
|
-
|
|
147
|
-
for (const source of sorted) {
|
|
148
|
-
await preload(source.src, source.type, source.priority)
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
[preload]
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
const cancelPreload = useCallback((src: string) => {
|
|
155
|
-
setPreloadQueue((current) => current.filter((s) => s.src !== src))
|
|
156
|
-
setInProgress((prev) => {
|
|
157
|
-
const next = new Map(prev)
|
|
158
|
-
next.delete(src)
|
|
159
|
-
return next
|
|
160
|
-
})
|
|
161
|
-
progressRef.current.delete(src)
|
|
162
|
-
}, [])
|
|
163
|
-
|
|
164
|
-
const cancelAllPreloads = useCallback(() => {
|
|
165
|
-
setPreloadQueue([])
|
|
166
|
-
setInProgress(new Map())
|
|
167
|
-
setPreloadedSources([])
|
|
168
|
-
progressRef.current.clear()
|
|
169
|
-
activeCountRef.current = 0
|
|
170
|
-
}, [])
|
|
171
|
-
|
|
172
|
-
const isPreloading = useCallback(
|
|
173
|
-
(src: string): boolean => {
|
|
174
|
-
return inProgress.has(src)
|
|
175
|
-
},
|
|
176
|
-
[inProgress]
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
const getPreloadProgress = useCallback((src: string): number | null => {
|
|
180
|
-
return progressRef.current.get(src) || null
|
|
181
|
-
}, [])
|
|
182
|
-
|
|
183
|
-
return {
|
|
184
|
-
preload,
|
|
185
|
-
preloadSources,
|
|
186
|
-
cancelPreload,
|
|
187
|
-
cancelAllPreloads,
|
|
188
|
-
isPreloading,
|
|
189
|
-
getPreloadProgress,
|
|
190
|
-
preloadQueue,
|
|
191
|
-
preloadedSources
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export function usePreloadOnVisibility(
|
|
196
|
-
videoRef: RefObject<HTMLVideoElement | HTMLAudioElement>,
|
|
197
|
-
sources: PreloadSource[],
|
|
198
|
-
options?: UseSmartPreloadOptions
|
|
199
|
-
) {
|
|
200
|
-
const smartPreload = useSmartPreload(options)
|
|
201
|
-
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
if (!videoRef.current) return
|
|
204
|
-
|
|
205
|
-
const video = videoRef.current
|
|
206
|
-
|
|
207
|
-
const handleCanPlay = () => {
|
|
208
|
-
if (video.buffered.length > 0) {
|
|
209
|
-
const bufferedEnd = video.buffered.end(video.buffered.length - 1)
|
|
210
|
-
const remaining = video.duration - video.currentTime
|
|
211
|
-
|
|
212
|
-
if (remaining < (options?.preloadAheadTime || 30)) {
|
|
213
|
-
const nextSources = sources.filter(
|
|
214
|
-
(s) => !smartPreload.isPreloading(s.src) && !smartPreload.getPreloadProgress(s.src)
|
|
215
|
-
)
|
|
216
|
-
smartPreload.preloadSources(nextSources)
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
video.addEventListener("canplay", handleCanPlay)
|
|
222
|
-
|
|
223
|
-
return () => {
|
|
224
|
-
video.removeEventListener("canplay", handleCanPlay)
|
|
225
|
-
}
|
|
226
|
-
}, [videoRef, sources, options, smartPreload])
|
|
227
|
-
|
|
228
|
-
return smartPreload
|
|
229
|
-
}
|