@openplayerjs/hls 3.3.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.js +62 -1
- package/dist/index.js.map +1 -1
- package/dist/openplayer-hls.js +1 -1
- package/dist/openplayer-hls.js.map +1 -1
- package/dist/types/hls.d.ts +14 -0
- package/dist/types/hls.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -36690,6 +36690,18 @@ class HlsMediaEngine extends BaseMediaEngine {
|
|
|
36690
36690
|
writable: true,
|
|
36691
36691
|
value: void 0
|
|
36692
36692
|
});
|
|
36693
|
+
Object.defineProperty(this, "seenCueIds", {
|
|
36694
|
+
enumerable: true,
|
|
36695
|
+
configurable: true,
|
|
36696
|
+
writable: true,
|
|
36697
|
+
value: new Set()
|
|
36698
|
+
});
|
|
36699
|
+
Object.defineProperty(this, "onCue", {
|
|
36700
|
+
enumerable: true,
|
|
36701
|
+
configurable: true,
|
|
36702
|
+
writable: true,
|
|
36703
|
+
value: void 0
|
|
36704
|
+
});
|
|
36693
36705
|
const { hlsClass, ...hlsConfig } = config;
|
|
36694
36706
|
this.HlsClass = hlsClass ?? Hls;
|
|
36695
36707
|
this.hlsConfig = hlsConfig;
|
|
@@ -36706,7 +36718,7 @@ class HlsMediaEngine extends BaseMediaEngine {
|
|
|
36706
36718
|
const u = new URL(source.src, window.location.href);
|
|
36707
36719
|
return u.pathname.endsWith('.m3u8');
|
|
36708
36720
|
}
|
|
36709
|
-
catch {
|
|
36721
|
+
catch /* istanbul ignore next */ {
|
|
36710
36722
|
return source.src.split('?')[0].endsWith('.m3u8');
|
|
36711
36723
|
}
|
|
36712
36724
|
}
|
|
@@ -36720,6 +36732,11 @@ class HlsMediaEngine extends BaseMediaEngine {
|
|
|
36720
36732
|
backBufferLength: 90,
|
|
36721
36733
|
renderTextTracksNatively: true,
|
|
36722
36734
|
enableWebVTT: true,
|
|
36735
|
+
// Surface EXT-X-DATERANGE tags and ID3 frames as metadata TextTrack cues so
|
|
36736
|
+
// consumers can detect SCTE-35 splice points via the standard DOM cuechange API without
|
|
36737
|
+
// any engine-specific event coupling.
|
|
36738
|
+
enableDateRangeMetadataCues: true,
|
|
36739
|
+
enableID3MetadataCues: true,
|
|
36723
36740
|
...this.hlsConfig,
|
|
36724
36741
|
});
|
|
36725
36742
|
this.adapter.loadSource(ctx.activeSource?.src || '');
|
|
@@ -36783,6 +36800,28 @@ class HlsMediaEngine extends BaseMediaEngine {
|
|
|
36783
36800
|
ctx.core.isLive = details.live;
|
|
36784
36801
|
ctx.events.emit('media:duration', details.totalduration);
|
|
36785
36802
|
}, EVENT_OPTIONS);
|
|
36803
|
+
this.onAdapterEvent(this.HlsClass.Events.LEVEL_UPDATED, (_, { details }) => {
|
|
36804
|
+
if (!this.onCue)
|
|
36805
|
+
return;
|
|
36806
|
+
const dateRanges = details?.dateRanges;
|
|
36807
|
+
if (!dateRanges)
|
|
36808
|
+
return;
|
|
36809
|
+
for (const [id, range] of Object.entries(dateRanges)) {
|
|
36810
|
+
if (!range || this.seenCueIds.has(id))
|
|
36811
|
+
continue;
|
|
36812
|
+
const attr = range.attr;
|
|
36813
|
+
const scte35Out = attr?.['SCTE35-OUT'];
|
|
36814
|
+
if (!scte35Out)
|
|
36815
|
+
continue;
|
|
36816
|
+
this.seenCueIds.add(id);
|
|
36817
|
+
this.onCue({
|
|
36818
|
+
id,
|
|
36819
|
+
scte35Out,
|
|
36820
|
+
plannedDuration: typeof range.plannedDuration === 'number' ? range.plannedDuration : undefined,
|
|
36821
|
+
startDate: range.startDate instanceof Date ? range.startDate : undefined,
|
|
36822
|
+
});
|
|
36823
|
+
}
|
|
36824
|
+
}, EVENT_OPTIONS);
|
|
36786
36825
|
this.onAdapterEvent(this.HlsClass.Events.FRAG_PARSING_METADATA, (_, data) => ctx.events.emit('playback:metadataready', { data }), EVENT_OPTIONS);
|
|
36787
36826
|
this.onAdapterEvent(this.HlsClass.Events.SUBTITLE_TRACKS_UPDATED, () => ctx.events.emit('texttrack:listchange'), EVENT_OPTIONS);
|
|
36788
36827
|
this.onAdapterEvent(this.HlsClass.Events.ERROR, (_, data) => {
|
|
@@ -36818,6 +36857,27 @@ class HlsMediaEngine extends BaseMediaEngine {
|
|
|
36818
36857
|
ctx.events.emit('playback:error', data);
|
|
36819
36858
|
}, EVENT_OPTIONS);
|
|
36820
36859
|
}
|
|
36860
|
+
/**
|
|
36861
|
+
* Attach a separate hls.js instance to an arbitrary video element without
|
|
36862
|
+
* touching the main engine state. Intended for ad creatives that are HLS
|
|
36863
|
+
* streams — the caller owns the returned dispose function and must call it
|
|
36864
|
+
* when the ad ends (or on any teardown path).
|
|
36865
|
+
*/
|
|
36866
|
+
attachMedia(video, src) {
|
|
36867
|
+
const hls = new this.HlsClass({ autoStartLoad: true, ...this.hlsConfig });
|
|
36868
|
+
hls.loadSource(src);
|
|
36869
|
+
hls.attachMedia(video);
|
|
36870
|
+
return () => {
|
|
36871
|
+
try {
|
|
36872
|
+
hls.stopLoad();
|
|
36873
|
+
}
|
|
36874
|
+
catch {
|
|
36875
|
+
/* ignore */
|
|
36876
|
+
}
|
|
36877
|
+
hls.detachMedia();
|
|
36878
|
+
hls.destroy();
|
|
36879
|
+
};
|
|
36880
|
+
}
|
|
36821
36881
|
detach() {
|
|
36822
36882
|
this.unbindCommands();
|
|
36823
36883
|
this.unbindMediaEvents();
|
|
@@ -36826,6 +36886,7 @@ class HlsMediaEngine extends BaseMediaEngine {
|
|
|
36826
36886
|
this.adapter?.destroy();
|
|
36827
36887
|
this.adapter = null;
|
|
36828
36888
|
this.startedLoad = false;
|
|
36889
|
+
this.seenCueIds.clear();
|
|
36829
36890
|
}
|
|
36830
36891
|
onAdapterEvent(event, handler, options) {
|
|
36831
36892
|
if (!this.adapter)
|