@therealtinhtute/baroiplayer 1.0.1 → 1.0.2

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.
Files changed (73) hide show
  1. package/dist/context/media.js +2 -0
  2. package/dist/context/media.js.map +1 -0
  3. package/dist/context/media.mjs +15 -0
  4. package/dist/context/media.mjs.map +1 -0
  5. package/dist/context/store.js +2 -0
  6. package/dist/context/store.js.map +1 -0
  7. package/dist/context/store.mjs +5 -0
  8. package/dist/context/store.mjs.map +1 -0
  9. package/dist/context-Af84FynT.js +1179 -0
  10. package/dist/context-Af84FynT.js.map +1 -0
  11. package/dist/context-CwZnPdz0.cjs +23 -0
  12. package/dist/context-CwZnPdz0.cjs.map +1 -0
  13. package/dist/core-events-B5W_j8yU.js +480 -0
  14. package/dist/core-events-B5W_j8yU.js.map +1 -0
  15. package/dist/core-events-CN0-Vhhq.cjs +2 -0
  16. package/dist/core-events-CN0-Vhhq.cjs.map +1 -0
  17. package/dist/core-plugins-Bq9KLany.js +696 -0
  18. package/dist/core-plugins-Bq9KLany.js.map +1 -0
  19. package/dist/core-plugins-CPDSHMiQ.cjs +2 -0
  20. package/dist/core-plugins-CPDSHMiQ.cjs.map +1 -0
  21. package/dist/core.js +37 -0
  22. package/dist/core.js.map +1 -0
  23. package/dist/core.mjs +1217 -0
  24. package/dist/core.mjs.map +1 -0
  25. package/dist/enhanced-components-CXnYiOt6.cjs +2 -0
  26. package/dist/enhanced-components-CXnYiOt6.cjs.map +1 -0
  27. package/dist/enhanced-components-Da0TSvKe.js +1073 -0
  28. package/dist/enhanced-components-Da0TSvKe.js.map +1 -0
  29. package/dist/hooks-BhW_i-9L.js +2013 -0
  30. package/dist/hooks-BhW_i-9L.js.map +1 -0
  31. package/dist/hooks-DTXeB5Z-.cjs +4 -0
  32. package/dist/hooks-DTXeB5Z-.cjs.map +1 -0
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js.map +1 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/minimal-components-B0bILe18.js +2002 -0
  37. package/dist/minimal-components-B0bILe18.js.map +1 -0
  38. package/dist/minimal-components-BsqodtY8.cjs +2 -0
  39. package/dist/minimal-components-BsqodtY8.cjs.map +1 -0
  40. package/dist/minimal-components.css +589 -0
  41. package/dist/mona-loading.gif +0 -0
  42. package/dist/performance-monitor--rzKTlbj.js +302 -0
  43. package/dist/performance-monitor--rzKTlbj.js.map +1 -0
  44. package/dist/performance-monitor-cjIvZE2D.cjs +2 -0
  45. package/dist/performance-monitor-cjIvZE2D.cjs.map +1 -0
  46. package/dist/src/components/AnimateLoading.tsx +1 -1
  47. package/dist/src/components/enhanced/debug-panel.tsx +1 -1
  48. package/dist/src/components/media-player.tsx +2 -2
  49. package/dist/src/components/ui/media-resource-preloader.tsx +9 -11
  50. package/dist/src/components/ui/seek-bar.tsx +1 -1
  51. package/dist/src/core/plugins/enhanced-plugin-system.ts +14 -8
  52. package/dist/src/core/providers/enhanced-hls-provider.ts +22 -53
  53. package/dist/src/hooks/use-enhanced-media-player.ts +19 -2
  54. package/dist/src/types/index.ts +40 -5
  55. package/dist/styles/minimal-player.css +589 -0
  56. package/dist/utils-Db13763z.cjs +9 -0
  57. package/dist/utils-Db13763z.cjs.map +1 -0
  58. package/dist/utils-nTO4AnHo.js +2809 -0
  59. package/dist/utils-nTO4AnHo.js.map +1 -0
  60. package/dist/utils.js +2 -0
  61. package/dist/utils.js.map +1 -0
  62. package/dist/utils.mjs +7 -0
  63. package/dist/utils.mjs.map +1 -0
  64. package/package.json +1 -1
  65. package/src/components/AnimateLoading.tsx +1 -1
  66. package/src/components/enhanced/debug-panel.tsx +1 -1
  67. package/src/components/media-player.tsx +2 -2
  68. package/src/components/ui/media-resource-preloader.tsx +9 -11
  69. package/src/components/ui/seek-bar.tsx +1 -1
  70. package/src/core/plugins/enhanced-plugin-system.ts +14 -8
  71. package/src/core/providers/enhanced-hls-provider.ts +22 -53
  72. package/src/hooks/use-enhanced-media-player.ts +19 -2
  73. package/src/types/index.ts +40 -5
@@ -34,10 +34,16 @@ export interface MediaPluginHooks {
34
34
  export abstract class EnhancedMediaPlugin extends BasePlugin {
35
35
  protected hooks: Partial<MediaPluginHooks> = {};
36
36
  protected priority: number = 0;
37
- protected middleware?: PluginMiddleware;
37
+ public middleware?: PluginMiddleware;
38
38
 
39
39
  constructor(name: string, config: any = {}) {
40
- super(name, config);
40
+ super({
41
+ name,
42
+ version: config.version || '1.0.0',
43
+ description: config.description || '',
44
+ category: config.category || 'general',
45
+ priority: config.priority || 0
46
+ });
41
47
  this.priority = config.priority || 0;
42
48
  this.setupHooks();
43
49
  }
@@ -119,7 +125,7 @@ export class EnhancedPluginRegistry {
119
125
  * Register a plugin with the system
120
126
  */
121
127
  public register(plugin: EnhancedMediaPlugin): void {
122
- this.plugins.set(plugin.getName(), plugin);
128
+ this.plugins.set(plugin.metadata.name, plugin);
123
129
 
124
130
  // Register plugin hooks
125
131
  this.registerPluginHooks(plugin);
@@ -212,7 +218,7 @@ export class EnhancedPluginRegistry {
212
218
  }
213
219
 
214
220
  const middleware = this.middlewares[index++];
215
- return Promise.resolve(middleware.execute(context, next));
221
+ return middleware ? Promise.resolve(middleware.execute(context, next)) : next();
216
222
  };
217
223
 
218
224
  return next();
@@ -231,8 +237,8 @@ export class EnhancedPluginRegistry {
231
237
  }
232
238
 
233
239
  this.hooks.get(hookType as keyof MediaPluginHooks)!.push({
234
- plugin: plugin.getName(),
235
- handler,
240
+ plugin: plugin.metadata.name,
241
+ handler: handler as Function,
236
242
  });
237
243
  }
238
244
  });
@@ -249,7 +255,7 @@ export class EnhancedPluginRegistry {
249
255
  if (handlers) {
250
256
  this.hooks.set(
251
257
  hookType as keyof MediaPluginHooks,
252
- handlers.filter(h => h.plugin !== plugin.getName())
258
+ handlers.filter(h => h.plugin !== plugin.metadata.name)
253
259
  );
254
260
  }
255
261
  });
@@ -282,7 +288,7 @@ export class EnhancedPluginManager {
282
288
  */
283
289
  public async setup(options: MediaPlayerConfig = {}): Promise<void> {
284
290
  // Execute beforeSetup hooks
285
- const setupResults = await this.registry.executeHook('beforeSetup', this.player.getElement(), options);
291
+ const setupResults = await this.registry.executeHook('beforeSetup', this.player.element, options);
286
292
 
287
293
  // Apply configuration modifications from hooks
288
294
  const modifiedOptions = setupResults.reduce((acc, { result }) => {
@@ -6,13 +6,15 @@
6
6
  import Hls, { HlsConfig } from 'hls.js';
7
7
  import { MediaPlayerConfig } from '../../types';
8
8
 
9
- export interface EnhancedHLSConfig extends HlsConfig {
9
+ export interface EnhancedHLSConfig {
10
10
  /** Enable machine learning-enhanced adaptive bitrate streaming */
11
11
  enableAdvancedABR?: boolean;
12
12
  /** Optimize for low-latency streaming */
13
13
  lowLatencyMode?: boolean;
14
14
  /** Enhanced buffer management for smoother playback */
15
15
  optimizedBuffering?: boolean;
16
+ // Include all standard HLS.js properties
17
+ [key: string]: any;
16
18
  }
17
19
 
18
20
  export const ENHANCED_HLS_DEFAULTS: EnhancedHLSConfig = {
@@ -60,50 +62,17 @@ export const ENHANCED_HLS_DEFAULTS: EnhancedHLSConfig = {
60
62
  },
61
63
  },
62
64
 
63
- // Progressive segment loading for better performance
64
- segmentLoadPolicy: {
65
- default: {
66
- maxTimeToFirstByteMs: 9000,
67
- maxLoadTimeMs: 20000,
68
- timeoutRetry: {
69
- maxNumRetry: 3,
70
- retryDelayMs: 2000,
71
- maxRetryDelayMs: 20000,
72
- backoff: 'linear',
73
- },
74
- errorRetry: {
75
- maxNumRetry: 5,
76
- retryDelayMs: 3000,
77
- maxRetryDelayMs: 30000,
78
- backoff: 'linear',
79
- },
80
- },
81
- },
82
-
83
- // Enhanced manifest parsing
84
- manifestLoadPolicy: {
85
- default: {
86
- maxTimeToFirstByteMs: 9000,
87
- maxLoadTimeMs: 20000,
88
- timeoutRetry: {
89
- maxNumRetry: 3,
90
- retryDelayMs: 2000,
91
- maxRetryDelayMs: 20000,
92
- backoff: 'linear',
93
- },
94
- errorRetry: {
95
- maxNumRetry: 5,
96
- retryDelayMs: 3000,
97
- maxRetryDelayMs: 30000,
98
- backoff: 'linear',
99
- },
100
- },
101
- },
65
+ // Enhanced timeout and retry configuration
66
+ maxLoadingDelay: 20000,
67
+ manifestLoadingTimeOut: 20000,
68
+ manifestLoadingMaxRetry: 5,
69
+ levelLoadingTimeOut: 20000,
70
+ levelLoadingMaxRetry: 5,
71
+ fragLoadingTimeOut: 20000,
72
+ fragLoadingMaxRetry: 5,
102
73
 
103
74
  // Level selection optimization
104
75
  startLevel: -1, // Auto-select start level
105
- initialBitrate: 0, // Auto-detect
106
- preferManagedMediaSource: true,
107
76
 
108
77
  // Debug and monitoring
109
78
  debug: false,
@@ -177,7 +146,7 @@ export class EnhancedHLSProvider {
177
146
  });
178
147
 
179
148
  // Quality optimization events
180
- this.hls.on(Hls.Events.BITRATE_SWITCHING, (event, data) => {
149
+ (this.hls as any).on('hlsBitrateSwitch', (event: any, data: any) => {
181
150
  this.performanceMonitor.onBitrateSwitch(data);
182
151
  });
183
152
  }
@@ -206,15 +175,15 @@ export class EnhancedHLSProvider {
206
175
  case Hls.ErrorDetails.FRAG_LOAD_TIMEOUT:
207
176
  // Timeout - increase timeout and retry
208
177
  if (this.hls) {
209
- this.hls.config.fragLoadPolicy.default.timeoutRetry.maxNumRetry = 8;
210
- this.hls.config.fragLoadPolicy.default.timeoutRetry.retryDelayMs = 5000;
178
+ this.hls.config.fragLoadingMaxRetry = 8;
179
+ this.hls.config.fragLoadingTimeOut = 15000;
211
180
  }
212
181
  break;
213
182
 
214
183
  case Hls.ErrorDetails.LEVEL_LOAD_ERROR:
215
184
  // Manifest error - try recovery with alternative
216
- if (options.hlsConfig?.fallbackUrl) {
217
- this.hls?.loadSource(options.hlsConfig.fallbackUrl);
185
+ if ((options as any).hlsConfig?.fallbackUrl) {
186
+ this.hls?.loadSource((options as any).hlsConfig.fallbackUrl);
218
187
  }
219
188
  break;
220
189
 
@@ -234,8 +203,8 @@ export class EnhancedHLSProvider {
234
203
  }
235
204
 
236
205
  // Custom error handler if provided
237
- if (options.onError) {
238
- options.onError(data);
206
+ if ((options as any).onError) {
207
+ (options as any).onError(data);
239
208
  }
240
209
  }
241
210
 
@@ -243,9 +212,9 @@ export class EnhancedHLSProvider {
243
212
  * Update configuration dynamically
244
213
  */
245
214
  public updateConfig(newConfig: Partial<EnhancedHLSConfig>): void {
246
- this.config = { ...this.config, ...newConfig };
215
+ Object.assign(this.config, newConfig);
247
216
  if (this.hls) {
248
- this.hls.config = this.config;
217
+ Object.assign(this.hls.config, this.config);
249
218
  }
250
219
  }
251
220
 
@@ -295,8 +264,8 @@ class HLSPerformanceMonitor {
295
264
  const video = hls.media;
296
265
  if (video) {
297
266
  const checkDroppedFrames = () => {
298
- if (video.getVideoPlaybackQuality) {
299
- const quality = video.getVideoPlaybackQuality();
267
+ if ((video as any).getVideoPlaybackQuality) {
268
+ const quality = (video as any).getVideoPlaybackQuality();
300
269
  this.metrics.droppedFrames = quality.droppedVideoFrames;
301
270
  }
302
271
  };
@@ -34,6 +34,16 @@ interface UseEnhancedMediaPlayerOptions {
34
34
  timeUpdateThrottleMs?: number
35
35
  enableSeekPreview?: boolean
36
36
  preloadStrategy?: "eager" | "lazy" | "progressive"
37
+ // Event callbacks
38
+ onPlay?: () => void
39
+ onPause?: () => void
40
+ onTimeUpdate?: (currentTime: number) => void
41
+ onDurationChange?: (duration: number) => void
42
+ onVolumeChange?: (volume: number) => void
43
+ onError?: (error: string) => void
44
+ onLoadStart?: () => void
45
+ onLoadedData?: () => void
46
+ onEnded?: () => void
37
47
  }
38
48
 
39
49
  // Performance-optimized media player hook with React 19 features
@@ -51,7 +61,7 @@ export function useEnhancedMediaPlayer(options: UseEnhancedMediaPlayerOptions) {
51
61
  const lastFrameTime = React.useRef<number>(0)
52
62
 
53
63
  // Throttled time update
54
- const timeUpdateTimeoutRef = useRef<NodeJS.Timeout>()
64
+ const timeUpdateTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined)
55
65
  const lastTimeUpdate = useRef<number>(0)
56
66
 
57
67
  // Store integration
@@ -398,7 +408,14 @@ export function useEnhancedMediaPlayer(options: UseEnhancedMediaPlayerOptions) {
398
408
  setVolume,
399
409
  toggleMute,
400
410
  enterFullscreen,
401
- exitFullscreen
411
+ exitFullscreen,
412
+ toggleFullscreen: () => {
413
+ if (document.fullscreenElement) {
414
+ exitFullscreen()
415
+ } else {
416
+ enterFullscreen()
417
+ }
418
+ }
402
419
  }
403
420
  }, [
404
421
  isPlaying,
@@ -65,19 +65,50 @@ export interface MediaPlayerState {
65
65
  }
66
66
 
67
67
  export interface MediaPlayerControls {
68
- play: () => void
68
+ play: () => Promise<void>
69
69
  pause: () => void
70
70
  toggle: () => void
71
71
  seek: (time: number) => void
72
72
  setVolume: (volume: number) => void
73
- mute: () => void
74
- unmute: () => void
75
73
  toggleMute: () => void
76
- enterFullscreen: () => void
77
- exitFullscreen: () => void
74
+ enterFullscreen: () => Promise<void>
75
+ exitFullscreen: () => Promise<void>
78
76
  toggleFullscreen: () => void
79
77
  }
80
78
 
79
+ export interface MediaPlayerInstance {
80
+ // Basic media element
81
+ element: HTMLMediaElement
82
+
83
+ // Player state
84
+ state: MediaPlayerState
85
+
86
+ // Controls
87
+ controls: MediaPlayerControls
88
+
89
+ // Configuration
90
+ config: MediaPlayerConfig
91
+
92
+ // Core methods
93
+ play: () => Promise<void>
94
+ pause: () => void
95
+ toggle: () => void
96
+ seek: (time: number) => void
97
+ setVolume: (volume: number) => void
98
+ toggleMute: () => void
99
+ enterFullscreen: () => Promise<void>
100
+ exitFullscreen: () => Promise<void>
101
+ toggleFullscreen: () => void
102
+
103
+ // Event listeners
104
+ on: (event: string, callback: Function) => void
105
+ off: (event: string, callback: Function) => void
106
+ one: (event: string, callback: Function) => void
107
+
108
+ // Plugin integration
109
+ plugins: Map<string, any>
110
+ }
111
+
81
112
  export interface MediaPlayerConfig {
82
113
  autoPlay?: boolean
83
114
  loop?: boolean
@@ -89,6 +120,10 @@ export interface MediaPlayerConfig {
89
120
  keyboardControls?: boolean
90
121
  showControls?: boolean
91
122
  customControls?: boolean
123
+ enablePerformanceMonitoring?: boolean
124
+ bufferingStrategy?: "adaptive" | "conservative" | "aggressive"
125
+ preloadStrategy?: "progressive" | "lazy" | "eager"
126
+ enableOptimizations?: boolean
92
127
  }
93
128
 
94
129
  export interface MediaPlayerProps extends MediaPlayerConfig {