@hanifhan1f/vidstack-react 1.12.19 → 1.12.21
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/dev/chunks/vidstack-BPymmnxm.js +551 -0
- package/dev/chunks/vidstack-BSpAxhO6.js +643 -0
- package/dev/chunks/vidstack-BoLZuw80.js +34 -0
- package/dev/chunks/vidstack-CFOPpDTy.js +476 -0
- package/dev/chunks/vidstack-CXrXBlpD.js +11692 -0
- package/dev/chunks/vidstack-DOtIyh4c.js +288 -0
- package/dev/chunks/vidstack-DY2iivhG.js +84 -0
- package/dev/chunks/vidstack-Dov8gjdq.js +401 -0
- package/dev/chunks/vidstack-DwdhbP5c.js +189 -0
- package/dev/chunks/vidstack-DweQYzVw.js +180 -0
- package/dev/chunks/vidstack-H9OdEKUQ.js +375 -0
- package/dev/chunks/vidstack-KntYDWMe.js +668 -0
- package/dev/chunks/vidstack-NCBSBZE-.js +61 -0
- package/dev/chunks/vidstack-UWMPvwsa.js +1537 -0
- package/dev/player/vidstack-default-components.js +5 -5
- package/dev/player/vidstack-default-layout.js +5 -5
- package/dev/player/vidstack-plyr-layout.js +4 -4
- package/dev/player/vidstack-remotion.js +3 -3
- package/dev/vidstack.js +7 -7
- package/package.json +1 -1
- package/player/styles/default/layouts/video.css +94 -77
- package/prod/chunks/vidstack-B9nEslvl.js +11197 -0
- package/prod/chunks/vidstack-BOObgZd8.js +504 -0
- package/prod/chunks/vidstack-B_wD853-.js +386 -0
- package/prod/chunks/vidstack-C4tNkfXj.js +470 -0
- package/prod/chunks/vidstack-CNJwYQRW.js +84 -0
- package/prod/chunks/vidstack-CVzVtf1j.js +61 -0
- package/prod/chunks/vidstack-CiQEyk_l.js +189 -0
- package/prod/chunks/vidstack-CiTWSpv_.js +34 -0
- package/prod/chunks/vidstack-CzjHdPIT.js +375 -0
- package/prod/chunks/vidstack-Djmla_FM.js +545 -0
- package/prod/chunks/vidstack-DpQw1Y33.js +663 -0
- package/prod/chunks/vidstack-VTpvHAdU.js +1537 -0
- package/prod/chunks/vidstack-dbLRgf2L.js +159 -0
- package/prod/chunks/vidstack-rHvQ8f6c.js +288 -0
- package/prod/player/vidstack-default-components.js +5 -5
- package/prod/player/vidstack-default-layout.js +5 -5
- package/prod/player/vidstack-plyr-layout.js +4 -4
- package/prod/player/vidstack-remotion.js +3 -3
- package/prod/vidstack.js +7 -7
- package/server/chunks/vidstack-BV_VpWlJ.js +1537 -0
- package/server/chunks/vidstack-ByG5MvLs.js +545 -0
- package/server/chunks/vidstack-C0xOpWYR.js +470 -0
- package/server/chunks/vidstack-C481iXqe.js +386 -0
- package/server/chunks/vidstack-CbNRZgUA.js +11197 -0
- package/server/chunks/vidstack-D7D9kiW6.js +34 -0
- package/server/chunks/vidstack-DJJmNib6.js +504 -0
- package/server/chunks/vidstack-DWt5LAKE.js +375 -0
- package/server/chunks/vidstack-DsZKgA8y.js +663 -0
- package/server/chunks/vidstack-NXcLNXxO.js +84 -0
- package/server/chunks/vidstack-OKdxH1xx.js +189 -0
- package/server/chunks/vidstack-iVN8uBAv.js +288 -0
- package/server/chunks/vidstack-m8aA99tE.js +159 -0
- package/server/chunks/vidstack-rUHVQoo3.js +61 -0
- package/server/player/vidstack-default-components.js +5 -5
- package/server/player/vidstack-default-layout.js +5 -5
- package/server/player/vidstack-plyr-layout.js +4 -4
- package/server/player/vidstack-remotion.js +3 -3
- package/server/vidstack.js +7 -7
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { peek, listenEvent, effect, DOMEvent, isString, camelToKebabCase, isUndefined, isFunction } from './vidstack-CZgUA94N.js';
|
|
4
|
+
import { QualitySymbol, RAFLoop, TextTrack, TextTrackSymbol, ListSymbol, IS_CHROME, coerceToError, loadScript, VideoProvider, isHLSSupported, preconnect } from './vidstack-B9nEslvl.js';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '@floating-ui/dom';
|
|
7
|
+
|
|
8
|
+
const toDOMEventType = (type) => camelToKebabCase(type);
|
|
9
|
+
class HLSController {
|
|
10
|
+
#video;
|
|
11
|
+
#ctx;
|
|
12
|
+
#instance = null;
|
|
13
|
+
#stopLiveSync = null;
|
|
14
|
+
config = {};
|
|
15
|
+
#callbacks = /* @__PURE__ */ new Set();
|
|
16
|
+
get instance() {
|
|
17
|
+
return this.#instance;
|
|
18
|
+
}
|
|
19
|
+
constructor(video, ctx) {
|
|
20
|
+
this.#video = video;
|
|
21
|
+
this.#ctx = ctx;
|
|
22
|
+
}
|
|
23
|
+
setup(ctor) {
|
|
24
|
+
const { streamType } = this.#ctx.$state;
|
|
25
|
+
const isLive = peek(streamType).includes("live"), isLiveLowLatency = peek(streamType).includes("ll-");
|
|
26
|
+
this.#instance = new ctor({
|
|
27
|
+
lowLatencyMode: isLiveLowLatency,
|
|
28
|
+
backBufferLength: isLiveLowLatency ? 4 : isLive ? 8 : void 0,
|
|
29
|
+
renderTextTracksNatively: false,
|
|
30
|
+
...this.config
|
|
31
|
+
});
|
|
32
|
+
const dispatcher = this.#dispatchHLSEvent.bind(this);
|
|
33
|
+
for (const event of Object.values(ctor.Events)) this.#instance.on(event, dispatcher);
|
|
34
|
+
this.#instance.on(ctor.Events.ERROR, this.#onError.bind(this));
|
|
35
|
+
for (const callback of this.#callbacks) callback(this.#instance);
|
|
36
|
+
this.#ctx.player.dispatch("hls-instance", {
|
|
37
|
+
detail: this.#instance
|
|
38
|
+
});
|
|
39
|
+
this.#instance.attachMedia(this.#video);
|
|
40
|
+
this.#instance.on(ctor.Events.AUDIO_TRACK_SWITCHED, this.#onAudioSwitch.bind(this));
|
|
41
|
+
this.#instance.on(ctor.Events.LEVEL_SWITCHED, this.#onLevelSwitched.bind(this));
|
|
42
|
+
this.#instance.on(ctor.Events.LEVEL_LOADED, this.#onLevelLoaded.bind(this));
|
|
43
|
+
this.#instance.on(ctor.Events.LEVEL_UPDATED, this.#onLevelUpdated.bind(this));
|
|
44
|
+
this.#instance.on(ctor.Events.NON_NATIVE_TEXT_TRACKS_FOUND, this.#onTracksFound.bind(this));
|
|
45
|
+
this.#instance.on(ctor.Events.CUES_PARSED, this.#onCuesParsed.bind(this));
|
|
46
|
+
this.#ctx.qualities[QualitySymbol.enableAuto] = this.#enableAutoQuality.bind(this);
|
|
47
|
+
listenEvent(this.#ctx.qualities, "change", this.#onUserQualityChange.bind(this));
|
|
48
|
+
listenEvent(this.#ctx.audioTracks, "change", this.#onUserAudioChange.bind(this));
|
|
49
|
+
this.#stopLiveSync = effect(this.#liveSync.bind(this));
|
|
50
|
+
}
|
|
51
|
+
#createDOMEvent(type, data) {
|
|
52
|
+
return new DOMEvent(toDOMEventType(type), { detail: data });
|
|
53
|
+
}
|
|
54
|
+
#liveSync() {
|
|
55
|
+
if (!this.#ctx.$state.live()) return;
|
|
56
|
+
const raf = new RAFLoop(this.#liveSyncPosition.bind(this));
|
|
57
|
+
raf.start();
|
|
58
|
+
return raf.stop.bind(raf);
|
|
59
|
+
}
|
|
60
|
+
#liveSyncPosition() {
|
|
61
|
+
this.#ctx.$state.liveSyncPosition.set(this.#instance?.liveSyncPosition ?? Infinity);
|
|
62
|
+
}
|
|
63
|
+
#dispatchHLSEvent(type, data) {
|
|
64
|
+
this.#ctx.player?.dispatch(this.#createDOMEvent(type, data));
|
|
65
|
+
}
|
|
66
|
+
#onTracksFound(eventType, data) {
|
|
67
|
+
const event = this.#createDOMEvent(eventType, data);
|
|
68
|
+
let currentTrack = -1;
|
|
69
|
+
for (let i = 0; i < data.tracks.length; i++) {
|
|
70
|
+
const nonNativeTrack = data.tracks[i], init = nonNativeTrack.subtitleTrack ?? nonNativeTrack.closedCaptions, track = new TextTrack({
|
|
71
|
+
id: `hls-${nonNativeTrack.kind}-${i}`,
|
|
72
|
+
src: init?.url,
|
|
73
|
+
label: nonNativeTrack.label,
|
|
74
|
+
language: init?.lang,
|
|
75
|
+
kind: nonNativeTrack.kind,
|
|
76
|
+
default: nonNativeTrack.default
|
|
77
|
+
});
|
|
78
|
+
track[TextTrackSymbol.readyState] = 2;
|
|
79
|
+
track[TextTrackSymbol.onModeChange] = () => {
|
|
80
|
+
if (track.mode === "showing") {
|
|
81
|
+
this.#instance.subtitleTrack = i;
|
|
82
|
+
currentTrack = i;
|
|
83
|
+
} else if (currentTrack === i) {
|
|
84
|
+
this.#instance.subtitleTrack = -1;
|
|
85
|
+
currentTrack = -1;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
this.#ctx.textTracks.add(track, event);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
#onCuesParsed(eventType, data) {
|
|
92
|
+
const index = this.#instance?.subtitleTrack, track = this.#ctx.textTracks.getById(`hls-${data.type}-${index}`);
|
|
93
|
+
if (!track) return;
|
|
94
|
+
const event = this.#createDOMEvent(eventType, data);
|
|
95
|
+
for (const cue of data.cues) {
|
|
96
|
+
cue.positionAlign = "auto";
|
|
97
|
+
track.addCue(cue, event);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
#onAudioSwitch(eventType, data) {
|
|
101
|
+
const track = this.#ctx.audioTracks[data.id];
|
|
102
|
+
if (track) {
|
|
103
|
+
const trigger = this.#createDOMEvent(eventType, data);
|
|
104
|
+
this.#ctx.audioTracks[ListSymbol.select](track, true, trigger);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
#onLevelSwitched(eventType, data) {
|
|
108
|
+
const quality = this.#ctx.qualities[data.level];
|
|
109
|
+
if (quality) {
|
|
110
|
+
const trigger = this.#createDOMEvent(eventType, data);
|
|
111
|
+
this.#ctx.qualities[ListSymbol.select](quality, true, trigger);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
#onLevelUpdated(eventType, data) {
|
|
115
|
+
if (data.details.totalduration > 0) {
|
|
116
|
+
this.#ctx.$state.inferredLiveDVRWindow.set(data.details.totalduration);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
#onLevelLoaded(eventType, data) {
|
|
120
|
+
if (this.#ctx.$state.canPlay()) return;
|
|
121
|
+
const { type, live, totalduration: duration, targetduration } = data.details, trigger = this.#createDOMEvent(eventType, data);
|
|
122
|
+
this.#ctx.notify(
|
|
123
|
+
"stream-type-change",
|
|
124
|
+
live ? type === "EVENT" && Number.isFinite(duration) && targetduration >= 10 ? "live:dvr" : "live" : "on-demand",
|
|
125
|
+
trigger
|
|
126
|
+
);
|
|
127
|
+
this.#ctx.notify("duration-change", duration, trigger);
|
|
128
|
+
const media = this.#instance.media;
|
|
129
|
+
if (this.#instance.currentLevel === -1) {
|
|
130
|
+
this.#ctx.qualities[QualitySymbol.setAuto](true, trigger);
|
|
131
|
+
}
|
|
132
|
+
for (const remoteTrack of this.#instance.audioTracks) {
|
|
133
|
+
const localTrack = {
|
|
134
|
+
id: remoteTrack.id.toString(),
|
|
135
|
+
label: remoteTrack.name,
|
|
136
|
+
language: remoteTrack.lang || "",
|
|
137
|
+
kind: "main"
|
|
138
|
+
};
|
|
139
|
+
this.#ctx.audioTracks[ListSymbol.add](localTrack, trigger);
|
|
140
|
+
}
|
|
141
|
+
for (const level of this.#instance.levels) {
|
|
142
|
+
const videoQuality = {
|
|
143
|
+
id: level.id?.toString() ?? level.height + "p",
|
|
144
|
+
width: level.width,
|
|
145
|
+
height: level.height,
|
|
146
|
+
codec: level.codecSet,
|
|
147
|
+
bitrate: level.bitrate
|
|
148
|
+
};
|
|
149
|
+
this.#ctx.qualities[ListSymbol.add](videoQuality, trigger);
|
|
150
|
+
}
|
|
151
|
+
media.dispatchEvent(new DOMEvent("canplay", { trigger }));
|
|
152
|
+
}
|
|
153
|
+
#onError(eventType, data) {
|
|
154
|
+
if (data.fatal) {
|
|
155
|
+
switch (data.type) {
|
|
156
|
+
case "mediaError":
|
|
157
|
+
this.#instance?.recoverMediaError();
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
this.#onFatalError(data.error);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
#onFatalError(error) {
|
|
166
|
+
this.#ctx.notify("error", {
|
|
167
|
+
message: error.message,
|
|
168
|
+
code: 1,
|
|
169
|
+
error
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
#enableAutoQuality() {
|
|
173
|
+
if (this.#instance) this.#instance.currentLevel = -1;
|
|
174
|
+
}
|
|
175
|
+
#onUserQualityChange() {
|
|
176
|
+
const { qualities } = this.#ctx;
|
|
177
|
+
if (!this.#instance || qualities.auto) return;
|
|
178
|
+
this.#instance[qualities.switch + "Level"] = qualities.selectedIndex;
|
|
179
|
+
if (IS_CHROME) {
|
|
180
|
+
this.#video.currentTime = this.#video.currentTime;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
#onUserAudioChange() {
|
|
184
|
+
const { audioTracks } = this.#ctx;
|
|
185
|
+
if (this.#instance && this.#instance.audioTrack !== audioTracks.selectedIndex) {
|
|
186
|
+
this.#instance.audioTrack = audioTracks.selectedIndex;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
onInstance(callback) {
|
|
190
|
+
this.#callbacks.add(callback);
|
|
191
|
+
return () => this.#callbacks.delete(callback);
|
|
192
|
+
}
|
|
193
|
+
loadSource(src) {
|
|
194
|
+
if (!isString(src.src)) return;
|
|
195
|
+
this.#instance?.loadSource(src.src);
|
|
196
|
+
}
|
|
197
|
+
destroy() {
|
|
198
|
+
this.#instance?.destroy();
|
|
199
|
+
this.#instance = null;
|
|
200
|
+
this.#stopLiveSync?.();
|
|
201
|
+
this.#stopLiveSync = null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
class HLSLibLoader {
|
|
206
|
+
#lib;
|
|
207
|
+
#ctx;
|
|
208
|
+
#callback;
|
|
209
|
+
constructor(lib, ctx, callback) {
|
|
210
|
+
this.#lib = lib;
|
|
211
|
+
this.#ctx = ctx;
|
|
212
|
+
this.#callback = callback;
|
|
213
|
+
this.#startLoading();
|
|
214
|
+
}
|
|
215
|
+
async #startLoading() {
|
|
216
|
+
const callbacks = {
|
|
217
|
+
onLoadStart: this.#onLoadStart.bind(this),
|
|
218
|
+
onLoaded: this.#onLoaded.bind(this),
|
|
219
|
+
onLoadError: this.#onLoadError.bind(this)
|
|
220
|
+
};
|
|
221
|
+
let ctor = await loadHLSScript(this.#lib, callbacks);
|
|
222
|
+
if (isUndefined(ctor) && !isString(this.#lib)) ctor = await importHLS(this.#lib, callbacks);
|
|
223
|
+
if (!ctor) return null;
|
|
224
|
+
if (!ctor.isSupported()) {
|
|
225
|
+
const message = "[vidstack] `hls.js` is not supported in this environment";
|
|
226
|
+
this.#ctx.player.dispatch(new DOMEvent("hls-unsupported"));
|
|
227
|
+
this.#ctx.notify("error", { message, code: 4 });
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return ctor;
|
|
231
|
+
}
|
|
232
|
+
#onLoadStart() {
|
|
233
|
+
this.#ctx.player.dispatch(new DOMEvent("hls-lib-load-start"));
|
|
234
|
+
}
|
|
235
|
+
#onLoaded(ctor) {
|
|
236
|
+
this.#ctx.player.dispatch(
|
|
237
|
+
new DOMEvent("hls-lib-loaded", {
|
|
238
|
+
detail: ctor
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
this.#callback(ctor);
|
|
242
|
+
}
|
|
243
|
+
#onLoadError(e) {
|
|
244
|
+
const error = coerceToError(e);
|
|
245
|
+
this.#ctx.player.dispatch(
|
|
246
|
+
new DOMEvent("hls-lib-load-error", {
|
|
247
|
+
detail: error
|
|
248
|
+
})
|
|
249
|
+
);
|
|
250
|
+
this.#ctx.notify("error", {
|
|
251
|
+
message: error.message,
|
|
252
|
+
code: 4,
|
|
253
|
+
error
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async function importHLS(loader, callbacks = {}) {
|
|
258
|
+
if (isUndefined(loader)) return void 0;
|
|
259
|
+
callbacks.onLoadStart?.();
|
|
260
|
+
if (loader.prototype && loader.prototype !== Function) {
|
|
261
|
+
callbacks.onLoaded?.(loader);
|
|
262
|
+
return loader;
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
const ctor = (await loader())?.default;
|
|
266
|
+
if (ctor && !!ctor.isSupported) {
|
|
267
|
+
callbacks.onLoaded?.(ctor);
|
|
268
|
+
} else {
|
|
269
|
+
throw Error(
|
|
270
|
+
false ? "[vidstack] failed importing `hls.js`. Dynamic import returned invalid constructor." : ""
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
return ctor;
|
|
274
|
+
} catch (err) {
|
|
275
|
+
callbacks.onLoadError?.(err);
|
|
276
|
+
}
|
|
277
|
+
return void 0;
|
|
278
|
+
}
|
|
279
|
+
async function loadHLSScript(src, callbacks = {}) {
|
|
280
|
+
if (!isString(src)) return void 0;
|
|
281
|
+
callbacks.onLoadStart?.();
|
|
282
|
+
try {
|
|
283
|
+
await loadScript(src);
|
|
284
|
+
if (!isFunction(window.Hls)) {
|
|
285
|
+
throw Error(
|
|
286
|
+
false ? "[vidstack] failed loading `hls.js`. Could not find a valid `Hls` constructor on window" : ""
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
const ctor = window.Hls;
|
|
290
|
+
callbacks.onLoaded?.(ctor);
|
|
291
|
+
return ctor;
|
|
292
|
+
} catch (err) {
|
|
293
|
+
callbacks.onLoadError?.(err);
|
|
294
|
+
}
|
|
295
|
+
return void 0;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const JS_DELIVR_CDN = "https://cdn.jsdelivr.net";
|
|
299
|
+
class HLSProvider extends VideoProvider {
|
|
300
|
+
$$PROVIDER_TYPE = "HLS";
|
|
301
|
+
#ctor = null;
|
|
302
|
+
#controller = new HLSController(this.video, this.ctx);
|
|
303
|
+
/**
|
|
304
|
+
* The `hls.js` constructor.
|
|
305
|
+
*/
|
|
306
|
+
get ctor() {
|
|
307
|
+
return this.#ctor;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* The current `hls.js` instance.
|
|
311
|
+
*/
|
|
312
|
+
get instance() {
|
|
313
|
+
return this.#controller.instance;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Whether `hls.js` is supported in this environment.
|
|
317
|
+
*/
|
|
318
|
+
static supported = isHLSSupported();
|
|
319
|
+
get type() {
|
|
320
|
+
return "hls";
|
|
321
|
+
}
|
|
322
|
+
get canLiveSync() {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
#library = `${JS_DELIVR_CDN}/npm/hls.js@^1.5.0/dist/hls${".min.js"}`;
|
|
326
|
+
/**
|
|
327
|
+
* The `hls.js` configuration object.
|
|
328
|
+
*
|
|
329
|
+
* @see {@link https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning}
|
|
330
|
+
*/
|
|
331
|
+
get config() {
|
|
332
|
+
return this.#controller.config;
|
|
333
|
+
}
|
|
334
|
+
set config(config) {
|
|
335
|
+
this.#controller.config = config;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* The `hls.js` constructor (supports dynamic imports) or a URL of where it can be found.
|
|
339
|
+
*
|
|
340
|
+
* @defaultValue `https://cdn.jsdelivr.net/npm/hls.js@^1.0.0/dist/hls.min.js`
|
|
341
|
+
*/
|
|
342
|
+
get library() {
|
|
343
|
+
return this.#library;
|
|
344
|
+
}
|
|
345
|
+
set library(library) {
|
|
346
|
+
this.#library = library;
|
|
347
|
+
}
|
|
348
|
+
preconnect() {
|
|
349
|
+
if (!isString(this.#library)) return;
|
|
350
|
+
preconnect(this.#library);
|
|
351
|
+
}
|
|
352
|
+
setup() {
|
|
353
|
+
super.setup();
|
|
354
|
+
new HLSLibLoader(this.#library, this.ctx, (ctor) => {
|
|
355
|
+
this.#ctor = ctor;
|
|
356
|
+
this.#controller.setup(ctor);
|
|
357
|
+
this.ctx.notify("provider-setup", this);
|
|
358
|
+
const src = peek(this.ctx.$state.source);
|
|
359
|
+
if (src) this.loadSource(src);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
async loadSource(src, preload) {
|
|
363
|
+
if (!isString(src.src)) {
|
|
364
|
+
this.removeSource();
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
this.media.preload = preload || "";
|
|
368
|
+
this.appendSource(src, "application/x-mpegurl");
|
|
369
|
+
this.#controller.loadSource(src);
|
|
370
|
+
this.currentSrc = src;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The given callback is invoked when a new `hls.js` instance is created and right before it's
|
|
374
|
+
* attached to media.
|
|
375
|
+
*/
|
|
376
|
+
onInstance(callback) {
|
|
377
|
+
const instance = this.#controller.instance;
|
|
378
|
+
if (instance) callback(instance);
|
|
379
|
+
return this.#controller.onInstance(callback);
|
|
380
|
+
}
|
|
381
|
+
destroy() {
|
|
382
|
+
this.#controller.destroy();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export { HLSProvider };
|