strataplayer 1.0.11 → 1.0.12
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/dist/hls.cjs.js +1 -1
- package/dist/hls.cjs.js.map +1 -1
- package/dist/hls.d.ts +207 -2
- package/dist/hls.es.js +17 -16
- package/dist/hls.es.js.map +1 -1
- package/dist/index.d.ts +220 -1
- package/package.json +1 -8
- package/dist/core/AudioEngine.d.ts +0 -14
- package/dist/core/EventBus.d.ts +0 -9
- package/dist/core/NanoStore.d.ts +0 -10
- package/dist/core/StrataCore.d.ts +0 -162
- package/dist/lib.d.ts +0 -11
- package/dist/plugins/HlsPlugin.d.ts +0 -10
- package/dist/ui/Icons.d.ts +0 -38
- package/dist/ui/StrataPlayer.d.ts +0 -21
- package/dist/ui/components/Menu.d.ts +0 -16
- package/dist/ui/components/NotificationContainer.d.ts +0 -5
- package/dist/ui/components/SettingsPrimitives.d.ts +0 -4
- package/dist/ui/components/SubtitleMenu.d.ts +0 -1
- package/dist/ui/components/SubtitleOverlay.d.ts +0 -6
- package/dist/ui/hooks/useTransition.d.ts +0 -4
- package/dist/utils/playerUtils.d.ts +0 -11
package/dist/hls.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var c=(s,t,e)=>t in s?u(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var h=(s,t,e)=>c(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("hls.js");function v(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const l=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(t,e,l.get?l:{enumerable:!0,get:()=>s[e]})}}return t.default=s,Object.freeze(t)}const a=v(d),r=a.default||a;class f{constructor(){h(this,"name","HlsPlugin");h(this,"hls",null);h(this,"core",null)}init(t){this.core=t,this.core.events.on("load",e=>{e.type==="hls"||e.url.includes(".m3u8")?r.isSupported()?this.loadHls(e.url):this.core.video.canPlayType("application/vnd.apple.mpegurl")&&(this.core.video.src=e.url):this.hls&&(this.hls.destroy(),this.hls=null)}),this.core.events.on("quality-request",e=>{this.hls&&(this.hls.currentLevel=e)}),this.core.events.on("audio-track-request",e=>{this.hls&&(this.hls.audioTrack=e)})}loadHls(t){this.hls&&this.hls.destroy(),this.hls=new r({autoStartLoad:!0,startLevel:-1,capLevelToPlayerSize:!0}),this.hls.loadSource(t),this.hls.attachMedia(this.core.video),this.hls.on(r.Events.MANIFEST_PARSED,(e,l)=>{const o=l.levels.map((i,n)=>({height:i.height,bitrate:i.bitrate,index:n}));this.core.store.setState({qualityLevels:o})}),this.hls.on(r.Events.AUDIO_TRACKS_UPDATED,(e,l)=>{const o=l.audioTracks.map((i,n)=>({label:i.name||i.lang||`Audio ${n+1}`,language:i.lang||"",index:n}));this.core.store.setState({audioTracks:o,currentAudioTrack:this.hls.audioTrack})}),this.hls.on(r.Events.LEVEL_SWITCHED,(e,l)=>{}),this.hls.on(r.Events.ERROR,(e,l)=>{if(l.fatal){const o=l.details||"Unknown HLS Error";this.core.triggerError(o,!0)}})}destroy(){this.hls&&(this.hls.destroy(),this.hls=null)}}exports.HlsPlugin=f;
|
|
2
2
|
//# sourceMappingURL=hls.cjs.js.map
|
package/dist/hls.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hls.cjs.js","sources":["../plugins/HlsPlugin.ts"],"sourcesContent":["\nimport { StrataCore, IPlugin } from '../core/StrataCore';\nimport
|
|
1
|
+
{"version":3,"file":"hls.cjs.js","sources":["../plugins/HlsPlugin.ts"],"sourcesContent":["\nimport { StrataCore, IPlugin } from '../core/StrataCore';\nimport * as HlsModule from 'hls.js';\n\n// Handle environment differences where Hls might be a default export or module export\nconst Hls = (HlsModule as any).default || HlsModule;\n\nexport class HlsPlugin implements IPlugin {\n name = 'HlsPlugin';\n private hls: any = null;\n private core: StrataCore | null = null;\n\n init(core: StrataCore) {\n this.core = core;\n\n // Listen for load requests\n this.core.events.on('load', (data: { url: string, type: string }) => {\n // Only proceed if type matches HLS\n if (data.type === 'hls' || data.url.includes('.m3u8')) {\n if (Hls.isSupported()) {\n this.loadHls(data.url);\n } else if (this.core!.video.canPlayType('application/vnd.apple.mpegurl')) {\n // Native HLS fallback (Safari) - Core sets src, we do nothing\n // Core already handles setting video.src if standard\n this.core!.video.src = data.url;\n }\n } else {\n // If we had an active HLS instance but switched to MP4, destroy it\n if (this.hls) {\n this.hls.destroy();\n this.hls = null;\n }\n }\n });\n\n // Listen for quality changes from UI\n this.core.events.on('quality-request', (index: number) => {\n if (this.hls) {\n this.hls.currentLevel = index;\n }\n });\n\n // Listen for audio track changes from UI\n this.core.events.on('audio-track-request', (index: number) => {\n if (this.hls) {\n this.hls.audioTrack = index;\n }\n });\n }\n\n private loadHls(url: string) {\n if (this.hls) {\n this.hls.destroy();\n }\n\n this.hls = new Hls({\n autoStartLoad: true,\n startLevel: -1, // Auto\n capLevelToPlayerSize: true, // Performance opt\n });\n\n this.hls.loadSource(url);\n this.hls.attachMedia(this.core!.video);\n\n this.hls.on(Hls.Events.MANIFEST_PARSED, (event: any, data: any) => {\n const levels = data.levels.map((lvl: any, idx: number) => ({\n height: lvl.height,\n bitrate: lvl.bitrate,\n index: idx\n }));\n this.core!.store.setState({ qualityLevels: levels });\n });\n\n // Handle Audio Tracks\n this.hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (event: any, data: any) => {\n const tracks = data.audioTracks.map((track: any, idx: number) => ({\n label: track.name || track.lang || `Audio ${idx + 1}`,\n language: track.lang || '',\n index: idx\n }));\n this.core!.store.setState({\n audioTracks: tracks,\n currentAudioTrack: this.hls!.audioTrack\n });\n });\n\n this.hls.on(Hls.Events.LEVEL_SWITCHED, (event: any, data: any) => {\n // Update current quality only if in auto mode to show what's playing\n // If manual, state is already set\n });\n\n this.hls.on(Hls.Events.ERROR, (event: any, data: any) => {\n if (data.fatal) {\n // Pass fatal errors to Core to handle the retry loop visibly\n const msg = data.details || 'Unknown HLS Error';\n this.core!.triggerError(msg, true);\n\n // Cleanup if needed, but core.load() will eventually destroy and re-init this plugin\n }\n });\n }\n\n destroy() {\n if (this.hls) {\n this.hls.destroy();\n this.hls = null;\n }\n }\n}\n"],"names":["Hls","HlsModule","HlsPlugin","__publicField","core","data","index","url","event","levels","lvl","idx","tracks","track","msg"],"mappings":"wiBAKMA,EAAOC,EAAkB,SAAWA,EAEnC,MAAMC,CAA6B,CAAnC,cACLC,EAAA,YAAO,aACCA,EAAA,WAAW,MACXA,EAAA,YAA0B,MAElC,KAAKC,EAAkB,CACrB,KAAK,KAAOA,EAGZ,KAAK,KAAK,OAAO,GAAG,OAASC,GAAwC,CAE/DA,EAAK,OAAS,OAASA,EAAK,IAAI,SAAS,OAAO,EAC9CL,EAAI,cACN,KAAK,QAAQK,EAAK,GAAG,EACZ,KAAK,KAAM,MAAM,YAAY,+BAA+B,IAGrE,KAAK,KAAM,MAAM,IAAMA,EAAK,KAI1B,KAAK,MACP,KAAK,IAAI,QAAA,EACT,KAAK,IAAM,KAGjB,CAAC,EAGD,KAAK,KAAK,OAAO,GAAG,kBAAoBC,GAAkB,CACpD,KAAK,MACP,KAAK,IAAI,aAAeA,EAE5B,CAAC,EAGD,KAAK,KAAK,OAAO,GAAG,sBAAwBA,GAAkB,CACxD,KAAK,MACP,KAAK,IAAI,WAAaA,EAE1B,CAAC,CACH,CAEQ,QAAQC,EAAa,CACvB,KAAK,KACP,KAAK,IAAI,QAAA,EAGX,KAAK,IAAM,IAAIP,EAAI,CACjB,cAAe,GACf,WAAY,GACZ,qBAAsB,EAAA,CACvB,EAED,KAAK,IAAI,WAAWO,CAAG,EACvB,KAAK,IAAI,YAAY,KAAK,KAAM,KAAK,EAErC,KAAK,IAAI,GAAGP,EAAI,OAAO,gBAAiB,CAACQ,EAAYH,IAAc,CACjE,MAAMI,EAASJ,EAAK,OAAO,IAAI,CAACK,EAAUC,KAAiB,CACzD,OAAQD,EAAI,OACZ,QAASA,EAAI,QACb,MAAOC,CAAA,EACP,EACF,KAAK,KAAM,MAAM,SAAS,CAAE,cAAeF,EAAQ,CACrD,CAAC,EAGD,KAAK,IAAI,GAAGT,EAAI,OAAO,qBAAsB,CAACQ,EAAYH,IAAc,CACtE,MAAMO,EAASP,EAAK,YAAY,IAAI,CAACQ,EAAYF,KAAiB,CAChE,MAAOE,EAAM,MAAQA,EAAM,MAAQ,SAASF,EAAM,CAAC,GACnD,SAAUE,EAAM,MAAQ,GACxB,MAAOF,CAAA,EACP,EACF,KAAK,KAAM,MAAM,SAAS,CACxB,YAAaC,EACb,kBAAmB,KAAK,IAAK,UAAA,CAC9B,CACH,CAAC,EAED,KAAK,IAAI,GAAGZ,EAAI,OAAO,eAAgB,CAACQ,EAAYH,IAAc,CAGlE,CAAC,EAED,KAAK,IAAI,GAAGL,EAAI,OAAO,MAAO,CAACQ,EAAYH,IAAc,CACvD,GAAIA,EAAK,MAAO,CAEd,MAAMS,EAAMT,EAAK,SAAW,oBAC5B,KAAK,KAAM,aAAaS,EAAK,EAAI,CAGnC,CACF,CAAC,CACH,CAEA,SAAU,CACJ,KAAK,MACP,KAAK,IAAI,QAAA,EACT,KAAK,IAAM,KAEf,CACF"}
|
package/dist/hls.d.ts
CHANGED
|
@@ -1,3 +1,208 @@
|
|
|
1
|
-
|
|
1
|
+
declare class EventBus {
|
|
2
|
+
private events;
|
|
3
|
+
constructor();
|
|
4
|
+
on<T>(event: string, callback: EventCallback<T>): () => void;
|
|
5
|
+
off<T>(event: string, callback: EventCallback<T>): void;
|
|
6
|
+
emit<T>(event: string, data?: T): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare type EventCallback<T = any> = (data: T) => void;
|
|
11
|
+
|
|
12
|
+
export declare class HlsPlugin implements IPlugin {
|
|
13
|
+
name: string;
|
|
14
|
+
private hls;
|
|
15
|
+
private core;
|
|
16
|
+
init(core: StrataCore): void;
|
|
17
|
+
private loadHls;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare interface IPlugin {
|
|
22
|
+
name: string;
|
|
23
|
+
init(core: StrataCore): void;
|
|
24
|
+
destroy?(): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare type Listener<T> = (state: T, prevState: T) => void;
|
|
28
|
+
|
|
29
|
+
declare class NanoStore<T> {
|
|
30
|
+
private state;
|
|
31
|
+
private listeners;
|
|
32
|
+
constructor(initialState: T);
|
|
33
|
+
get(): T;
|
|
34
|
+
setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;
|
|
35
|
+
subscribe(listener: Listener<T>): () => void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare interface Notification_2 {
|
|
40
|
+
id: string;
|
|
41
|
+
message: string;
|
|
42
|
+
type: 'info' | 'success' | 'warning' | 'error' | 'loading';
|
|
43
|
+
duration?: number;
|
|
44
|
+
progress?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare interface PlayerSource {
|
|
48
|
+
url: string;
|
|
49
|
+
type?: 'hls' | 'mp4' | 'webm' | 'dash' | string;
|
|
50
|
+
name?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare interface PlayerState {
|
|
54
|
+
isPlaying: boolean;
|
|
55
|
+
isBuffering: boolean;
|
|
56
|
+
currentTime: number;
|
|
57
|
+
duration: number;
|
|
58
|
+
buffered: {
|
|
59
|
+
start: number;
|
|
60
|
+
end: number;
|
|
61
|
+
}[];
|
|
62
|
+
volume: number;
|
|
63
|
+
isMuted: boolean;
|
|
64
|
+
audioGain: number;
|
|
65
|
+
playbackRate: number;
|
|
66
|
+
qualityLevels: {
|
|
67
|
+
height: number;
|
|
68
|
+
bitrate: number;
|
|
69
|
+
index: number;
|
|
70
|
+
}[];
|
|
71
|
+
currentQuality: number;
|
|
72
|
+
audioTracks: {
|
|
73
|
+
label: string;
|
|
74
|
+
language: string;
|
|
75
|
+
index: number;
|
|
76
|
+
}[];
|
|
77
|
+
currentAudioTrack: number;
|
|
78
|
+
error: string | null;
|
|
79
|
+
isFullscreen: boolean;
|
|
80
|
+
isPip: boolean;
|
|
81
|
+
subtitleTracks: {
|
|
82
|
+
label: string;
|
|
83
|
+
language: string;
|
|
84
|
+
index: number;
|
|
85
|
+
}[];
|
|
86
|
+
currentSubtitle: number;
|
|
87
|
+
subtitleOffset: number;
|
|
88
|
+
subtitleSettings: SubtitleSettings;
|
|
89
|
+
activeCues: string[];
|
|
90
|
+
viewMode: 'normal' | 'theater' | 'pip';
|
|
91
|
+
notifications: Notification_2[];
|
|
92
|
+
iconSize: 'small' | 'medium' | 'large';
|
|
93
|
+
themeColor: string;
|
|
94
|
+
theme: PlayerTheme;
|
|
95
|
+
sources: PlayerSource[];
|
|
96
|
+
currentSourceIndex: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare type PlayerTheme = 'default' | 'pixel' | 'game' | 'hacker';
|
|
100
|
+
|
|
101
|
+
declare interface StrataConfig {
|
|
102
|
+
volume?: number;
|
|
103
|
+
muted?: boolean;
|
|
104
|
+
playbackRate?: number;
|
|
105
|
+
audioGain?: number;
|
|
106
|
+
theme?: PlayerTheme;
|
|
107
|
+
themeColor?: string;
|
|
108
|
+
iconSize?: 'small' | 'medium' | 'large';
|
|
109
|
+
subtitleSettings?: Partial<SubtitleSettings>;
|
|
110
|
+
disablePersistence?: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
declare class StrataCore {
|
|
114
|
+
video: HTMLVideoElement;
|
|
115
|
+
container: HTMLElement | null;
|
|
116
|
+
events: EventBus;
|
|
117
|
+
store: NanoStore<PlayerState>;
|
|
118
|
+
private plugins;
|
|
119
|
+
private audioEngine;
|
|
120
|
+
private config;
|
|
121
|
+
private retryCount;
|
|
122
|
+
private maxRetries;
|
|
123
|
+
private retryTimer;
|
|
124
|
+
private currentSource;
|
|
125
|
+
private currentSrc;
|
|
126
|
+
private currentTracks;
|
|
127
|
+
private castInitialized;
|
|
128
|
+
private boundCueChange;
|
|
129
|
+
private boundFullscreenChange;
|
|
130
|
+
constructor(config?: StrataConfig, videoElement?: HTMLVideoElement);
|
|
131
|
+
private initVideoListeners;
|
|
132
|
+
triggerError(message: string, isFatal?: boolean): void;
|
|
133
|
+
private handleError;
|
|
134
|
+
private updateBuffer;
|
|
135
|
+
private updateSubtitles;
|
|
136
|
+
fetchWithRetry(url: string, retries?: number): Promise<Response>;
|
|
137
|
+
attach(container: HTMLElement): void;
|
|
138
|
+
use(plugin: IPlugin): void;
|
|
139
|
+
setSources(sources: PlayerSource[], tracks?: TextTrackConfig[]): void;
|
|
140
|
+
switchSource(index: number): void;
|
|
141
|
+
load(source: PlayerSource | string, tracks?: TextTrackConfig[], isRetry?: boolean): void;
|
|
142
|
+
addTextTrack(file: File, label: string): void;
|
|
143
|
+
private addTextTrackInternal;
|
|
144
|
+
play(): Promise<void>;
|
|
145
|
+
pause(): void;
|
|
146
|
+
togglePlay(): void;
|
|
147
|
+
seek(time: number): void;
|
|
148
|
+
skip(seconds: number): void;
|
|
149
|
+
setVolume(vol: number): void;
|
|
150
|
+
toggleMute(): void;
|
|
151
|
+
setAudioGain(gain: number): void;
|
|
152
|
+
setQuality(index: number): void;
|
|
153
|
+
setAudioTrack(index: number): void;
|
|
154
|
+
toggleFullscreen(): void;
|
|
155
|
+
togglePip(): void;
|
|
156
|
+
private initCast;
|
|
157
|
+
requestCast(): void;
|
|
158
|
+
private loadMediaToCast;
|
|
159
|
+
private handleCueChange;
|
|
160
|
+
setSubtitle(index: number): void;
|
|
161
|
+
updateSubtitleSettings(settings: Partial<SubtitleSettings>): void;
|
|
162
|
+
resetSubtitleSettings(): void;
|
|
163
|
+
setSubtitleOffset(offset: number): void;
|
|
164
|
+
download(): Promise<void>;
|
|
165
|
+
notify(n: Omit<Notification_2, 'id'> & {
|
|
166
|
+
id?: string;
|
|
167
|
+
}): string;
|
|
168
|
+
removeNotification(id: string): void;
|
|
169
|
+
setAppearance(settings: {
|
|
170
|
+
iconSize?: 'small' | 'medium' | 'large';
|
|
171
|
+
themeColor?: string;
|
|
172
|
+
theme?: PlayerTheme;
|
|
173
|
+
}): void;
|
|
174
|
+
destroy(): void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare interface SubtitleSettings {
|
|
178
|
+
useNative: boolean;
|
|
179
|
+
fixCapitalization: boolean;
|
|
180
|
+
backgroundOpacity: number;
|
|
181
|
+
backgroundBlur: boolean;
|
|
182
|
+
backgroundBlurAmount: number;
|
|
183
|
+
textSize: number;
|
|
184
|
+
textStyle: 'none' | 'outline' | 'raised' | 'depressed' | 'shadow';
|
|
185
|
+
isBold: boolean;
|
|
186
|
+
textColor: string;
|
|
187
|
+
verticalOffset: number;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
declare interface TextTrackConfig {
|
|
191
|
+
kind: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
192
|
+
label: string;
|
|
193
|
+
src: string;
|
|
194
|
+
srcLang: string;
|
|
195
|
+
default?: boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export { }
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
declare module 'react' {
|
|
202
|
+
namespace JSX {
|
|
203
|
+
interface IntrinsicElements {
|
|
204
|
+
'google-cast-launcher': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
2
208
|
|
|
3
|
-
export { HlsPlugin };
|
package/dist/hls.es.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var n = (
|
|
4
|
-
import
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var c = (l, e, s) => e in l ? u(l, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : l[e] = s;
|
|
3
|
+
var n = (l, e, s) => c(l, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import * as a from "hls.js";
|
|
5
|
+
const h = a.default || a;
|
|
5
6
|
class v {
|
|
6
7
|
constructor() {
|
|
7
8
|
n(this, "name", "HlsPlugin");
|
|
@@ -25,27 +26,27 @@ class v {
|
|
|
25
26
|
capLevelToPlayerSize: !0
|
|
26
27
|
// Performance opt
|
|
27
28
|
}), this.hls.loadSource(e), this.hls.attachMedia(this.core.video), this.hls.on(h.Events.MANIFEST_PARSED, (s, t) => {
|
|
28
|
-
const
|
|
29
|
-
height:
|
|
30
|
-
bitrate:
|
|
31
|
-
index:
|
|
29
|
+
const o = t.levels.map((i, r) => ({
|
|
30
|
+
height: i.height,
|
|
31
|
+
bitrate: i.bitrate,
|
|
32
|
+
index: r
|
|
32
33
|
}));
|
|
33
|
-
this.core.store.setState({ qualityLevels:
|
|
34
|
+
this.core.store.setState({ qualityLevels: o });
|
|
34
35
|
}), this.hls.on(h.Events.AUDIO_TRACKS_UPDATED, (s, t) => {
|
|
35
|
-
const
|
|
36
|
-
label:
|
|
37
|
-
language:
|
|
38
|
-
index:
|
|
36
|
+
const o = t.audioTracks.map((i, r) => ({
|
|
37
|
+
label: i.name || i.lang || `Audio ${r + 1}`,
|
|
38
|
+
language: i.lang || "",
|
|
39
|
+
index: r
|
|
39
40
|
}));
|
|
40
41
|
this.core.store.setState({
|
|
41
|
-
audioTracks:
|
|
42
|
+
audioTracks: o,
|
|
42
43
|
currentAudioTrack: this.hls.audioTrack
|
|
43
44
|
});
|
|
44
45
|
}), this.hls.on(h.Events.LEVEL_SWITCHED, (s, t) => {
|
|
45
46
|
}), this.hls.on(h.Events.ERROR, (s, t) => {
|
|
46
47
|
if (t.fatal) {
|
|
47
|
-
const
|
|
48
|
-
this.core.triggerError(
|
|
48
|
+
const o = t.details || "Unknown HLS Error";
|
|
49
|
+
this.core.triggerError(o, !0);
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
}
|
package/dist/hls.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hls.es.js","sources":["../plugins/HlsPlugin.ts"],"sourcesContent":["\nimport { StrataCore, IPlugin } from '../core/StrataCore';\nimport
|
|
1
|
+
{"version":3,"file":"hls.es.js","sources":["../plugins/HlsPlugin.ts"],"sourcesContent":["\nimport { StrataCore, IPlugin } from '../core/StrataCore';\nimport * as HlsModule from 'hls.js';\n\n// Handle environment differences where Hls might be a default export or module export\nconst Hls = (HlsModule as any).default || HlsModule;\n\nexport class HlsPlugin implements IPlugin {\n name = 'HlsPlugin';\n private hls: any = null;\n private core: StrataCore | null = null;\n\n init(core: StrataCore) {\n this.core = core;\n\n // Listen for load requests\n this.core.events.on('load', (data: { url: string, type: string }) => {\n // Only proceed if type matches HLS\n if (data.type === 'hls' || data.url.includes('.m3u8')) {\n if (Hls.isSupported()) {\n this.loadHls(data.url);\n } else if (this.core!.video.canPlayType('application/vnd.apple.mpegurl')) {\n // Native HLS fallback (Safari) - Core sets src, we do nothing\n // Core already handles setting video.src if standard\n this.core!.video.src = data.url;\n }\n } else {\n // If we had an active HLS instance but switched to MP4, destroy it\n if (this.hls) {\n this.hls.destroy();\n this.hls = null;\n }\n }\n });\n\n // Listen for quality changes from UI\n this.core.events.on('quality-request', (index: number) => {\n if (this.hls) {\n this.hls.currentLevel = index;\n }\n });\n\n // Listen for audio track changes from UI\n this.core.events.on('audio-track-request', (index: number) => {\n if (this.hls) {\n this.hls.audioTrack = index;\n }\n });\n }\n\n private loadHls(url: string) {\n if (this.hls) {\n this.hls.destroy();\n }\n\n this.hls = new Hls({\n autoStartLoad: true,\n startLevel: -1, // Auto\n capLevelToPlayerSize: true, // Performance opt\n });\n\n this.hls.loadSource(url);\n this.hls.attachMedia(this.core!.video);\n\n this.hls.on(Hls.Events.MANIFEST_PARSED, (event: any, data: any) => {\n const levels = data.levels.map((lvl: any, idx: number) => ({\n height: lvl.height,\n bitrate: lvl.bitrate,\n index: idx\n }));\n this.core!.store.setState({ qualityLevels: levels });\n });\n\n // Handle Audio Tracks\n this.hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (event: any, data: any) => {\n const tracks = data.audioTracks.map((track: any, idx: number) => ({\n label: track.name || track.lang || `Audio ${idx + 1}`,\n language: track.lang || '',\n index: idx\n }));\n this.core!.store.setState({\n audioTracks: tracks,\n currentAudioTrack: this.hls!.audioTrack\n });\n });\n\n this.hls.on(Hls.Events.LEVEL_SWITCHED, (event: any, data: any) => {\n // Update current quality only if in auto mode to show what's playing\n // If manual, state is already set\n });\n\n this.hls.on(Hls.Events.ERROR, (event: any, data: any) => {\n if (data.fatal) {\n // Pass fatal errors to Core to handle the retry loop visibly\n const msg = data.details || 'Unknown HLS Error';\n this.core!.triggerError(msg, true);\n\n // Cleanup if needed, but core.load() will eventually destroy and re-init this plugin\n }\n });\n }\n\n destroy() {\n if (this.hls) {\n this.hls.destroy();\n this.hls = null;\n }\n }\n}\n"],"names":["Hls","HlsModule","HlsPlugin","__publicField","core","data","index","url","event","levels","lvl","idx","tracks","track","msg"],"mappings":";;;;AAKA,MAAMA,IAAOC,EAAkB,WAAWA;AAEnC,MAAMC,EAA6B;AAAA,EAAnC;AACL,IAAAC,EAAA,cAAO;AACC,IAAAA,EAAA,aAAW;AACX,IAAAA,EAAA,cAA0B;AAAA;AAAA,EAElC,KAAKC,GAAkB;AACrB,SAAK,OAAOA,GAGZ,KAAK,KAAK,OAAO,GAAG,QAAQ,CAACC,MAAwC;AAEnE,MAAIA,EAAK,SAAS,SAASA,EAAK,IAAI,SAAS,OAAO,IAC9CL,EAAI,gBACN,KAAK,QAAQK,EAAK,GAAG,IACZ,KAAK,KAAM,MAAM,YAAY,+BAA+B,MAGrE,KAAK,KAAM,MAAM,MAAMA,EAAK,OAI1B,KAAK,QACP,KAAK,IAAI,QAAA,GACT,KAAK,MAAM;AAAA,IAGjB,CAAC,GAGD,KAAK,KAAK,OAAO,GAAG,mBAAmB,CAACC,MAAkB;AACxD,MAAI,KAAK,QACP,KAAK,IAAI,eAAeA;AAAA,IAE5B,CAAC,GAGD,KAAK,KAAK,OAAO,GAAG,uBAAuB,CAACA,MAAkB;AAC5D,MAAI,KAAK,QACP,KAAK,IAAI,aAAaA;AAAA,IAE1B,CAAC;AAAA,EACH;AAAA,EAEQ,QAAQC,GAAa;AAC3B,IAAI,KAAK,OACP,KAAK,IAAI,QAAA,GAGX,KAAK,MAAM,IAAIP,EAAI;AAAA,MACjB,eAAe;AAAA,MACf,YAAY;AAAA;AAAA,MACZ,sBAAsB;AAAA;AAAA,IAAA,CACvB,GAED,KAAK,IAAI,WAAWO,CAAG,GACvB,KAAK,IAAI,YAAY,KAAK,KAAM,KAAK,GAErC,KAAK,IAAI,GAAGP,EAAI,OAAO,iBAAiB,CAACQ,GAAYH,MAAc;AACjE,YAAMI,IAASJ,EAAK,OAAO,IAAI,CAACK,GAAUC,OAAiB;AAAA,QACzD,QAAQD,EAAI;AAAA,QACZ,SAASA,EAAI;AAAA,QACb,OAAOC;AAAA,MAAA,EACP;AACF,WAAK,KAAM,MAAM,SAAS,EAAE,eAAeF,GAAQ;AAAA,IACrD,CAAC,GAGD,KAAK,IAAI,GAAGT,EAAI,OAAO,sBAAsB,CAACQ,GAAYH,MAAc;AACtE,YAAMO,IAASP,EAAK,YAAY,IAAI,CAACQ,GAAYF,OAAiB;AAAA,QAChE,OAAOE,EAAM,QAAQA,EAAM,QAAQ,SAASF,IAAM,CAAC;AAAA,QACnD,UAAUE,EAAM,QAAQ;AAAA,QACxB,OAAOF;AAAA,MAAA,EACP;AACF,WAAK,KAAM,MAAM,SAAS;AAAA,QACxB,aAAaC;AAAA,QACb,mBAAmB,KAAK,IAAK;AAAA,MAAA,CAC9B;AAAA,IACH,CAAC,GAED,KAAK,IAAI,GAAGZ,EAAI,OAAO,gBAAgB,CAACQ,GAAYH,MAAc;AAAA,IAGlE,CAAC,GAED,KAAK,IAAI,GAAGL,EAAI,OAAO,OAAO,CAACQ,GAAYH,MAAc;AACvD,UAAIA,EAAK,OAAO;AAEd,cAAMS,IAAMT,EAAK,WAAW;AAC5B,aAAK,KAAM,aAAaS,GAAK,EAAI;AAAA,MAGnC;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,UAAU;AACR,IAAI,KAAK,QACP,KAAK,IAAI,QAAA,GACT,KAAK,MAAM;AAAA,EAEf;AACF;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,220 @@
|
|
|
1
|
-
|
|
1
|
+
import { JSX } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
declare class EventBus {
|
|
4
|
+
private events;
|
|
5
|
+
constructor();
|
|
6
|
+
on<T>(event: string, callback: EventCallback<T>): () => void;
|
|
7
|
+
off<T>(event: string, callback: EventCallback<T>): void;
|
|
8
|
+
emit<T>(event: string, data?: T): void;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare type EventCallback<T = any> = (data: T) => void;
|
|
13
|
+
|
|
14
|
+
declare interface IPlugin {
|
|
15
|
+
name: string;
|
|
16
|
+
init(core: StrataCore): void;
|
|
17
|
+
destroy?(): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare type Listener<T> = (state: T, prevState: T) => void;
|
|
21
|
+
|
|
22
|
+
export declare const mountStrataPlayer: (container: HTMLElement, props: any) => StrataPlayerInstance;
|
|
23
|
+
|
|
24
|
+
declare class NanoStore<T> {
|
|
25
|
+
private state;
|
|
26
|
+
private listeners;
|
|
27
|
+
constructor(initialState: T);
|
|
28
|
+
get(): T;
|
|
29
|
+
setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;
|
|
30
|
+
subscribe(listener: Listener<T>): () => void;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare interface Notification_2 {
|
|
35
|
+
id: string;
|
|
36
|
+
message: string;
|
|
37
|
+
type: 'info' | 'success' | 'warning' | 'error' | 'loading';
|
|
38
|
+
duration?: number;
|
|
39
|
+
progress?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare interface PlayerSource {
|
|
43
|
+
url: string;
|
|
44
|
+
type?: 'hls' | 'mp4' | 'webm' | 'dash' | string;
|
|
45
|
+
name?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export declare interface PlayerState {
|
|
49
|
+
isPlaying: boolean;
|
|
50
|
+
isBuffering: boolean;
|
|
51
|
+
currentTime: number;
|
|
52
|
+
duration: number;
|
|
53
|
+
buffered: {
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
}[];
|
|
57
|
+
volume: number;
|
|
58
|
+
isMuted: boolean;
|
|
59
|
+
audioGain: number;
|
|
60
|
+
playbackRate: number;
|
|
61
|
+
qualityLevels: {
|
|
62
|
+
height: number;
|
|
63
|
+
bitrate: number;
|
|
64
|
+
index: number;
|
|
65
|
+
}[];
|
|
66
|
+
currentQuality: number;
|
|
67
|
+
audioTracks: {
|
|
68
|
+
label: string;
|
|
69
|
+
language: string;
|
|
70
|
+
index: number;
|
|
71
|
+
}[];
|
|
72
|
+
currentAudioTrack: number;
|
|
73
|
+
error: string | null;
|
|
74
|
+
isFullscreen: boolean;
|
|
75
|
+
isPip: boolean;
|
|
76
|
+
subtitleTracks: {
|
|
77
|
+
label: string;
|
|
78
|
+
language: string;
|
|
79
|
+
index: number;
|
|
80
|
+
}[];
|
|
81
|
+
currentSubtitle: number;
|
|
82
|
+
subtitleOffset: number;
|
|
83
|
+
subtitleSettings: SubtitleSettings;
|
|
84
|
+
activeCues: string[];
|
|
85
|
+
viewMode: 'normal' | 'theater' | 'pip';
|
|
86
|
+
notifications: Notification_2[];
|
|
87
|
+
iconSize: 'small' | 'medium' | 'large';
|
|
88
|
+
themeColor: string;
|
|
89
|
+
theme: PlayerTheme;
|
|
90
|
+
sources: PlayerSource[];
|
|
91
|
+
currentSourceIndex: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare type PlayerTheme = 'default' | 'pixel' | 'game' | 'hacker';
|
|
95
|
+
|
|
96
|
+
export declare interface StrataConfig {
|
|
97
|
+
volume?: number;
|
|
98
|
+
muted?: boolean;
|
|
99
|
+
playbackRate?: number;
|
|
100
|
+
audioGain?: number;
|
|
101
|
+
theme?: PlayerTheme;
|
|
102
|
+
themeColor?: string;
|
|
103
|
+
iconSize?: 'small' | 'medium' | 'large';
|
|
104
|
+
subtitleSettings?: Partial<SubtitleSettings>;
|
|
105
|
+
disablePersistence?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export declare class StrataCore {
|
|
109
|
+
video: HTMLVideoElement;
|
|
110
|
+
container: HTMLElement | null;
|
|
111
|
+
events: EventBus;
|
|
112
|
+
store: NanoStore<PlayerState>;
|
|
113
|
+
private plugins;
|
|
114
|
+
private audioEngine;
|
|
115
|
+
private config;
|
|
116
|
+
private retryCount;
|
|
117
|
+
private maxRetries;
|
|
118
|
+
private retryTimer;
|
|
119
|
+
private currentSource;
|
|
120
|
+
private currentSrc;
|
|
121
|
+
private currentTracks;
|
|
122
|
+
private castInitialized;
|
|
123
|
+
private boundCueChange;
|
|
124
|
+
private boundFullscreenChange;
|
|
125
|
+
constructor(config?: StrataConfig, videoElement?: HTMLVideoElement);
|
|
126
|
+
private initVideoListeners;
|
|
127
|
+
triggerError(message: string, isFatal?: boolean): void;
|
|
128
|
+
private handleError;
|
|
129
|
+
private updateBuffer;
|
|
130
|
+
private updateSubtitles;
|
|
131
|
+
fetchWithRetry(url: string, retries?: number): Promise<Response>;
|
|
132
|
+
attach(container: HTMLElement): void;
|
|
133
|
+
use(plugin: IPlugin): void;
|
|
134
|
+
setSources(sources: PlayerSource[], tracks?: TextTrackConfig[]): void;
|
|
135
|
+
switchSource(index: number): void;
|
|
136
|
+
load(source: PlayerSource | string, tracks?: TextTrackConfig[], isRetry?: boolean): void;
|
|
137
|
+
addTextTrack(file: File, label: string): void;
|
|
138
|
+
private addTextTrackInternal;
|
|
139
|
+
play(): Promise<void>;
|
|
140
|
+
pause(): void;
|
|
141
|
+
togglePlay(): void;
|
|
142
|
+
seek(time: number): void;
|
|
143
|
+
skip(seconds: number): void;
|
|
144
|
+
setVolume(vol: number): void;
|
|
145
|
+
toggleMute(): void;
|
|
146
|
+
setAudioGain(gain: number): void;
|
|
147
|
+
setQuality(index: number): void;
|
|
148
|
+
setAudioTrack(index: number): void;
|
|
149
|
+
toggleFullscreen(): void;
|
|
150
|
+
togglePip(): void;
|
|
151
|
+
private initCast;
|
|
152
|
+
requestCast(): void;
|
|
153
|
+
private loadMediaToCast;
|
|
154
|
+
private handleCueChange;
|
|
155
|
+
setSubtitle(index: number): void;
|
|
156
|
+
updateSubtitleSettings(settings: Partial<SubtitleSettings>): void;
|
|
157
|
+
resetSubtitleSettings(): void;
|
|
158
|
+
setSubtitleOffset(offset: number): void;
|
|
159
|
+
download(): Promise<void>;
|
|
160
|
+
notify(n: Omit<Notification_2, 'id'> & {
|
|
161
|
+
id?: string;
|
|
162
|
+
}): string;
|
|
163
|
+
removeNotification(id: string): void;
|
|
164
|
+
setAppearance(settings: {
|
|
165
|
+
iconSize?: 'small' | 'medium' | 'large';
|
|
166
|
+
themeColor?: string;
|
|
167
|
+
theme?: PlayerTheme;
|
|
168
|
+
}): void;
|
|
169
|
+
destroy(): void;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export declare const StrataPlayer: (props: StrataPlayerProps) => JSX.Element;
|
|
173
|
+
|
|
174
|
+
export declare interface StrataPlayerInstance {
|
|
175
|
+
unmount: () => void;
|
|
176
|
+
update: (props: any) => void;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare interface StrataPlayerProps extends StrataConfig {
|
|
180
|
+
src?: string;
|
|
181
|
+
sources?: PlayerSource[];
|
|
182
|
+
poster?: string;
|
|
183
|
+
autoPlay?: boolean;
|
|
184
|
+
thumbnails?: string;
|
|
185
|
+
textTracks?: TextTrackConfig[];
|
|
186
|
+
plugins?: IPlugin[];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare interface SubtitleSettings {
|
|
190
|
+
useNative: boolean;
|
|
191
|
+
fixCapitalization: boolean;
|
|
192
|
+
backgroundOpacity: number;
|
|
193
|
+
backgroundBlur: boolean;
|
|
194
|
+
backgroundBlurAmount: number;
|
|
195
|
+
textSize: number;
|
|
196
|
+
textStyle: 'none' | 'outline' | 'raised' | 'depressed' | 'shadow';
|
|
197
|
+
isBold: boolean;
|
|
198
|
+
textColor: string;
|
|
199
|
+
verticalOffset: number;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export declare interface TextTrackConfig {
|
|
203
|
+
kind: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
204
|
+
label: string;
|
|
205
|
+
src: string;
|
|
206
|
+
srcLang: string;
|
|
207
|
+
default?: boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { }
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
declare module 'react' {
|
|
214
|
+
namespace JSX {
|
|
215
|
+
interface IntrinsicElements {
|
|
216
|
+
'google-cast-launcher': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strataplayer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "A robust, secure, and production-grade video player built for the modern web.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/strataplayer.cjs.js",
|
|
@@ -22,13 +22,6 @@
|
|
|
22
22
|
},
|
|
23
23
|
"./style.css": "./dist/style.css"
|
|
24
24
|
},
|
|
25
|
-
"typesVersions": {
|
|
26
|
-
"*": {
|
|
27
|
-
"hls": [
|
|
28
|
-
"./dist/hls.d.ts"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
25
|
"scripts": {
|
|
33
26
|
"dev": "vite",
|
|
34
27
|
"build": "tsc && vite build --mode lib && vite build --mode demo",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class AudioEngine {
|
|
2
|
-
private context;
|
|
3
|
-
private source;
|
|
4
|
-
private gainNode;
|
|
5
|
-
private video;
|
|
6
|
-
private isInitialized;
|
|
7
|
-
constructor(video: HTMLVideoElement);
|
|
8
|
-
/**
|
|
9
|
-
* Initialize the AudioContext. Must be called after user interaction.
|
|
10
|
-
*/
|
|
11
|
-
init(): void;
|
|
12
|
-
setGain(value: number): void;
|
|
13
|
-
destroy(): void;
|
|
14
|
-
}
|
package/dist/core/EventBus.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type EventCallback<T = any> = (data: T) => void;
|
|
2
|
-
export declare class EventBus {
|
|
3
|
-
private events;
|
|
4
|
-
constructor();
|
|
5
|
-
on<T>(event: string, callback: EventCallback<T>): () => void;
|
|
6
|
-
off<T>(event: string, callback: EventCallback<T>): void;
|
|
7
|
-
emit<T>(event: string, data?: T): void;
|
|
8
|
-
destroy(): void;
|
|
9
|
-
}
|
package/dist/core/NanoStore.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type Listener<T> = (state: T, prevState: T) => void;
|
|
2
|
-
export declare class NanoStore<T> {
|
|
3
|
-
private state;
|
|
4
|
-
private listeners;
|
|
5
|
-
constructor(initialState: T);
|
|
6
|
-
get(): T;
|
|
7
|
-
setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;
|
|
8
|
-
subscribe(listener: Listener<T>): () => void;
|
|
9
|
-
destroy(): void;
|
|
10
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { EventBus } from './EventBus';
|
|
2
|
-
import { NanoStore } from './NanoStore';
|
|
3
|
-
|
|
4
|
-
export interface Notification {
|
|
5
|
-
id: string;
|
|
6
|
-
message: string;
|
|
7
|
-
type: 'info' | 'success' | 'warning' | 'error' | 'loading';
|
|
8
|
-
duration?: number;
|
|
9
|
-
progress?: number;
|
|
10
|
-
}
|
|
11
|
-
export interface SubtitleSettings {
|
|
12
|
-
useNative: boolean;
|
|
13
|
-
fixCapitalization: boolean;
|
|
14
|
-
backgroundOpacity: number;
|
|
15
|
-
backgroundBlur: boolean;
|
|
16
|
-
backgroundBlurAmount: number;
|
|
17
|
-
textSize: number;
|
|
18
|
-
textStyle: 'none' | 'outline' | 'raised' | 'depressed' | 'shadow';
|
|
19
|
-
isBold: boolean;
|
|
20
|
-
textColor: string;
|
|
21
|
-
verticalOffset: number;
|
|
22
|
-
}
|
|
23
|
-
export declare const DEFAULT_SUBTITLE_SETTINGS: SubtitleSettings;
|
|
24
|
-
export type PlayerTheme = 'default' | 'pixel' | 'game' | 'hacker';
|
|
25
|
-
export interface PlayerSource {
|
|
26
|
-
url: string;
|
|
27
|
-
type?: 'hls' | 'mp4' | 'webm' | 'dash' | string;
|
|
28
|
-
name?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface PlayerState {
|
|
31
|
-
isPlaying: boolean;
|
|
32
|
-
isBuffering: boolean;
|
|
33
|
-
currentTime: number;
|
|
34
|
-
duration: number;
|
|
35
|
-
buffered: {
|
|
36
|
-
start: number;
|
|
37
|
-
end: number;
|
|
38
|
-
}[];
|
|
39
|
-
volume: number;
|
|
40
|
-
isMuted: boolean;
|
|
41
|
-
audioGain: number;
|
|
42
|
-
playbackRate: number;
|
|
43
|
-
qualityLevels: {
|
|
44
|
-
height: number;
|
|
45
|
-
bitrate: number;
|
|
46
|
-
index: number;
|
|
47
|
-
}[];
|
|
48
|
-
currentQuality: number;
|
|
49
|
-
audioTracks: {
|
|
50
|
-
label: string;
|
|
51
|
-
language: string;
|
|
52
|
-
index: number;
|
|
53
|
-
}[];
|
|
54
|
-
currentAudioTrack: number;
|
|
55
|
-
error: string | null;
|
|
56
|
-
isFullscreen: boolean;
|
|
57
|
-
isPip: boolean;
|
|
58
|
-
subtitleTracks: {
|
|
59
|
-
label: string;
|
|
60
|
-
language: string;
|
|
61
|
-
index: number;
|
|
62
|
-
}[];
|
|
63
|
-
currentSubtitle: number;
|
|
64
|
-
subtitleOffset: number;
|
|
65
|
-
subtitleSettings: SubtitleSettings;
|
|
66
|
-
activeCues: string[];
|
|
67
|
-
viewMode: 'normal' | 'theater' | 'pip';
|
|
68
|
-
notifications: Notification[];
|
|
69
|
-
iconSize: 'small' | 'medium' | 'large';
|
|
70
|
-
themeColor: string;
|
|
71
|
-
theme: PlayerTheme;
|
|
72
|
-
sources: PlayerSource[];
|
|
73
|
-
currentSourceIndex: number;
|
|
74
|
-
}
|
|
75
|
-
export interface StrataConfig {
|
|
76
|
-
volume?: number;
|
|
77
|
-
muted?: boolean;
|
|
78
|
-
playbackRate?: number;
|
|
79
|
-
audioGain?: number;
|
|
80
|
-
theme?: PlayerTheme;
|
|
81
|
-
themeColor?: string;
|
|
82
|
-
iconSize?: 'small' | 'medium' | 'large';
|
|
83
|
-
subtitleSettings?: Partial<SubtitleSettings>;
|
|
84
|
-
disablePersistence?: boolean;
|
|
85
|
-
}
|
|
86
|
-
export declare const DEFAULT_STATE: PlayerState;
|
|
87
|
-
export declare const getResolvedState: (config?: StrataConfig) => PlayerState;
|
|
88
|
-
export interface IPlugin {
|
|
89
|
-
name: string;
|
|
90
|
-
init(core: StrataCore): void;
|
|
91
|
-
destroy?(): void;
|
|
92
|
-
}
|
|
93
|
-
export interface TextTrackConfig {
|
|
94
|
-
kind: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
95
|
-
label: string;
|
|
96
|
-
src: string;
|
|
97
|
-
srcLang: string;
|
|
98
|
-
default?: boolean;
|
|
99
|
-
}
|
|
100
|
-
export declare class StrataCore {
|
|
101
|
-
video: HTMLVideoElement;
|
|
102
|
-
container: HTMLElement | null;
|
|
103
|
-
events: EventBus;
|
|
104
|
-
store: NanoStore<PlayerState>;
|
|
105
|
-
private plugins;
|
|
106
|
-
private audioEngine;
|
|
107
|
-
private config;
|
|
108
|
-
private retryCount;
|
|
109
|
-
private maxRetries;
|
|
110
|
-
private retryTimer;
|
|
111
|
-
private currentSource;
|
|
112
|
-
private currentSrc;
|
|
113
|
-
private currentTracks;
|
|
114
|
-
private castInitialized;
|
|
115
|
-
private boundCueChange;
|
|
116
|
-
private boundFullscreenChange;
|
|
117
|
-
constructor(config?: StrataConfig, videoElement?: HTMLVideoElement);
|
|
118
|
-
private initVideoListeners;
|
|
119
|
-
triggerError(message: string, isFatal?: boolean): void;
|
|
120
|
-
private handleError;
|
|
121
|
-
private updateBuffer;
|
|
122
|
-
private updateSubtitles;
|
|
123
|
-
fetchWithRetry(url: string, retries?: number): Promise<Response>;
|
|
124
|
-
attach(container: HTMLElement): void;
|
|
125
|
-
use(plugin: IPlugin): void;
|
|
126
|
-
setSources(sources: PlayerSource[], tracks?: TextTrackConfig[]): void;
|
|
127
|
-
switchSource(index: number): void;
|
|
128
|
-
load(source: PlayerSource | string, tracks?: TextTrackConfig[], isRetry?: boolean): void;
|
|
129
|
-
addTextTrack(file: File, label: string): void;
|
|
130
|
-
private addTextTrackInternal;
|
|
131
|
-
play(): Promise<void>;
|
|
132
|
-
pause(): void;
|
|
133
|
-
togglePlay(): void;
|
|
134
|
-
seek(time: number): void;
|
|
135
|
-
skip(seconds: number): void;
|
|
136
|
-
setVolume(vol: number): void;
|
|
137
|
-
toggleMute(): void;
|
|
138
|
-
setAudioGain(gain: number): void;
|
|
139
|
-
setQuality(index: number): void;
|
|
140
|
-
setAudioTrack(index: number): void;
|
|
141
|
-
toggleFullscreen(): void;
|
|
142
|
-
togglePip(): void;
|
|
143
|
-
private initCast;
|
|
144
|
-
requestCast(): void;
|
|
145
|
-
private loadMediaToCast;
|
|
146
|
-
private handleCueChange;
|
|
147
|
-
setSubtitle(index: number): void;
|
|
148
|
-
updateSubtitleSettings(settings: Partial<SubtitleSettings>): void;
|
|
149
|
-
resetSubtitleSettings(): void;
|
|
150
|
-
setSubtitleOffset(offset: number): void;
|
|
151
|
-
download(): Promise<void>;
|
|
152
|
-
notify(n: Omit<Notification, 'id'> & {
|
|
153
|
-
id?: string;
|
|
154
|
-
}): string;
|
|
155
|
-
removeNotification(id: string): void;
|
|
156
|
-
setAppearance(settings: {
|
|
157
|
-
iconSize?: 'small' | 'medium' | 'large';
|
|
158
|
-
themeColor?: string;
|
|
159
|
-
theme?: PlayerTheme;
|
|
160
|
-
}): void;
|
|
161
|
-
destroy(): void;
|
|
162
|
-
}
|
package/dist/lib.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { StrataPlayer } from './ui/StrataPlayer';
|
|
2
|
-
import { StrataCore, PlayerState, PlayerSource, StrataConfig, TextTrackConfig } from './core/StrataCore';
|
|
3
|
-
|
|
4
|
-
export { StrataPlayer };
|
|
5
|
-
export { StrataCore };
|
|
6
|
-
export type { PlayerState, PlayerSource, StrataConfig, TextTrackConfig };
|
|
7
|
-
export interface StrataPlayerInstance {
|
|
8
|
-
unmount: () => void;
|
|
9
|
-
update: (props: any) => void;
|
|
10
|
-
}
|
|
11
|
-
export declare const mountStrataPlayer: (container: HTMLElement, props: any) => StrataPlayerInstance;
|
package/dist/ui/Icons.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export declare const PlayIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
2
|
-
export declare const PauseIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
3
|
-
export declare const VolumeHighIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
4
|
-
export declare const VolumeLowIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
5
|
-
export declare const VolumeMuteIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
6
|
-
export declare const MaximizeIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
7
|
-
export declare const MinimizeIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
8
|
-
export declare const SettingsIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
9
|
-
export declare const CheckIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
10
|
-
export declare const PipIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
11
|
-
export declare const SubtitleIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
12
|
-
export declare const DownloadIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
13
|
-
export declare const UploadIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
14
|
-
export declare const ArrowLeftIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
15
|
-
export declare const LoaderIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
16
|
-
export declare const CastIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
17
|
-
export declare const UsersIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
18
|
-
export declare const ClockIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
19
|
-
export declare const MinusIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
20
|
-
export declare const PlusIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
21
|
-
export declare const CustomizeIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
22
|
-
export declare const TypeIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
23
|
-
export declare const PaletteIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
24
|
-
export declare const EyeIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
25
|
-
export declare const MoveVerticalIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
26
|
-
export declare const ResetIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
27
|
-
export declare const BoldIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
28
|
-
export declare const CaseUpperIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
29
|
-
export declare const BlurIcon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
|
|
30
|
-
export declare const Replay10Icon: ({ className }: {
|
|
31
|
-
className?: string;
|
|
32
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export declare const Forward10Icon: ({ className }: {
|
|
34
|
-
className?: string;
|
|
35
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
-
export declare const StrataLogo: ({ className }: {
|
|
37
|
-
className?: string;
|
|
38
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { TextTrackConfig, StrataConfig, IPlugin, PlayerSource } from '../core/StrataCore';
|
|
3
|
-
|
|
4
|
-
declare module 'react' {
|
|
5
|
-
namespace JSX {
|
|
6
|
-
interface IntrinsicElements {
|
|
7
|
-
'google-cast-launcher': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
interface StrataPlayerProps extends StrataConfig {
|
|
12
|
-
src?: string;
|
|
13
|
-
sources?: PlayerSource[];
|
|
14
|
-
poster?: string;
|
|
15
|
-
autoPlay?: boolean;
|
|
16
|
-
thumbnails?: string;
|
|
17
|
-
textTracks?: TextTrackConfig[];
|
|
18
|
-
plugins?: IPlugin[];
|
|
19
|
-
}
|
|
20
|
-
export declare const StrataPlayer: (props: StrataPlayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
|
|
3
|
-
export declare const Menu: ({ children, onClose, align, maxHeight, className }: {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
align?: "right" | "center";
|
|
7
|
-
maxHeight?: number;
|
|
8
|
-
className?: string;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export declare const MenuItem: ({ label, value, active, onClick, hasSubmenu, icon }: any) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare const MenuHeader: ({ label, onBack, rightAction }: {
|
|
12
|
-
label: string;
|
|
13
|
-
onBack: () => void;
|
|
14
|
-
rightAction?: React.ReactNode;
|
|
15
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare const MenuDivider: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const Toggle: ({ label, checked, onChange, icon }: any) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
-
export declare const Slider: ({ label, value, min, max, step, onChange, formatValue, icon }: any) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare const Select: ({ label, value, options, onChange, icon }: any) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
export declare const SettingsGroup: ({ title, children }: any) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SubtitleMenu: ({ tracks, current, onSelect, onUpload, onClose, settings, onSettingsChange, onReset, offset, onOffsetChange, maxHeight, animationClass }: any) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const formatTime: (seconds: number) => string;
|
|
2
|
-
export interface ThumbnailCue {
|
|
3
|
-
start: number;
|
|
4
|
-
end: number;
|
|
5
|
-
url: string;
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
w: number;
|
|
9
|
-
h: number;
|
|
10
|
-
}
|
|
11
|
-
export declare const parseVTT: (url: string, notify: (msg: any) => void) => Promise<ThumbnailCue[]>;
|