p2p-media-loader-core p2p-media-loader-hlsjs v1.0.3
This commit is contained in:
parent
df21e78edb
commit
7622dbd7dc
|
@ -1451,7 +1451,9 @@ https://cdn.jsdelivr.net/npm/ngx-bootstrap@18.0.0/datepicker/bs-datepicker.css
|
|||
https://cdn.jsdelivr.net/npm/ngx-bootstrap@6.2.0/datepicker/bs-datepicker.css
|
||||
https://cdn.jsdelivr.net/npm/object-assign@4.1.1/index.js
|
||||
https://cdn.jsdelivr.net/npm/p2p-media-loader-core@0.6.2/build/p2p-media-loader-core.min.js
|
||||
https://cdn.jsdelivr.net/npm/p2p-media-loader-core@1.0.3/dist/p2p-media-loader-core.es.min.js
|
||||
https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@0.6.2/build/p2p-media-loader-hlsjs.min.js
|
||||
https://cdn.jsdelivr.net/npm/p2p-media-loader-hlsjs@1.0.3/dist/p2p-media-loader-hlsjs.es.min.js
|
||||
https://cdn.jsdelivr.net/npm/plyr@3.7.8/dist/plyr.css
|
||||
https://cdn.jsdelivr.net/npm/plyr@3.7.8/dist/plyr.min.js
|
||||
https://cdn.jsdelivr.net/npm/raven-js@3.27.2/dist/raven.min.js
|
||||
|
|
|
@ -439,9 +439,17 @@ function create_url() {
|
|||
elif [ "$folder" = "react-side-effect" ]; then
|
||||
url="$UNPKG/react-side-effect@$version/lib/index.umd.min.js"
|
||||
elif [ "$folder" = "p2p-media-loader-core" ]; then
|
||||
url="$JSDELIVR/npm/p2p-media-loader-core@$version/build/p2p-media-loader-core.min.js"
|
||||
if [ "$version" = "0.6.2" ]; then
|
||||
url="$JSDELIVR/npm/p2p-media-loader-core@$version/build/p2p-media-loader-core.min.js"
|
||||
else
|
||||
url="$JSDELIVR/npm/p2p-media-loader-core@$version/dist/p2p-media-loader-core.es.min.js"
|
||||
fi
|
||||
elif [ "$folder" = "p2p-media-loader-hlsjs" ]; then
|
||||
url="$JSDELIVR/npm/p2p-media-loader-hlsjs@$version/build/p2p-media-loader-hlsjs.min.js"
|
||||
if [ "$version" = "0.6.2" ]; then
|
||||
url="$JSDELIVR/npm/p2p-media-loader-hlsjs@$version/build/p2p-media-loader-hlsjs.min.js"
|
||||
else
|
||||
url="$JSDELIVR/npm/p2p-media-loader-hlsjs@$version/dist/p2p-media-loader-hlsjs.es.min.js"
|
||||
fi
|
||||
elif [ "$folder" = "urlize" ]; then
|
||||
url="$JSDELIVR/npm/urlize.js/urlize.js"
|
||||
elif [ "$folder" = "videojs-seek-buttons" ]; then
|
||||
|
|
|
@ -364,7 +364,10 @@ targets.setLastVersion = function (type, version) {
|
|||
if (type.startsWith('/OwlCarousel2/2.')) return '2.3.4';
|
||||
if (type.startsWith('/owl-carousel/1.')) return '1.3.3';
|
||||
if (type.startsWith('/owl-carousel/2.')) return '2.3.4';
|
||||
if (type.startsWith('/p2p-media-loader-core') || type.startsWith('/p2p-media-loader-hlsjs')) return '0.6.2';
|
||||
if (type.startsWith('/p2p-media-loader-core') || type.startsWith('/p2p-media-loader-hlsjs')) {
|
||||
if (helpers.compareVersion('0.6.2', version)) return '0.6.2'; // <= v0.6.2
|
||||
return '1.0.3';
|
||||
};
|
||||
if (type.startsWith('/p5.js/0.')) return '0.10.2';
|
||||
if (type.startsWith('/p5.js/1.')) return '1.9.4';
|
||||
if (type.startsWith('/page.js/1.')) return '1.11.6';
|
||||
|
|
|
@ -48,6 +48,11 @@
|
|||
<li>vue v3.4.29 -> v3.4.31</li>
|
||||
<li>vue-router v4.3.3 -> v4.4.0</li>
|
||||
</ul>
|
||||
<p>Added</p>
|
||||
<ul>
|
||||
<li>p2p-media-loader-core v1.0.3</li>
|
||||
<li>p2p-media-loader-hlsjs v1.0.3</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="generator-section">
|
||||
<div class="topic-label">
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,219 @@
|
|||
var j = Object.defineProperty;
|
||||
var R = (n) => {
|
||||
throw TypeError(n);
|
||||
};
|
||||
var q = (n, t, e) => t in n ? j(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
||||
var r = (n, t, e) => q(n, typeof t != "symbol" ? t + "" : t, e), A = (n, t, e) => t.has(n) || R("Cannot " + e);
|
||||
var i = (n, t, e) => (A(n, t, "read from private field"), e ? e.call(n) : t.get(n)), l = (n, t, e) => t.has(n) ? R("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, e), u = (n, t, e, s) => (A(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e), x = (n, t, e) => (A(n, t, "access private method"), e);
|
||||
import { CoreRequestError as T, debug as N, Core as z } from "p2p-media-loader-core";
|
||||
function F(n, t) {
|
||||
return t ? `${n}|${t.start}-${t.end}` : n;
|
||||
}
|
||||
function J(n, t) {
|
||||
if (n !== void 0 && t !== void 0 && n <= t) return { start: n, end: t };
|
||||
}
|
||||
var H, C, g, v, f, p, b, G, U;
|
||||
class B {
|
||||
constructor(t, e) {
|
||||
l(this, b);
|
||||
r(this, "context");
|
||||
r(this, "config");
|
||||
r(this, "stats");
|
||||
l(this, H);
|
||||
l(this, C);
|
||||
l(this, g);
|
||||
l(this, v);
|
||||
l(this, f);
|
||||
l(this, p);
|
||||
u(this, v, e), u(this, C, () => new t.loader(t)), this.stats = { aborted: !1, chunkCount: 0, loading: { start: 0, first: 0, end: 0 }, buffering: { start: 0, first: 0, end: 0 }, parsing: { start: 0, end: 0 }, total: 1, loaded: 1, bwEstimate: 0, retry: 0 };
|
||||
}
|
||||
load(t, e, s) {
|
||||
var L;
|
||||
this.context = t, this.config = e, u(this, H, s);
|
||||
const o = this.stats, { rangeStart: h, rangeEnd: a } = t, y = J(h, a !== void 0 ? a - 1 : void 0);
|
||||
u(this, p, F(t.url, y));
|
||||
const c = i(this, v).isSegmentLoadable(i(this, p));
|
||||
if (!i(this, v).hasSegment(i(this, p)) || c === !1) return u(this, g, i(this, C).call(this)), i(this, g).stats = this.stats, void ((L = i(this, g)) == null ? void 0 : L.load(t, e, s));
|
||||
i(this, v).loadSegment(i(this, p), { onSuccess: (d) => {
|
||||
u(this, f, d);
|
||||
const E = i(this, f).data.byteLength;
|
||||
o.loading = function(I, w, S) {
|
||||
const P = 8e3 * w / I, M = S - P;
|
||||
return { start: M - 10, first: M, end: S };
|
||||
}(i(this, f).bandwidth, E, performance.now()), o.total = o.loaded = E, s.onProgress && s.onProgress(this.stats, t, i(this, f).data, void 0), s.onSuccess({ data: i(this, f).data, url: t.url }, this.stats, t, void 0);
|
||||
}, onError: (d) => {
|
||||
d instanceof T && d.type === "aborted" && this.stats.aborted || x(this, b, G).call(this, d);
|
||||
} });
|
||||
}
|
||||
abort() {
|
||||
var t, e;
|
||||
i(this, g) ? i(this, g).abort() : (x(this, b, U).call(this), (e = (t = i(this, H)) == null ? void 0 : t.onAbort) == null || e.call(t, this.stats, this.context, {}));
|
||||
}
|
||||
destroy() {
|
||||
i(this, g) ? i(this, g).destroy() : (this.stats.aborted || x(this, b, U).call(this), u(this, H, null), this.config = null);
|
||||
}
|
||||
}
|
||||
H = new WeakMap(), C = new WeakMap(), g = new WeakMap(), v = new WeakMap(), f = new WeakMap(), p = new WeakMap(), b = new WeakSet(), G = function(t) {
|
||||
var s;
|
||||
const e = { code: 0, text: "" };
|
||||
(t instanceof T && t.type === "failed" || t instanceof Error) && (e.text = t.message), (s = i(this, H)) == null || s.onError(e, this.context, null, this.stats);
|
||||
}, U = function() {
|
||||
!i(this, f) && i(this, p) && (this.stats.aborted = !0, i(this, v).abortSegmentLoading(i(this, p)));
|
||||
};
|
||||
var m;
|
||||
class X {
|
||||
constructor(t) {
|
||||
l(this, m);
|
||||
r(this, "context");
|
||||
r(this, "stats");
|
||||
u(this, m, new t.loader(t)), this.stats = i(this, m).stats, this.context = i(this, m).context;
|
||||
}
|
||||
load(t, e, s) {
|
||||
i(this, m).load(t, e, s);
|
||||
}
|
||||
abort() {
|
||||
i(this, m).abort();
|
||||
}
|
||||
destroy() {
|
||||
i(this, m).destroy();
|
||||
}
|
||||
}
|
||||
m = new WeakMap();
|
||||
class K {
|
||||
constructor(t) {
|
||||
r(this, "core");
|
||||
this.core = t;
|
||||
}
|
||||
processMainManifest(t) {
|
||||
const { levels: e, audioTracks: s } = t;
|
||||
for (const [o, h] of e.entries()) {
|
||||
const { url: a } = h;
|
||||
this.core.addStreamIfNoneExists({ runtimeId: Array.isArray(a) ? a[0] : a, type: "main", index: o });
|
||||
}
|
||||
for (const [o, h] of s.entries()) {
|
||||
const { url: a } = h;
|
||||
this.core.addStreamIfNoneExists({ runtimeId: Array.isArray(a) ? a[0] : a, type: "secondary", index: o });
|
||||
}
|
||||
}
|
||||
updatePlaylist(t) {
|
||||
if (!t.details) return;
|
||||
const { details: { url: e, fragments: s, live: o } } = t, h = this.core.getStream(e);
|
||||
if (!h) return;
|
||||
const a = new Set(h.segments.keys()), y = [];
|
||||
s.forEach((c, L) => {
|
||||
const { url: d, byteRange: E, sn: I, start: w, end: S } = c;
|
||||
if (I === "initSegment") return;
|
||||
const [P, M] = E, k = J(P, M !== void 0 ? M - 1 : void 0), D = F(d, k);
|
||||
a.delete(D), h.segments.has(D) || y.push({ runtimeId: D, url: d, externalId: o ? I : L, byteRange: k, startTime: w, endTime: S });
|
||||
}), (y.length || a.size) && this.core.updateStream(e, y, a.values());
|
||||
}
|
||||
}
|
||||
class $ {
|
||||
constructor(t) {
|
||||
r(this, "core");
|
||||
r(this, "segmentManager");
|
||||
r(this, "hlsInstanceGetter");
|
||||
r(this, "currentHlsInstance");
|
||||
r(this, "debug", N("p2pml-hlsjs:engine"));
|
||||
r(this, "updateMediaElementEventHandlers", (t) => {
|
||||
var o;
|
||||
const e = (o = this.currentHlsInstance) == null ? void 0 : o.media;
|
||||
if (!e) return;
|
||||
const s = t === "register" ? "addEventListener" : "removeEventListener";
|
||||
e[s]("timeupdate", this.handlePlaybackUpdate), e[s]("seeking", this.handlePlaybackUpdate), e[s]("ratechange", this.handlePlaybackUpdate);
|
||||
});
|
||||
r(this, "handleManifestLoaded", (t, e) => {
|
||||
const s = e.networkDetails;
|
||||
s instanceof XMLHttpRequest ? this.core.setManifestResponseUrl(s.responseURL) : s instanceof Response && this.core.setManifestResponseUrl(s.url), this.segmentManager.processMainManifest(e);
|
||||
});
|
||||
r(this, "handleLevelSwitching", (t, e) => {
|
||||
e.bitrate && this.core.setActiveLevelBitrate(e.bitrate);
|
||||
});
|
||||
r(this, "handleLevelUpdated", (t, e) => {
|
||||
this.currentHlsInstance && this.currentHlsInstance.config.liveSyncDurationCount !== e.details.fragments.length - 1 && e.details.live && e.details.fragments[0].type === "main" && !this.currentHlsInstance.userConfig.liveSyncDuration && !this.currentHlsInstance.userConfig.liveSyncDurationCount && e.details.fragments.length > 4 && (this.debug("set liveSyncDurationCount " + (e.details.fragments.length - 1)), this.currentHlsInstance.config.liveSyncDurationCount = e.details.fragments.length - 1), this.core.setIsLive(e.details.live), this.segmentManager.updatePlaylist(e);
|
||||
});
|
||||
r(this, "handleMediaAttached", () => {
|
||||
this.updateMediaElementEventHandlers("register");
|
||||
});
|
||||
r(this, "handleMediaDetached", () => {
|
||||
this.updateMediaElementEventHandlers("unregister");
|
||||
});
|
||||
r(this, "handlePlaybackUpdate", (t) => {
|
||||
const e = t.target;
|
||||
this.core.updatePlayback(e.currentTime, e.playbackRate);
|
||||
});
|
||||
r(this, "destroyCore", () => this.core.destroy());
|
||||
r(this, "destroy", () => {
|
||||
this.destroyCore(), this.updateHlsEventsHandlers("unregister"), this.updateMediaElementEventHandlers("unregister"), this.currentHlsInstance = void 0;
|
||||
});
|
||||
this.core = new z(t == null ? void 0 : t.core), this.segmentManager = new K(this.core);
|
||||
}
|
||||
static injectMixin(t) {
|
||||
var s, o;
|
||||
return e = t, o = class extends e {
|
||||
constructor(...a) {
|
||||
var E;
|
||||
const y = a[0], { p2p: c, ...L } = y ?? {}, d = new $(c);
|
||||
super({ ...L, ...d.getConfigForHlsJs() });
|
||||
l(this, s);
|
||||
d.bindHls(this), u(this, s, d), (E = c == null ? void 0 : c.onHlsJsCreated) == null || E.call(c, this);
|
||||
}
|
||||
get p2pEngine() {
|
||||
return i(this, s);
|
||||
}
|
||||
}, s = new WeakMap(), o;
|
||||
var e;
|
||||
}
|
||||
addEventListener(t, e) {
|
||||
this.core.addEventListener(t, e);
|
||||
}
|
||||
removeEventListener(t, e) {
|
||||
this.core.removeEventListener(t, e);
|
||||
}
|
||||
getConfigForHlsJs() {
|
||||
return { fLoader: this.createFragmentLoaderClass(), pLoader: this.createPlaylistLoaderClass() };
|
||||
}
|
||||
getConfig() {
|
||||
return { core: this.core.getConfig() };
|
||||
}
|
||||
applyDynamicConfig(t) {
|
||||
t.core && this.core.applyDynamicConfig(t.core);
|
||||
}
|
||||
bindHls(t) {
|
||||
this.hlsInstanceGetter = typeof t == "function" ? t : () => t;
|
||||
}
|
||||
initHlsEvents() {
|
||||
var e;
|
||||
const t = (e = this.hlsInstanceGetter) == null ? void 0 : e.call(this);
|
||||
this.currentHlsInstance !== t && (this.currentHlsInstance && this.destroy(), this.currentHlsInstance = t, this.updateHlsEventsHandlers("register"), this.updateMediaElementEventHandlers("register"));
|
||||
}
|
||||
updateHlsEventsHandlers(t) {
|
||||
const e = this.currentHlsInstance;
|
||||
if (!e) return;
|
||||
const s = t === "register" ? "on" : "off";
|
||||
e[s]("hlsManifestLoaded", this.handleManifestLoaded), e[s]("hlsLevelSwitching", this.handleLevelSwitching), e[s]("hlsLevelUpdated", this.handleLevelUpdated), e[s]("hlsAudioTrackLoaded", this.handleLevelUpdated), e[s]("hlsDestroying", this.destroy), e[s]("hlsMediaAttaching", this.destroyCore), e[s]("hlsManifestLoading", this.destroyCore), e[s]("hlsMediaDetached", this.handleMediaDetached), e[s]("hlsMediaAttached", this.handleMediaAttached);
|
||||
}
|
||||
createFragmentLoaderClass() {
|
||||
const t = this.core, e = this;
|
||||
return class extends B {
|
||||
constructor(s) {
|
||||
super(s, t);
|
||||
}
|
||||
static getEngine() {
|
||||
return e;
|
||||
}
|
||||
};
|
||||
}
|
||||
createPlaylistLoaderClass() {
|
||||
const t = this;
|
||||
return class extends X {
|
||||
constructor(e) {
|
||||
super(e), t.initHlsEvents();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
export {
|
||||
$ as HlsJsP2PEngine
|
||||
};
|
||||
//# sourceMappingURL=p2p-media-loader-hlsjs.es.min.js.map
|
Loading…
Reference in New Issue