@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,470 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useRef, useState, useCallback } from "react"
|
|
4
|
-
import "../styles/videojs.css"
|
|
5
|
-
import type VideoJsPlayer from "video.js/dist/types/player"
|
|
6
|
-
import { MediaActionTypes, useMediaContext, useMediaDispatch } from "../context/media-context"
|
|
7
|
-
import { cn } from "../lib/utils"
|
|
8
|
-
|
|
9
|
-
// Lazy load Video.js and HLS.js for better performance
|
|
10
|
-
let videojs: any = null
|
|
11
|
-
let Hls: any = null
|
|
12
|
-
|
|
13
|
-
async function loadVideoJS() {
|
|
14
|
-
if (!videojs) {
|
|
15
|
-
const [videojsModule, hlsModule] = await Promise.all([import("video.js"), import("hls.js")])
|
|
16
|
-
videojs = videojsModule.default
|
|
17
|
-
Hls = hlsModule.default
|
|
18
|
-
|
|
19
|
-
// Import plugins after Video.js is loaded
|
|
20
|
-
await Promise.all([
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
import("@videojs/http-streaming"),
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
import("videojs-contrib-quality-levels"),
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
import("videojs-hls-quality-selector")
|
|
27
|
-
])
|
|
28
|
-
}
|
|
29
|
-
return { videojs, Hls }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface VideoSource {
|
|
33
|
-
src: string
|
|
34
|
-
type: string
|
|
35
|
-
label?: string
|
|
36
|
-
selected?: boolean
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface TextTrack {
|
|
40
|
-
src: string
|
|
41
|
-
kind: "subtitles" | "captions" | "descriptions" | "chapters" | "metadata"
|
|
42
|
-
srclang: string
|
|
43
|
-
label: string
|
|
44
|
-
default?: boolean
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface VideoJSAdapterProps {
|
|
48
|
-
sources: VideoSource[]
|
|
49
|
-
poster?: string
|
|
50
|
-
textTracks?: TextTrack[]
|
|
51
|
-
autoplay?: boolean
|
|
52
|
-
muted?: boolean
|
|
53
|
-
controls?: boolean
|
|
54
|
-
preload?: "auto" | "metadata" | "none"
|
|
55
|
-
fluid?: boolean
|
|
56
|
-
responsive?: boolean
|
|
57
|
-
playbackRates?: number[]
|
|
58
|
-
className?: string
|
|
59
|
-
onReady?: (player: VideoJsPlayer) => void
|
|
60
|
-
onError?: (error: any) => void
|
|
61
|
-
hlsConfig?: any // HLS.js config
|
|
62
|
-
enableQualitySelector?: boolean
|
|
63
|
-
enableSubtitles?: boolean
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function VideoJSAdapter({
|
|
67
|
-
sources,
|
|
68
|
-
poster,
|
|
69
|
-
textTracks = [],
|
|
70
|
-
autoplay = false,
|
|
71
|
-
muted = false,
|
|
72
|
-
controls = false,
|
|
73
|
-
preload = "metadata",
|
|
74
|
-
fluid = true,
|
|
75
|
-
responsive = true,
|
|
76
|
-
playbackRates = [0.5, 0.75, 1, 1.25, 1.5, 2],
|
|
77
|
-
className,
|
|
78
|
-
onReady,
|
|
79
|
-
onError,
|
|
80
|
-
hlsConfig = {},
|
|
81
|
-
enableQualitySelector = true,
|
|
82
|
-
enableSubtitles = true
|
|
83
|
-
}: VideoJSAdapterProps) {
|
|
84
|
-
const videoRef = useRef<HTMLVideoElement>(null)
|
|
85
|
-
const playerRef = useRef<VideoJsPlayer | null>(null)
|
|
86
|
-
const hlsRef = useRef<any | null>(null) // HLS.js instance
|
|
87
|
-
const [isLoading, setIsLoading] = useState(true)
|
|
88
|
-
const [error, setError] = useState<string | null>(null)
|
|
89
|
-
|
|
90
|
-
const context = useMediaContext()
|
|
91
|
-
const dispatch = useMediaDispatch()
|
|
92
|
-
|
|
93
|
-
// Initialize Video.js player
|
|
94
|
-
const initializePlayer = async () => {
|
|
95
|
-
if (!videoRef.current || playerRef.current) return
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
setIsLoading(true)
|
|
99
|
-
const { videojs, Hls: HlsLib } = await loadVideoJS()
|
|
100
|
-
|
|
101
|
-
// Check if we need HLS.js (for non-Safari browsers)
|
|
102
|
-
const needsHlsJs =
|
|
103
|
-
sources.some((s) => s.type === "application/x-mpegURL") &&
|
|
104
|
-
!videoRef.current.canPlayType("application/vnd.apple.mpegurl")
|
|
105
|
-
|
|
106
|
-
// Video.js options
|
|
107
|
-
const options: any = {
|
|
108
|
-
autoplay,
|
|
109
|
-
muted,
|
|
110
|
-
controls,
|
|
111
|
-
preload,
|
|
112
|
-
fluid,
|
|
113
|
-
responsive,
|
|
114
|
-
playbackRates,
|
|
115
|
-
sources: needsHlsJs ? [] : sources, // Don't set sources if using HLS.js
|
|
116
|
-
poster,
|
|
117
|
-
html5: {
|
|
118
|
-
vhs: {
|
|
119
|
-
// Video.js HTTP Streaming options
|
|
120
|
-
overrideNative: !videoRef.current.canPlayType("application/vnd.apple.mpegurl"),
|
|
121
|
-
enableLowInitialPlaylist: true,
|
|
122
|
-
fastQualityChange: true,
|
|
123
|
-
handleManifestRedirects: true
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Create Video.js player
|
|
129
|
-
const player = videojs(videoRef.current, options, function () {
|
|
130
|
-
console.log("Video.js player ready")
|
|
131
|
-
}) as VideoJsPlayer
|
|
132
|
-
|
|
133
|
-
playerRef.current = player
|
|
134
|
-
|
|
135
|
-
// Add text tracks
|
|
136
|
-
textTracks.forEach((track) => {
|
|
137
|
-
player.addRemoteTextTrack(
|
|
138
|
-
{
|
|
139
|
-
kind: track.kind,
|
|
140
|
-
src: track.src,
|
|
141
|
-
srclang: track.srclang,
|
|
142
|
-
label: track.label,
|
|
143
|
-
default: track.default
|
|
144
|
-
},
|
|
145
|
-
false
|
|
146
|
-
)
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
// Setup HLS.js for non-Safari browsers if needed
|
|
150
|
-
if (needsHlsJs) {
|
|
151
|
-
const hlsSource = sources.find((s) => s.type === "application/x-mpegURL")
|
|
152
|
-
if (hlsSource) {
|
|
153
|
-
const hls = new HlsLib({
|
|
154
|
-
debug: false,
|
|
155
|
-
enableWorker: true,
|
|
156
|
-
lowLatencyMode: false,
|
|
157
|
-
backBufferLength: 30,
|
|
158
|
-
maxBufferLength: 30,
|
|
159
|
-
maxMaxBufferLength: 600,
|
|
160
|
-
maxBufferSize: 60 * 1000 * 1000,
|
|
161
|
-
maxBufferHole: 0.1,
|
|
162
|
-
highBufferWatchdogPeriod: 2,
|
|
163
|
-
// ABR settings
|
|
164
|
-
abrEwmaFastLive: 3.0,
|
|
165
|
-
abrEwmaSlowLive: 9.0,
|
|
166
|
-
abrEwmaFastVoD: 3.0,
|
|
167
|
-
abrEwmaSlowVoD: 9.0,
|
|
168
|
-
abrEwmaDefaultEstimate: 500000,
|
|
169
|
-
abrBandWidthFactor: 0.95,
|
|
170
|
-
abrBandWidthUpFactor: 0.7,
|
|
171
|
-
abrMaxWithRealBitrate: false,
|
|
172
|
-
maxStarvationDelay: 4,
|
|
173
|
-
maxLoadingDelay: 4,
|
|
174
|
-
capLevelToPlayerSize: true,
|
|
175
|
-
capLevelOnFPSDrop: true,
|
|
176
|
-
// Subtitle settings
|
|
177
|
-
renderTextTracksNatively: false,
|
|
178
|
-
subtitlePreference: {
|
|
179
|
-
lang: navigator.language.split("-")[0],
|
|
180
|
-
forced: false
|
|
181
|
-
},
|
|
182
|
-
...hlsConfig
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
hlsRef.current = hls
|
|
186
|
-
|
|
187
|
-
// Attach HLS to video element
|
|
188
|
-
hls.loadSource(hlsSource.src)
|
|
189
|
-
hls.attachMedia(videoRef.current)
|
|
190
|
-
|
|
191
|
-
// HLS.js event handlers
|
|
192
|
-
hls.on(HlsLib.Events.MANIFEST_PARSED, () => {
|
|
193
|
-
console.log("HLS manifest parsed", {
|
|
194
|
-
levels: hls.levels.map((l: any) => ({
|
|
195
|
-
height: l.height,
|
|
196
|
-
bitrate: l.bitrate,
|
|
197
|
-
codec: l.codecSet
|
|
198
|
-
}))
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
// Add quality levels to Video.js
|
|
202
|
-
if (enableQualitySelector && (player as any).qualityLevels) {
|
|
203
|
-
const qualityLevels = (player as any).qualityLevels()
|
|
204
|
-
|
|
205
|
-
hls.levels.forEach((level: any, index: number) => {
|
|
206
|
-
qualityLevels.addQualityLevel({
|
|
207
|
-
id: index.toString(),
|
|
208
|
-
label: `${level.height}p`,
|
|
209
|
-
width: level.width,
|
|
210
|
-
height: level.height,
|
|
211
|
-
bitrate: level.bitrate,
|
|
212
|
-
enabled: true
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
hls.on(HlsLib.Events.LEVEL_SWITCHED, (_event: any, data: any) => {
|
|
219
|
-
console.log(`HLS quality switched to level ${data.level}`)
|
|
220
|
-
dispatch({
|
|
221
|
-
type: MediaActionTypes.SET_QUALITY_LEVEL,
|
|
222
|
-
detail: data.level
|
|
223
|
-
})
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
hls.on(HlsLib.Events.ERROR, (_event: any, data: any) => {
|
|
227
|
-
if (data.fatal) {
|
|
228
|
-
switch (data.type) {
|
|
229
|
-
case HlsLib.ErrorTypes.NETWORK_ERROR:
|
|
230
|
-
console.error("Fatal network error encountered, try to recover")
|
|
231
|
-
hls.startLoad()
|
|
232
|
-
break
|
|
233
|
-
case HlsLib.ErrorTypes.MEDIA_ERROR:
|
|
234
|
-
console.error("Fatal media error encountered, try to recover")
|
|
235
|
-
hls.recoverMediaError()
|
|
236
|
-
break
|
|
237
|
-
default:
|
|
238
|
-
console.error("Fatal error, cannot recover")
|
|
239
|
-
setError("Streaming error occurred")
|
|
240
|
-
onError?.(data)
|
|
241
|
-
hls.destroy()
|
|
242
|
-
break
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
// Update bandwidth estimate in context
|
|
248
|
-
hls.on(HlsLib.Events.FRAG_LOADED, () => {
|
|
249
|
-
const estimate = hls.bandwidthEstimate
|
|
250
|
-
if (estimate) {
|
|
251
|
-
dispatch({
|
|
252
|
-
type: MediaActionTypes.SET_BANDWIDTH_ESTIMATE,
|
|
253
|
-
detail: estimate
|
|
254
|
-
})
|
|
255
|
-
}
|
|
256
|
-
})
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// Enable quality selector plugin
|
|
261
|
-
if (enableQualitySelector && (player as any).qualityLevels) {
|
|
262
|
-
;(player as any).hlsQualitySelector({
|
|
263
|
-
displayCurrentQuality: true
|
|
264
|
-
})
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Video.js event handlers to sync with MediaContext
|
|
268
|
-
player.on("play", () => {
|
|
269
|
-
dispatch({ type: MediaActionTypes.PLAY })
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
player.on("pause", () => {
|
|
273
|
-
dispatch({ type: MediaActionTypes.PAUSE })
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
player.on("timeupdate", () => {
|
|
277
|
-
dispatch({
|
|
278
|
-
type: MediaActionTypes.SET_CURRENT_TIME,
|
|
279
|
-
detail: player.currentTime() || 0
|
|
280
|
-
})
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
player.on("durationchange", () => {
|
|
284
|
-
dispatch({
|
|
285
|
-
type: MediaActionTypes.SET_DURATION,
|
|
286
|
-
detail: player.duration() || 0
|
|
287
|
-
})
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
player.on("volumechange", () => {
|
|
291
|
-
dispatch({
|
|
292
|
-
type: MediaActionTypes.SET_VOLUME,
|
|
293
|
-
detail: player.volume() || 0
|
|
294
|
-
})
|
|
295
|
-
dispatch({
|
|
296
|
-
type: player.muted() ? MediaActionTypes.MUTE : MediaActionTypes.UNMUTE
|
|
297
|
-
})
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
player.on("ended", () => {
|
|
301
|
-
dispatch({ type: MediaActionTypes.PAUSE })
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
player.on("error", (e: any) => {
|
|
305
|
-
const error = player.error()
|
|
306
|
-
setError(error?.message || "An error occurred")
|
|
307
|
-
dispatch({
|
|
308
|
-
type: MediaActionTypes.SET_ERROR,
|
|
309
|
-
detail: error?.message || "Playback error"
|
|
310
|
-
})
|
|
311
|
-
onError?.(error)
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
player.on("loadstart", () => {
|
|
315
|
-
dispatch({ type: MediaActionTypes.SET_LOADING, detail: true })
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
player.on("loadeddata", () => {
|
|
319
|
-
setIsLoading(false)
|
|
320
|
-
dispatch({ type: MediaActionTypes.SET_LOADING, detail: false })
|
|
321
|
-
})
|
|
322
|
-
|
|
323
|
-
player.on("waiting", () => {
|
|
324
|
-
dispatch({ type: MediaActionTypes.SET_BUFFERING, detail: true })
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
player.on("playing", () => {
|
|
328
|
-
dispatch({ type: MediaActionTypes.SET_BUFFERING, detail: false })
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
// Text track changes
|
|
332
|
-
player.on("texttrackchange", () => {
|
|
333
|
-
const tracks = player.textTracks() as any
|
|
334
|
-
const activeTracks: any[] = []
|
|
335
|
-
|
|
336
|
-
if (tracks && tracks.length) {
|
|
337
|
-
for (let i = 0; i < tracks.length; i++) {
|
|
338
|
-
const track = tracks[i]
|
|
339
|
-
if (track.mode === "showing") {
|
|
340
|
-
activeTracks.push({
|
|
341
|
-
id: track.id,
|
|
342
|
-
label: track.label,
|
|
343
|
-
language: track.language,
|
|
344
|
-
kind: track.kind
|
|
345
|
-
})
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
dispatch({
|
|
351
|
-
type: MediaActionTypes.SET_ACTIVE_TEXT_TRACKS,
|
|
352
|
-
detail: activeTracks
|
|
353
|
-
})
|
|
354
|
-
})
|
|
355
|
-
|
|
356
|
-
// Update media ref in context for gesture/keyboard controls
|
|
357
|
-
if (context.mediaRef) {
|
|
358
|
-
context.mediaRef.current = videoRef.current
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
onReady?.(player)
|
|
362
|
-
setIsLoading(false)
|
|
363
|
-
} catch (err) {
|
|
364
|
-
console.error("Failed to initialize Video.js player:", err)
|
|
365
|
-
setError("Failed to initialize player")
|
|
366
|
-
setIsLoading(false)
|
|
367
|
-
onError?.(err)
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// Cleanup on unmount
|
|
372
|
-
useEffect(() => {
|
|
373
|
-
initializePlayer()
|
|
374
|
-
|
|
375
|
-
return () => {
|
|
376
|
-
if (hlsRef.current) {
|
|
377
|
-
hlsRef.current.destroy()
|
|
378
|
-
hlsRef.current = null
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (playerRef.current) {
|
|
382
|
-
playerRef.current.dispose()
|
|
383
|
-
playerRef.current = null
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}, [initializePlayer])
|
|
387
|
-
|
|
388
|
-
// Expose player methods to MediaContext
|
|
389
|
-
useEffect(() => {
|
|
390
|
-
if (!playerRef.current || !context.mediaRef) return
|
|
391
|
-
|
|
392
|
-
// Create a proxy object that bridges Video.js methods to native HTMLVideoElement methods
|
|
393
|
-
const proxyMethods = {
|
|
394
|
-
play: () => playerRef.current?.play(),
|
|
395
|
-
pause: () => playerRef.current?.pause(),
|
|
396
|
-
seekTo: (time: number) => {
|
|
397
|
-
if (playerRef.current) {
|
|
398
|
-
playerRef.current.currentTime(time)
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
setVolume: (volume: number) => {
|
|
402
|
-
if (playerRef.current) {
|
|
403
|
-
playerRef.current.volume(volume)
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
setMuted: (muted: boolean) => {
|
|
407
|
-
if (playerRef.current) {
|
|
408
|
-
playerRef.current.muted(muted)
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
setQualityLevel: (level: number) => {
|
|
412
|
-
if (hlsRef.current) {
|
|
413
|
-
hlsRef.current.currentLevel = level
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
getQualityLevels: () => {
|
|
417
|
-
if (hlsRef.current) {
|
|
418
|
-
return hlsRef.current.levels
|
|
419
|
-
}
|
|
420
|
-
return []
|
|
421
|
-
},
|
|
422
|
-
getCurrentQualityLevel: () => {
|
|
423
|
-
if (hlsRef.current) {
|
|
424
|
-
return hlsRef.current.currentLevel
|
|
425
|
-
}
|
|
426
|
-
return -1
|
|
427
|
-
},
|
|
428
|
-
getBandwidthEstimate: () => {
|
|
429
|
-
if (hlsRef.current) {
|
|
430
|
-
return hlsRef.current.bandwidthEstimate
|
|
431
|
-
}
|
|
432
|
-
return 0
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// Attach proxy methods to video element for external access
|
|
437
|
-
if (videoRef.current) {
|
|
438
|
-
Object.assign(videoRef.current, proxyMethods)
|
|
439
|
-
}
|
|
440
|
-
}, [context.mediaRef])
|
|
441
|
-
|
|
442
|
-
return (
|
|
443
|
-
<div className={cn("relative h-full w-full", className)}>
|
|
444
|
-
<video
|
|
445
|
-
ref={videoRef}
|
|
446
|
-
className="video-js vjs-default-skin vjs-big-play-centered h-full w-full"
|
|
447
|
-
playsInline
|
|
448
|
-
/>
|
|
449
|
-
|
|
450
|
-
{isLoading && (
|
|
451
|
-
<div className="absolute inset-0 flex items-center justify-center bg-black/50">
|
|
452
|
-
<div className="text-white">
|
|
453
|
-
<div className="h-8 w-8 animate-spin rounded-full border-white border-b-2" />
|
|
454
|
-
</div>
|
|
455
|
-
</div>
|
|
456
|
-
)}
|
|
457
|
-
|
|
458
|
-
{error && (
|
|
459
|
-
<div className="absolute inset-0 flex items-center justify-center bg-black/80">
|
|
460
|
-
<div className="text-center text-white">
|
|
461
|
-
<p className="font-semibold text-lg">Error</p>
|
|
462
|
-
<p className="text-sm opacity-80">{error}</p>
|
|
463
|
-
</div>
|
|
464
|
-
</div>
|
|
465
|
-
)}
|
|
466
|
-
</div>
|
|
467
|
-
)
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
VideoJSAdapter.displayName = "VideoJSAdapter"
|
|
Binary file
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { useState, useEffect } from "react"
|
|
4
|
-
import { cn } from "../lib/utils"
|
|
5
|
-
|
|
6
|
-
// Import the GIF statically for bundling (Vite / webpack may yield string or { src })
|
|
7
|
-
import monaGifSrc from "../assets/mona-loading.gif"
|
|
8
|
-
|
|
9
|
-
function resolveAssetUrl(src: unknown): string | undefined {
|
|
10
|
-
if (typeof src === "string" && src.length > 0) return src
|
|
11
|
-
if (
|
|
12
|
-
src &&
|
|
13
|
-
typeof src === "object" &&
|
|
14
|
-
"src" in src &&
|
|
15
|
-
typeof (src as { src: unknown }).src === "string"
|
|
16
|
-
) {
|
|
17
|
-
return (src as { src: string }).src
|
|
18
|
-
}
|
|
19
|
-
return undefined
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const monaLoadingGif = resolveAssetUrl(monaGifSrc)
|
|
23
|
-
|
|
24
|
-
interface AnimateLoadingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
25
|
-
loadingText?: string
|
|
26
|
-
gifSrc?: string
|
|
27
|
-
showFallback?: boolean
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function AnimateLoading({
|
|
31
|
-
loadingText = "Loading...",
|
|
32
|
-
gifSrc,
|
|
33
|
-
showFallback = true,
|
|
34
|
-
className,
|
|
35
|
-
...props
|
|
36
|
-
}: AnimateLoadingProps) {
|
|
37
|
-
const [imageError, setImageError] = useState(false)
|
|
38
|
-
const [imageLoaded, setImageLoaded] = useState(false)
|
|
39
|
-
|
|
40
|
-
// Try multiple paths for the GIF
|
|
41
|
-
const gifPaths = [
|
|
42
|
-
gifSrc,
|
|
43
|
-
monaLoadingGif,
|
|
44
|
-
"/mona-loading.gif",
|
|
45
|
-
"./mona-loading.gif",
|
|
46
|
-
"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" // 1x1 transparent gif as last resort
|
|
47
|
-
].filter(Boolean) as string[]
|
|
48
|
-
|
|
49
|
-
const [currentGifIndex, setCurrentGifIndex] = useState(0)
|
|
50
|
-
const currentGif = gifPaths[currentGifIndex]
|
|
51
|
-
|
|
52
|
-
const handleImageError = () => {
|
|
53
|
-
if (currentGifIndex < gifPaths.length - 1) {
|
|
54
|
-
setCurrentGifIndex(currentGifIndex + 1)
|
|
55
|
-
} else {
|
|
56
|
-
setImageError(true)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Enhanced fallback CSS animation
|
|
61
|
-
const FallbackAnimation = () => (
|
|
62
|
-
<div className="relative h-12 w-12">
|
|
63
|
-
{/* Outer spinning gradient ring */}
|
|
64
|
-
<div className="absolute inset-0 animate-spin rounded-full bg-gradient-to-r from-cyan-400 via-blue-500 to-cyan-400 opacity-75" />
|
|
65
|
-
|
|
66
|
-
{/* Inner background */}
|
|
67
|
-
<div className="absolute inset-1 rounded-full bg-black/90" />
|
|
68
|
-
|
|
69
|
-
{/* Center spinning element */}
|
|
70
|
-
<div className="absolute inset-0 flex items-center justify-center">
|
|
71
|
-
<div className="relative">
|
|
72
|
-
<div className="h-8 w-8 rounded-full border-2 border-white/20" />
|
|
73
|
-
<div className="absolute inset-0 h-8 w-8 animate-spin rounded-full border-2 border-transparent border-t-cyan-400" />
|
|
74
|
-
|
|
75
|
-
{/* Pulsing dot in center */}
|
|
76
|
-
<div className="absolute inset-0 flex items-center justify-center">
|
|
77
|
-
<div className="h-2 w-2 animate-pulse rounded-full bg-cyan-400" />
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<div
|
|
86
|
-
className={cn(
|
|
87
|
-
"flex flex-col items-center justify-center space-y-2 rounded py-2 text-white",
|
|
88
|
-
className
|
|
89
|
-
)}
|
|
90
|
-
{...props}>
|
|
91
|
-
{/* Show fallback while image is loading or if error */}
|
|
92
|
-
{(!imageLoaded || imageError) && showFallback && <FallbackAnimation />}
|
|
93
|
-
|
|
94
|
-
{/* Try to load the actual GIF (hidden if not loaded) */}
|
|
95
|
-
{!imageError && currentGif && (
|
|
96
|
-
<img
|
|
97
|
-
alt="loading"
|
|
98
|
-
height={50}
|
|
99
|
-
width={50}
|
|
100
|
-
src={currentGif}
|
|
101
|
-
onError={handleImageError}
|
|
102
|
-
onLoad={() => setImageLoaded(true)}
|
|
103
|
-
className={cn("object-contain", !imageLoaded && "hidden")}
|
|
104
|
-
style={{ display: imageLoaded ? "block" : "none" }}
|
|
105
|
-
/>
|
|
106
|
-
)}
|
|
107
|
-
|
|
108
|
-
<span className="mt-2 text-sm tracking-wider">{loadingText}</span>
|
|
109
|
-
</div>
|
|
110
|
-
)
|
|
111
|
-
}
|