strataplayer 1.1.0 → 1.2.0
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 +80 -114
- package/dist/dash.d.ts +120 -5
- package/dist/hls.d.ts +120 -5
- package/dist/index.d.ts +121 -6
- package/dist/mpegts.d.ts +120 -5
- package/dist/strataplayer.cjs.js +80 -42
- package/dist/strataplayer.cjs.js.map +1 -1
- package/dist/strataplayer.es.js +1315 -717
- package/dist/strataplayer.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webtorrent.cjs.js.map +1 -1
- package/dist/webtorrent.d.ts +120 -5
- package/dist/webtorrent.es.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<img src="https://dev-ashishranjan.github.io/StrataPlayer/logo.png" alt="StrataPlayer Logo" width="128" />
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
|
-
<strong>
|
|
7
|
+
<strong>A Universal Media Engine for the Web.</strong>
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
|
|
23
23
|
## Introduction
|
|
24
24
|
|
|
25
|
-
StrataPlayer is a
|
|
25
|
+
StrataPlayer is a framework-agnostic media engine designed for web applications. It decouples playback logic from the UI, ensuring consistent performance during state updates.
|
|
26
26
|
|
|
27
|
-
Built on **React 19** and **TypeScript**, it features a modular plugin architecture
|
|
27
|
+
Built on **React 19** and **TypeScript**, it features a modular plugin architecture to support various streaming formats while keeping the core bundle size minimal.
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Key Features
|
|
30
30
|
|
|
31
31
|
- **Universal Playback:** Support for **HLS**, **DASH**, **MPEG-TS/FLV**, and **WebTorrent** (P2P).
|
|
32
|
-
- **Framework Agnostic:** First-class React support
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
35
|
-
- **
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
- **State Management:** Powered by `NanoStore` for isolated
|
|
32
|
+
- **Framework Agnostic:** First-class React support with mounting helpers for Vue, Svelte, Angular, and Vanilla JS.
|
|
33
|
+
- **Network Handling:** Automatic exponential backoff and retry logic.
|
|
34
|
+
- **Audio Engine:** Integrated Web Audio API nodes for gain control and volume boosting.
|
|
35
|
+
- **UI System:**
|
|
36
|
+
- 4 built-in themes (Default, Pixel, Game, Hacker).
|
|
37
|
+
- VTT/SRT subtitle support with user customization.
|
|
38
|
+
- Picture-in-Picture & Google Cast integration.
|
|
39
|
+
- **State Management:** Powered by `NanoStore` for isolated state updates.
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## Installation
|
|
42
42
|
|
|
43
43
|
Install the core player:
|
|
44
44
|
|
|
@@ -62,7 +62,7 @@ npm install mpegts.js
|
|
|
62
62
|
npm install webtorrent
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
##
|
|
65
|
+
## Usage
|
|
66
66
|
|
|
67
67
|
### 1. Basic Usage (React)
|
|
68
68
|
|
|
@@ -141,55 +141,68 @@ const player = mountStrataPlayer(container, {
|
|
|
141
141
|
// player.unmount();
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
##
|
|
145
|
-
|
|
146
|
-
The `<StrataPlayer />` component accepts the following
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
| **
|
|
153
|
-
| **
|
|
154
|
-
| **
|
|
155
|
-
| **
|
|
156
|
-
| **
|
|
157
|
-
| **
|
|
158
|
-
| **
|
|
159
|
-
| **
|
|
160
|
-
| **
|
|
161
|
-
| **
|
|
162
|
-
| **
|
|
163
|
-
| **
|
|
164
|
-
| **
|
|
165
|
-
|
|
166
|
-
###
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
144
|
+
## Component Props & Options
|
|
145
|
+
|
|
146
|
+
The `<StrataPlayer />` component accepts the following configuration options.
|
|
147
|
+
|
|
148
|
+
### Source & Playback
|
|
149
|
+
|
|
150
|
+
| Prop | Type | Default | Description |
|
|
151
|
+
| :--------------- | :------------------ | :------ | :------------------------------------------------------------ |
|
|
152
|
+
| **src** | `string` | - | The primary media URL. |
|
|
153
|
+
| **sources** | `PlayerSource[]` | `[]` | Array of sources for quality fallback or alternative formats. |
|
|
154
|
+
| **poster** | `string` | - | URL for the poster image. |
|
|
155
|
+
| **thumbnails** | `string` | - | URL to a VTT file for hover previews. |
|
|
156
|
+
| **textTracks** | `TextTrackConfig[]` | `[]` | Array of subtitle/caption tracks. |
|
|
157
|
+
| **plugins** | `IPlugin[]` | `[]` | Array of initialized plugin instances. |
|
|
158
|
+
| **autoPlay** | `boolean` | `false` | Start playback automatically. |
|
|
159
|
+
| **loop** | `boolean` | `false` | Loop playback. |
|
|
160
|
+
| **volume** | `number` | `1` | Initial volume (0.0 to 1.0). |
|
|
161
|
+
| **muted** | `boolean` | `false` | Initial mute state. |
|
|
162
|
+
| **audioGain** | `number` | `1` | Audio boost level (e.g., `1.5` for 150%). |
|
|
163
|
+
| **playbackRate** | `number` | `1` | Initial playback speed. |
|
|
164
|
+
| **isLive** | `boolean` | `false` | Enable live stream UI mode. |
|
|
165
|
+
|
|
166
|
+
### UI & Appearance
|
|
167
|
+
|
|
168
|
+
| Prop | Type | Default | Description |
|
|
169
|
+
| :------------- | :------------ | :---------- | :----------------------------------------------- |
|
|
170
|
+
| **theme** | `string` | `'default'` | `'default'`, `'pixel'`, `'game'`, or `'hacker'`. |
|
|
171
|
+
| **themeColor** | `string` | `'#6366f1'` | Primary accent color (Hex, RGB). |
|
|
172
|
+
| **iconSize** | `string` | `'medium'` | `'small'`, `'medium'`, or `'large'`. |
|
|
173
|
+
| **backdrop** | `boolean` | `true` | Enable background blur effects in menus. |
|
|
174
|
+
| **autoSize** | `boolean` | `false` | Toggles `object-fit: cover`. |
|
|
175
|
+
| **highlight** | `Highlight[]` | `[]` | Markers to display on the timeline. |
|
|
176
|
+
|
|
177
|
+
### Functionality & Controls
|
|
178
|
+
|
|
179
|
+
| Prop | Type | Default | Description |
|
|
180
|
+
| :--------------------- | :-------- | :------ | :---------------------------------------- |
|
|
181
|
+
| **hotKey** | `boolean` | `true` | Enable keyboard shortcuts. |
|
|
182
|
+
| **screenshot** | `boolean` | `false` | Show screenshot button. |
|
|
183
|
+
| **pip** | `boolean` | `true` | Show Picture-in-Picture button. |
|
|
184
|
+
| **setting** | `boolean` | `true` | Show Settings menu. |
|
|
185
|
+
| **fullscreen** | `boolean` | `true` | Show Fullscreen button. |
|
|
186
|
+
| **fullscreenWeb** | `boolean` | `false` | Show Web Fullscreen button. |
|
|
187
|
+
| **flip** | `boolean` | `true` | Enable image flip controls in settings. |
|
|
188
|
+
| **aspectRatio** | `boolean` | `true` | Enable aspect ratio controls in settings. |
|
|
189
|
+
| **lock** | `boolean` | `false` | Show mobile lock button. |
|
|
190
|
+
| **fastForward** | `boolean` | `true` | Enable long-press to 2x speed. |
|
|
191
|
+
| **autoOrientation** | `boolean` | `false` | Lock landscape on mobile fullscreen. |
|
|
192
|
+
| **disablePersistence** | `boolean` | `false` | Prevent saving settings to LocalStorage. |
|
|
193
|
+
|
|
194
|
+
### Advanced Customization
|
|
195
|
+
|
|
196
|
+
> Detailed documentation for configuring layers, controls, context menus, and custom settings is available in the full documentation.
|
|
197
|
+
|
|
198
|
+
| Prop | Type | Description |
|
|
199
|
+
| :-------------- | :------------------ | :------------------------------------- |
|
|
200
|
+
| **controls** | `ControlItem[]` | Custom control bar items. |
|
|
201
|
+
| **layers** | `LayerConfig[]` | Custom UI layers overlaying the video. |
|
|
202
|
+
| **contextmenu** | `ContextMenuItem[]` | Custom right-click menu items. |
|
|
203
|
+
| **settings** | `SettingItem[]` | Custom menu entries. |
|
|
204
|
+
|
|
205
|
+
## Plugin System
|
|
193
206
|
|
|
194
207
|
StrataPlayer uses a modular system. You only pay the bundle size cost for the formats you use.
|
|
195
208
|
|
|
@@ -200,54 +213,7 @@ StrataPlayer uses a modular system. You only pay the bundle size cost for the fo
|
|
|
200
213
|
| **MpegtsPlugin** | `strataplayer/mpegts` | `mpegts.js` | MPEG-TS and FLV live streams |
|
|
201
214
|
| **WebTorrentPlugin** | `strataplayer/webtorrent` | `webtorrent` | P2P streaming via WebRTC |
|
|
202
215
|
|
|
203
|
-
##
|
|
204
|
-
|
|
205
|
-
### Sources & Tracks
|
|
206
|
-
|
|
207
|
-
Support multiple sources for quality fallback and detailed subtitle configuration.
|
|
208
|
-
|
|
209
|
-
```tsx
|
|
210
|
-
<StrataPlayer
|
|
211
|
-
sources={[
|
|
212
|
-
{ name: "HLS Master", url: "master.m3u8", type: "hls" },
|
|
213
|
-
{ name: "Fallback MP4", url: "fallback.mp4", type: "mp4" },
|
|
214
|
-
]}
|
|
215
|
-
poster="https://example.com/poster.jpg"
|
|
216
|
-
thumbnails="https://example.com/storyboard.vtt" // for hover previews
|
|
217
|
-
textTracks={[
|
|
218
|
-
{
|
|
219
|
-
kind: "subtitles",
|
|
220
|
-
label: "English",
|
|
221
|
-
src: "/subs/en.vtt",
|
|
222
|
-
srcLang: "en",
|
|
223
|
-
default: true,
|
|
224
|
-
},
|
|
225
|
-
]}
|
|
226
|
-
/>
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### UI & Themes
|
|
230
|
-
|
|
231
|
-
The player includes 4 professionally designed themes.
|
|
232
|
-
|
|
233
|
-
| Theme | Description |
|
|
234
|
-
| :-------- | :------------------------------------------------------------ |
|
|
235
|
-
| `default` | Clean, modern aesthetic using Inter font. |
|
|
236
|
-
| `pixel` | Retro 8-bit style with sharp edges and "Press Start 2P" font. |
|
|
237
|
-
| `game` | Cinematic RPG style with serif typography and gold accents. |
|
|
238
|
-
| `hacker` | Terminal-inspired look with scanlines and monospaced fonts. |
|
|
239
|
-
|
|
240
|
-
Customize further with:
|
|
241
|
-
|
|
242
|
-
```tsx
|
|
243
|
-
<StrataPlayer
|
|
244
|
-
theme="game"
|
|
245
|
-
themeColor="#10b981" // Custom accent color
|
|
246
|
-
iconSize="medium" // 'small' | 'medium' | 'large'
|
|
247
|
-
/>
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## ⌨️ Keyboard Shortcuts
|
|
216
|
+
## Keyboard Shortcuts
|
|
251
217
|
|
|
252
218
|
| Key | Action |
|
|
253
219
|
| ------------- | ----------------- |
|
|
@@ -259,7 +225,7 @@ Customize further with:
|
|
|
259
225
|
| `Arrow Up` | Increase Volume |
|
|
260
226
|
| `Arrow Down` | Decrease Volume |
|
|
261
227
|
|
|
262
|
-
##
|
|
228
|
+
## Development
|
|
263
229
|
|
|
264
230
|
1. Clone the repository
|
|
265
231
|
2. Install dependencies:
|
|
@@ -271,7 +237,7 @@ Customize further with:
|
|
|
271
237
|
npm run dev
|
|
272
238
|
```
|
|
273
239
|
|
|
274
|
-
##
|
|
240
|
+
## Contributing
|
|
275
241
|
|
|
276
242
|
Contributions are welcome! Please follow these steps:
|
|
277
243
|
|
|
@@ -281,7 +247,7 @@ Contributions are welcome! Please follow these steps:
|
|
|
281
247
|
4. Push to the branch.
|
|
282
248
|
5. Open a Pull Request.
|
|
283
249
|
|
|
284
|
-
##
|
|
250
|
+
## License
|
|
285
251
|
|
|
286
252
|
Distributed under the MIT License. See `LICENSE` for more information.
|
|
287
253
|
|
package/dist/dash.d.ts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
|
|
3
|
+
declare interface ContextMenuItem {
|
|
4
|
+
html?: string | default_2.ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
icon?: string | default_2.ReactNode;
|
|
7
|
+
onClick?: (close: () => void) => void;
|
|
8
|
+
click?: (close: () => void) => void;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
showBorder?: boolean;
|
|
11
|
+
separator?: boolean;
|
|
12
|
+
isLabel?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare interface ControlItem {
|
|
16
|
+
id?: string;
|
|
17
|
+
position: 'left' | 'right' | 'center';
|
|
18
|
+
index: number;
|
|
19
|
+
html?: string | default_2.ReactNode;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
onClick?: (core: StrataCore) => void;
|
|
22
|
+
click?: (core: StrataCore) => void;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: default_2.CSSProperties;
|
|
25
|
+
isBuiltIn?: boolean;
|
|
26
|
+
builtInId?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
1
29
|
export declare class DashPlugin implements IPlugin {
|
|
2
30
|
name: string;
|
|
3
31
|
private player;
|
|
@@ -20,12 +48,26 @@ declare class EventBus {
|
|
|
20
48
|
|
|
21
49
|
declare type EventCallback<T = any> = (data: T) => void;
|
|
22
50
|
|
|
51
|
+
declare interface Highlight_2 {
|
|
52
|
+
time: number;
|
|
53
|
+
text: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
23
56
|
declare interface IPlugin {
|
|
24
57
|
name: string;
|
|
25
58
|
init(core: StrataCore): void;
|
|
26
59
|
destroy?(): void;
|
|
27
60
|
}
|
|
28
61
|
|
|
62
|
+
declare interface LayerConfig {
|
|
63
|
+
name?: string;
|
|
64
|
+
html: string | default_2.ReactNode;
|
|
65
|
+
style?: default_2.CSSProperties;
|
|
66
|
+
className?: string;
|
|
67
|
+
click?: () => void;
|
|
68
|
+
mounted?: (element: HTMLElement) => void;
|
|
69
|
+
}
|
|
70
|
+
|
|
29
71
|
declare type Listener<T> = (state: T, prevState: T) => void;
|
|
30
72
|
|
|
31
73
|
declare class NanoStore<T> {
|
|
@@ -55,6 +97,7 @@ declare interface PlayerSource {
|
|
|
55
97
|
declare interface PlayerState {
|
|
56
98
|
isPlaying: boolean;
|
|
57
99
|
isBuffering: boolean;
|
|
100
|
+
isLive: boolean;
|
|
58
101
|
currentTime: number;
|
|
59
102
|
duration: number;
|
|
60
103
|
buffered: {
|
|
@@ -96,19 +139,65 @@ declare interface PlayerState {
|
|
|
96
139
|
theme: PlayerTheme;
|
|
97
140
|
sources: PlayerSource[];
|
|
98
141
|
currentSourceIndex: number;
|
|
142
|
+
isLocked: boolean;
|
|
143
|
+
flipState: {
|
|
144
|
+
horizontal: boolean;
|
|
145
|
+
vertical: boolean;
|
|
146
|
+
};
|
|
147
|
+
aspectRatio: string;
|
|
148
|
+
isAutoSized: boolean;
|
|
149
|
+
isLooping: boolean;
|
|
150
|
+
controlsVisible: boolean;
|
|
99
151
|
}
|
|
100
152
|
|
|
101
153
|
declare type PlayerTheme = 'default' | 'pixel' | 'game' | 'hacker';
|
|
102
154
|
|
|
155
|
+
declare interface SettingItem {
|
|
156
|
+
id?: string;
|
|
157
|
+
html: string | default_2.ReactNode;
|
|
158
|
+
icon?: string | default_2.ReactNode;
|
|
159
|
+
tooltip?: string;
|
|
160
|
+
switch?: boolean;
|
|
161
|
+
onSwitch?: (item: SettingItem) => boolean | void;
|
|
162
|
+
onClick?: () => void;
|
|
163
|
+
click?: () => void;
|
|
164
|
+
isDefault?: boolean;
|
|
165
|
+
}
|
|
166
|
+
|
|
103
167
|
declare interface StrataConfig {
|
|
168
|
+
container?: string;
|
|
169
|
+
id?: string;
|
|
104
170
|
volume?: number;
|
|
105
171
|
muted?: boolean;
|
|
106
172
|
playbackRate?: number;
|
|
107
173
|
audioGain?: number;
|
|
174
|
+
loop?: boolean;
|
|
175
|
+
playsInline?: boolean;
|
|
176
|
+
isLive?: boolean;
|
|
108
177
|
theme?: PlayerTheme;
|
|
109
178
|
themeColor?: string;
|
|
110
179
|
iconSize?: 'small' | 'medium' | 'large';
|
|
180
|
+
backdrop?: boolean;
|
|
181
|
+
autoSize?: boolean;
|
|
111
182
|
subtitleSettings?: Partial<SubtitleSettings>;
|
|
183
|
+
screenshot?: boolean;
|
|
184
|
+
setting?: boolean;
|
|
185
|
+
pip?: boolean;
|
|
186
|
+
fullscreen?: boolean;
|
|
187
|
+
fullscreenWeb?: boolean;
|
|
188
|
+
flip?: boolean;
|
|
189
|
+
aspectRatio?: boolean;
|
|
190
|
+
highlight?: Highlight_2[];
|
|
191
|
+
hotKey?: boolean;
|
|
192
|
+
lock?: boolean;
|
|
193
|
+
gesture?: boolean;
|
|
194
|
+
fastForward?: boolean;
|
|
195
|
+
autoOrientation?: boolean;
|
|
196
|
+
layers?: LayerConfig[];
|
|
197
|
+
contextmenu?: ContextMenuItem[];
|
|
198
|
+
controls?: ControlItem[];
|
|
199
|
+
settings?: SettingItem[];
|
|
200
|
+
useSSR?: boolean;
|
|
112
201
|
disablePersistence?: boolean;
|
|
113
202
|
}
|
|
114
203
|
|
|
@@ -119,7 +208,8 @@ declare class StrataCore {
|
|
|
119
208
|
store: NanoStore<PlayerState>;
|
|
120
209
|
private plugins;
|
|
121
210
|
private audioEngine;
|
|
122
|
-
|
|
211
|
+
config: StrataConfig;
|
|
212
|
+
private resizeObserver;
|
|
123
213
|
private retryCount;
|
|
124
214
|
private maxRetries;
|
|
125
215
|
private retryTimer;
|
|
@@ -130,6 +220,24 @@ declare class StrataCore {
|
|
|
130
220
|
private boundCueChange;
|
|
131
221
|
private boundFullscreenChange;
|
|
132
222
|
constructor(config?: StrataConfig, videoElement?: HTMLVideoElement);
|
|
223
|
+
get playing(): boolean;
|
|
224
|
+
get currentTime(): number;
|
|
225
|
+
set currentTime(val: number);
|
|
226
|
+
get duration(): number;
|
|
227
|
+
get paused(): boolean;
|
|
228
|
+
get volume(): number;
|
|
229
|
+
set volume(val: number);
|
|
230
|
+
get muted(): boolean;
|
|
231
|
+
set muted(val: boolean);
|
|
232
|
+
get playbackRate(): number;
|
|
233
|
+
set playbackRate(val: number);
|
|
234
|
+
get loop(): boolean;
|
|
235
|
+
set loop(val: boolean);
|
|
236
|
+
forward(seconds?: number): void;
|
|
237
|
+
backward(seconds?: number): void;
|
|
238
|
+
on(event: string, callback: EventCallback): () => void;
|
|
239
|
+
off(event: string, callback: EventCallback): void;
|
|
240
|
+
emit(event: string, data?: any): void;
|
|
133
241
|
private initVideoListeners;
|
|
134
242
|
triggerError(message: string, isFatal?: boolean): void;
|
|
135
243
|
private handleError;
|
|
@@ -141,6 +249,7 @@ declare class StrataCore {
|
|
|
141
249
|
setSources(sources: PlayerSource[], tracks?: TextTrackConfig[]): void;
|
|
142
250
|
switchSource(index: number): void;
|
|
143
251
|
load(source: PlayerSource | string, tracks?: TextTrackConfig[], isRetry?: boolean): void;
|
|
252
|
+
loadSubtitle(url: string, label?: string): void;
|
|
144
253
|
addTextTrack(file: File, label: string): void;
|
|
145
254
|
private addTextTrackInternal;
|
|
146
255
|
play(): Promise<void>;
|
|
@@ -153,8 +262,14 @@ declare class StrataCore {
|
|
|
153
262
|
setAudioGain(gain: number): void;
|
|
154
263
|
setQuality(index: number): void;
|
|
155
264
|
setAudioTrack(index: number): void;
|
|
156
|
-
|
|
265
|
+
setControlsVisible(visible: boolean): void;
|
|
266
|
+
toggleFullscreen(): Promise<void>;
|
|
157
267
|
togglePip(): void;
|
|
268
|
+
screenshot(): void;
|
|
269
|
+
toggleLock(): void;
|
|
270
|
+
toggleLoop(): void;
|
|
271
|
+
setFlip(direction: 'horizontal' | 'vertical'): void;
|
|
272
|
+
setAspectRatio(ratio: string): void;
|
|
158
273
|
private initCast;
|
|
159
274
|
requestCast(): void;
|
|
160
275
|
private loadMediaToCast;
|
|
@@ -190,11 +305,11 @@ declare interface SubtitleSettings {
|
|
|
190
305
|
}
|
|
191
306
|
|
|
192
307
|
declare interface TextTrackConfig {
|
|
193
|
-
kind: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
194
|
-
label: string;
|
|
195
308
|
src: string;
|
|
196
|
-
|
|
309
|
+
label: string;
|
|
310
|
+
srcLang?: string;
|
|
197
311
|
default?: boolean;
|
|
312
|
+
kind?: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
198
313
|
}
|
|
199
314
|
|
|
200
315
|
export { }
|
package/dist/hls.d.ts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
|
|
3
|
+
declare interface ContextMenuItem {
|
|
4
|
+
html?: string | default_2.ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
icon?: string | default_2.ReactNode;
|
|
7
|
+
onClick?: (close: () => void) => void;
|
|
8
|
+
click?: (close: () => void) => void;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
showBorder?: boolean;
|
|
11
|
+
separator?: boolean;
|
|
12
|
+
isLabel?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare interface ControlItem {
|
|
16
|
+
id?: string;
|
|
17
|
+
position: 'left' | 'right' | 'center';
|
|
18
|
+
index: number;
|
|
19
|
+
html?: string | default_2.ReactNode;
|
|
20
|
+
tooltip?: string;
|
|
21
|
+
onClick?: (core: StrataCore) => void;
|
|
22
|
+
click?: (core: StrataCore) => void;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: default_2.CSSProperties;
|
|
25
|
+
isBuiltIn?: boolean;
|
|
26
|
+
builtInId?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
1
29
|
declare class EventBus {
|
|
2
30
|
private events;
|
|
3
31
|
constructor();
|
|
@@ -9,6 +37,11 @@ declare class EventBus {
|
|
|
9
37
|
|
|
10
38
|
declare type EventCallback<T = any> = (data: T) => void;
|
|
11
39
|
|
|
40
|
+
declare interface Highlight_2 {
|
|
41
|
+
time: number;
|
|
42
|
+
text: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
12
45
|
export declare class HlsPlugin implements IPlugin {
|
|
13
46
|
name: string;
|
|
14
47
|
private hls;
|
|
@@ -24,6 +57,15 @@ declare interface IPlugin {
|
|
|
24
57
|
destroy?(): void;
|
|
25
58
|
}
|
|
26
59
|
|
|
60
|
+
declare interface LayerConfig {
|
|
61
|
+
name?: string;
|
|
62
|
+
html: string | default_2.ReactNode;
|
|
63
|
+
style?: default_2.CSSProperties;
|
|
64
|
+
className?: string;
|
|
65
|
+
click?: () => void;
|
|
66
|
+
mounted?: (element: HTMLElement) => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
27
69
|
declare type Listener<T> = (state: T, prevState: T) => void;
|
|
28
70
|
|
|
29
71
|
declare class NanoStore<T> {
|
|
@@ -53,6 +95,7 @@ declare interface PlayerSource {
|
|
|
53
95
|
declare interface PlayerState {
|
|
54
96
|
isPlaying: boolean;
|
|
55
97
|
isBuffering: boolean;
|
|
98
|
+
isLive: boolean;
|
|
56
99
|
currentTime: number;
|
|
57
100
|
duration: number;
|
|
58
101
|
buffered: {
|
|
@@ -94,19 +137,65 @@ declare interface PlayerState {
|
|
|
94
137
|
theme: PlayerTheme;
|
|
95
138
|
sources: PlayerSource[];
|
|
96
139
|
currentSourceIndex: number;
|
|
140
|
+
isLocked: boolean;
|
|
141
|
+
flipState: {
|
|
142
|
+
horizontal: boolean;
|
|
143
|
+
vertical: boolean;
|
|
144
|
+
};
|
|
145
|
+
aspectRatio: string;
|
|
146
|
+
isAutoSized: boolean;
|
|
147
|
+
isLooping: boolean;
|
|
148
|
+
controlsVisible: boolean;
|
|
97
149
|
}
|
|
98
150
|
|
|
99
151
|
declare type PlayerTheme = 'default' | 'pixel' | 'game' | 'hacker';
|
|
100
152
|
|
|
153
|
+
declare interface SettingItem {
|
|
154
|
+
id?: string;
|
|
155
|
+
html: string | default_2.ReactNode;
|
|
156
|
+
icon?: string | default_2.ReactNode;
|
|
157
|
+
tooltip?: string;
|
|
158
|
+
switch?: boolean;
|
|
159
|
+
onSwitch?: (item: SettingItem) => boolean | void;
|
|
160
|
+
onClick?: () => void;
|
|
161
|
+
click?: () => void;
|
|
162
|
+
isDefault?: boolean;
|
|
163
|
+
}
|
|
164
|
+
|
|
101
165
|
declare interface StrataConfig {
|
|
166
|
+
container?: string;
|
|
167
|
+
id?: string;
|
|
102
168
|
volume?: number;
|
|
103
169
|
muted?: boolean;
|
|
104
170
|
playbackRate?: number;
|
|
105
171
|
audioGain?: number;
|
|
172
|
+
loop?: boolean;
|
|
173
|
+
playsInline?: boolean;
|
|
174
|
+
isLive?: boolean;
|
|
106
175
|
theme?: PlayerTheme;
|
|
107
176
|
themeColor?: string;
|
|
108
177
|
iconSize?: 'small' | 'medium' | 'large';
|
|
178
|
+
backdrop?: boolean;
|
|
179
|
+
autoSize?: boolean;
|
|
109
180
|
subtitleSettings?: Partial<SubtitleSettings>;
|
|
181
|
+
screenshot?: boolean;
|
|
182
|
+
setting?: boolean;
|
|
183
|
+
pip?: boolean;
|
|
184
|
+
fullscreen?: boolean;
|
|
185
|
+
fullscreenWeb?: boolean;
|
|
186
|
+
flip?: boolean;
|
|
187
|
+
aspectRatio?: boolean;
|
|
188
|
+
highlight?: Highlight_2[];
|
|
189
|
+
hotKey?: boolean;
|
|
190
|
+
lock?: boolean;
|
|
191
|
+
gesture?: boolean;
|
|
192
|
+
fastForward?: boolean;
|
|
193
|
+
autoOrientation?: boolean;
|
|
194
|
+
layers?: LayerConfig[];
|
|
195
|
+
contextmenu?: ContextMenuItem[];
|
|
196
|
+
controls?: ControlItem[];
|
|
197
|
+
settings?: SettingItem[];
|
|
198
|
+
useSSR?: boolean;
|
|
110
199
|
disablePersistence?: boolean;
|
|
111
200
|
}
|
|
112
201
|
|
|
@@ -117,7 +206,8 @@ declare class StrataCore {
|
|
|
117
206
|
store: NanoStore<PlayerState>;
|
|
118
207
|
private plugins;
|
|
119
208
|
private audioEngine;
|
|
120
|
-
|
|
209
|
+
config: StrataConfig;
|
|
210
|
+
private resizeObserver;
|
|
121
211
|
private retryCount;
|
|
122
212
|
private maxRetries;
|
|
123
213
|
private retryTimer;
|
|
@@ -128,6 +218,24 @@ declare class StrataCore {
|
|
|
128
218
|
private boundCueChange;
|
|
129
219
|
private boundFullscreenChange;
|
|
130
220
|
constructor(config?: StrataConfig, videoElement?: HTMLVideoElement);
|
|
221
|
+
get playing(): boolean;
|
|
222
|
+
get currentTime(): number;
|
|
223
|
+
set currentTime(val: number);
|
|
224
|
+
get duration(): number;
|
|
225
|
+
get paused(): boolean;
|
|
226
|
+
get volume(): number;
|
|
227
|
+
set volume(val: number);
|
|
228
|
+
get muted(): boolean;
|
|
229
|
+
set muted(val: boolean);
|
|
230
|
+
get playbackRate(): number;
|
|
231
|
+
set playbackRate(val: number);
|
|
232
|
+
get loop(): boolean;
|
|
233
|
+
set loop(val: boolean);
|
|
234
|
+
forward(seconds?: number): void;
|
|
235
|
+
backward(seconds?: number): void;
|
|
236
|
+
on(event: string, callback: EventCallback): () => void;
|
|
237
|
+
off(event: string, callback: EventCallback): void;
|
|
238
|
+
emit(event: string, data?: any): void;
|
|
131
239
|
private initVideoListeners;
|
|
132
240
|
triggerError(message: string, isFatal?: boolean): void;
|
|
133
241
|
private handleError;
|
|
@@ -139,6 +247,7 @@ declare class StrataCore {
|
|
|
139
247
|
setSources(sources: PlayerSource[], tracks?: TextTrackConfig[]): void;
|
|
140
248
|
switchSource(index: number): void;
|
|
141
249
|
load(source: PlayerSource | string, tracks?: TextTrackConfig[], isRetry?: boolean): void;
|
|
250
|
+
loadSubtitle(url: string, label?: string): void;
|
|
142
251
|
addTextTrack(file: File, label: string): void;
|
|
143
252
|
private addTextTrackInternal;
|
|
144
253
|
play(): Promise<void>;
|
|
@@ -151,8 +260,14 @@ declare class StrataCore {
|
|
|
151
260
|
setAudioGain(gain: number): void;
|
|
152
261
|
setQuality(index: number): void;
|
|
153
262
|
setAudioTrack(index: number): void;
|
|
154
|
-
|
|
263
|
+
setControlsVisible(visible: boolean): void;
|
|
264
|
+
toggleFullscreen(): Promise<void>;
|
|
155
265
|
togglePip(): void;
|
|
266
|
+
screenshot(): void;
|
|
267
|
+
toggleLock(): void;
|
|
268
|
+
toggleLoop(): void;
|
|
269
|
+
setFlip(direction: 'horizontal' | 'vertical'): void;
|
|
270
|
+
setAspectRatio(ratio: string): void;
|
|
156
271
|
private initCast;
|
|
157
272
|
requestCast(): void;
|
|
158
273
|
private loadMediaToCast;
|
|
@@ -188,11 +303,11 @@ declare interface SubtitleSettings {
|
|
|
188
303
|
}
|
|
189
304
|
|
|
190
305
|
declare interface TextTrackConfig {
|
|
191
|
-
kind: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
192
|
-
label: string;
|
|
193
306
|
src: string;
|
|
194
|
-
|
|
307
|
+
label: string;
|
|
308
|
+
srcLang?: string;
|
|
195
309
|
default?: boolean;
|
|
310
|
+
kind?: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
196
311
|
}
|
|
197
312
|
|
|
198
313
|
export { }
|