mattebox 0.16.2 → 0.17.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/dist/cdn/mattebox.dash-drm.min.js +3 -3
- package/dist/cdn/mattebox.dash-ll.min.js +3 -3
- package/dist/cdn/mattebox.dash.min.js +3 -3
- package/dist/cdn/mattebox.dual-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ll.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.dual-ts.min.js +3 -3
- package/dist/cdn/mattebox.dual.min.js +3 -3
- package/dist/cdn/mattebox.hls-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ll.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
- package/dist/cdn/mattebox.hls-ts.min.js +3 -3
- package/dist/cdn/mattebox.hls.min.js +3 -3
- package/dist/cdn/mattebox.kernel.min.js +1 -1
- package/dist/cdn/mattebox.min.js +2 -2
- package/dist/containers/emsg.d.ts +16 -0
- package/dist/containers/emsg.d.ts.map +1 -1
- package/dist/containers/emsg.js +31 -1
- package/dist/containers/emsg.js.map +1 -1
- package/dist/eme/index.d.ts.map +1 -1
- package/dist/eme/index.js +2 -0
- package/dist/eme/index.js.map +1 -1
- package/dist/es2015/containers/emsg.js +28 -2
- package/dist/es2015/eme/index.js +8 -0
- package/dist/es2015/index.js +4 -3
- package/dist/es2015/kernel/context.js +6 -0
- package/dist/es2015/kernel/dry-run.js +2 -2
- package/dist/es2015/kernel/reducer.js +46 -6
- package/dist/es2015/protocols/dash-cmaf/parse.js +17 -2
- package/dist/es2015/protocols/hls-cmaf/parse.js +58 -2
- package/dist/es2015/stages/interstitials/breaks.js +341 -0
- package/dist/es2015/stages/interstitials/index.js +750 -0
- package/dist/es2015/stages/timed-metadata/index.js +10 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel/context.d.ts.map +1 -1
- package/dist/kernel/context.js +8 -0
- package/dist/kernel/context.js.map +1 -1
- package/dist/kernel/dry-run.d.ts +2 -0
- package/dist/kernel/dry-run.d.ts.map +1 -1
- package/dist/kernel/dry-run.js +1 -0
- package/dist/kernel/dry-run.js.map +1 -1
- package/dist/kernel/reducer.d.ts.map +1 -1
- package/dist/kernel/reducer.js +44 -3
- package/dist/kernel/reducer.js.map +1 -1
- package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/dash-cmaf/parse.js +16 -0
- package/dist/protocols/dash-cmaf/parse.js.map +1 -1
- package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
- package/dist/protocols/hls-cmaf/parse.js +75 -4
- package/dist/protocols/hls-cmaf/parse.js.map +1 -1
- package/dist/stages/interstitials/breaks.d.ts +113 -0
- package/dist/stages/interstitials/breaks.d.ts.map +1 -0
- package/dist/stages/interstitials/breaks.js +390 -0
- package/dist/stages/interstitials/breaks.js.map +1 -0
- package/dist/stages/interstitials/index.d.ts +57 -0
- package/dist/stages/interstitials/index.d.ts.map +1 -0
- package/dist/stages/interstitials/index.js +853 -0
- package/dist/stages/interstitials/index.js.map +1 -0
- package/dist/stages/timed-metadata/index.d.ts.map +1 -1
- package/dist/stages/timed-metadata/index.js +10 -27
- package/dist/stages/timed-metadata/index.js.map +1 -1
- package/dist/types/facade.d.ts +2 -19
- package/dist/types/facade.d.ts.map +1 -1
- package/dist/types/ir.d.ts +13 -1
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/kernel.d.ts +6 -0
- package/dist/types/kernel.d.ts.map +1 -1
- package/dist/types/load.d.ts +28 -0
- package/dist/types/load.d.ts.map +1 -0
- package/dist/types/load.js +3 -0
- package/dist/types/load.js.map +1 -0
- package/dist/types/messages.d.ts +2 -0
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/stage.d.ts +10 -0
- package/dist/types/stage.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/asyncToGenerator.js";
|
|
3
|
+
import { findBox, trackTimescales } from "../../containers/mp4-box/index.js";
|
|
4
|
+
import { placeEmsg } from "../../containers/emsg.js";
|
|
5
|
+
import { bytesToBase64 } from "../../kernel/base64.js";
|
|
6
|
+
import { assetsOf, breaksOf, fromEvent } from "./breaks.js";
|
|
7
|
+
// src/stages/interstitials/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* Plays breaks: HLS interstitials, DASH alternative MPD events, and the
|
|
10
|
+
* breaks a page schedules, on the one engine that plays the presentation.
|
|
11
|
+
* At a break the engine loads the asset in the presentation's place, and
|
|
12
|
+
* after it loads the presentation again at the resume point, each preloaded
|
|
13
|
+
* ahead so the switch fetches nothing. hls.js and Shaka play an asset this
|
|
14
|
+
* way when they cannot append it in place.
|
|
15
|
+
*
|
|
16
|
+
* SCTE-35 cue-outs are breaks with no assets: the presentation plays
|
|
17
|
+
* through them, and the stage reports their start, quartiles and end, so a
|
|
18
|
+
* player shows them as ads. A page fills one by scheduling assets under its
|
|
19
|
+
* id before it starts.
|
|
20
|
+
*
|
|
21
|
+
* The rules follow Appendix D of draft-pantos-hls-rfc8216bis as hls.js
|
|
22
|
+
* applies them: a pre-roll before the first frame, a post-roll at the end,
|
|
23
|
+
* a `once` break plays once, a seek past `noJump` breaks plays the last of
|
|
24
|
+
* them first, a `noSkip` break takes no seek, and a failed asset is skipped.
|
|
25
|
+
*
|
|
26
|
+
* The page reads `engine.interstitials` and listens to its events. The
|
|
27
|
+
* element's `currentTime` stays the browser's: during a break it is the
|
|
28
|
+
* asset's, and `primary` gives the presentation's.
|
|
29
|
+
*/
|
|
30
|
+
/** Seconds ahead of a break at which its asset list is fetched and its first asset preloaded (hls.js's live look-ahead). */
|
|
31
|
+
const LOOKAHEAD = 10;
|
|
32
|
+
/** Segments preloaded per track before a switch: with 3, the reels page started in under 50 ms. */
|
|
33
|
+
const SEGMENTS = 3;
|
|
34
|
+
/** A jump of the playhead larger than this, outside a seek event, counts as a seek. */
|
|
35
|
+
const JUMP = 2;
|
|
36
|
+
const QUARTILES = [
|
|
37
|
+
.25,
|
|
38
|
+
.5,
|
|
39
|
+
.75
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* Whether a span is a break: an ad or a promotion. The credits and the
|
|
43
|
+
* chapters a SCTE-35 section names are spans of the presentation, which a
|
|
44
|
+
* player shows as such, never as an ad.
|
|
45
|
+
*/
|
|
46
|
+
function isBreak(entry) {
|
|
47
|
+
return entry.role === void 0 || entry.role === "ad" || entry.role === "promo";
|
|
48
|
+
}
|
|
49
|
+
/** How long a break plays, when known: its assets, its limit, or the span it covers. */
|
|
50
|
+
function lengthOf(entry) {
|
|
51
|
+
const assets = entry.assets.reduce((sum, asset) => {
|
|
52
|
+
var _asset$duration;
|
|
53
|
+
return sum + ((_asset$duration = asset.duration) !== null && _asset$duration !== void 0 ? _asset$duration : 0);
|
|
54
|
+
}, 0);
|
|
55
|
+
const known = assets > 0 ? assets : entry.covers;
|
|
56
|
+
return entry.playoutLimit !== void 0 ? Math.min(known, entry.playoutLimit) : known;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The elements of an alternative MPD event an emsg carries as its message
|
|
60
|
+
* data: the `InsertPresentation` or `ReplacePresentation` element, alone or
|
|
61
|
+
* inside an `Event`. Empty for any other body.
|
|
62
|
+
*/
|
|
63
|
+
function presentationElements(data) {
|
|
64
|
+
const text = new TextDecoder().decode(data).trim();
|
|
65
|
+
if (!text.startsWith("<") || typeof DOMParser === "undefined") return [];
|
|
66
|
+
const root = new DOMParser().parseFromString(text, "application/xml").documentElement;
|
|
67
|
+
if (root === null) return [];
|
|
68
|
+
return (/Presentation$|^AlternativeMPD$/.test(root.localName) ? [root] : Array.from(root.children).filter((e) => /Presentation$|^AlternativeMPD$/.test(e.localName))).map((e) => ({
|
|
69
|
+
name: e.localName,
|
|
70
|
+
attributes: Object.fromEntries(Array.from(e.attributes, (a) => [a.localName, a.value]))
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
function interstitials() {
|
|
74
|
+
/**
|
|
75
|
+
* What a detach leaves of the presentation: its URL, the breaks played,
|
|
76
|
+
* the asset lists fetched. A player that plays a progressive ad on the
|
|
77
|
+
* video detaches the engine, then loads the presentation again from where
|
|
78
|
+
* it stopped; that load takes them back, so no break plays twice.
|
|
79
|
+
*/
|
|
80
|
+
let memory = null;
|
|
81
|
+
return {
|
|
82
|
+
name: "interstitials",
|
|
83
|
+
provides: ["interstitials"],
|
|
84
|
+
install(ctx) {
|
|
85
|
+
const element = ctx.element;
|
|
86
|
+
const entries = /* @__PURE__ */ new Map();
|
|
87
|
+
/** The breaks played, by id: a rebuild of the schedule keeps them. */
|
|
88
|
+
const played = /* @__PURE__ */ new Set();
|
|
89
|
+
/** The assets each fetched asset list named, by break id. */
|
|
90
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
91
|
+
const page = /* @__PURE__ */ new Map();
|
|
92
|
+
const told = /* @__PURE__ */ new Set();
|
|
93
|
+
let primary = null;
|
|
94
|
+
let presentationId = null;
|
|
95
|
+
let duration = NaN;
|
|
96
|
+
let live = false;
|
|
97
|
+
let own = false;
|
|
98
|
+
let playing = null;
|
|
99
|
+
/** A return in progress: the presentation's own seek to the resume point is no viewer seek. */
|
|
100
|
+
let settling = false;
|
|
101
|
+
let started = false;
|
|
102
|
+
let ended = false;
|
|
103
|
+
let lastTime = 0;
|
|
104
|
+
let seekFrom = null;
|
|
105
|
+
let timer = null;
|
|
106
|
+
let tracks = null;
|
|
107
|
+
let seq = 0;
|
|
108
|
+
/** A break waits for its asset list: no other starts meanwhile. */
|
|
109
|
+
let pending = false;
|
|
110
|
+
/** Whether the viewer wants playback: the element pauses at each load and at an asset's end. */
|
|
111
|
+
let wanted = !element.paused;
|
|
112
|
+
let switching = false;
|
|
113
|
+
/** The presentation and its post-rolls are over. */
|
|
114
|
+
let over = false;
|
|
115
|
+
/** A live return: the break's id and the seconds from its start where the broadcast resumes. */
|
|
116
|
+
let liveResume = null;
|
|
117
|
+
/** Breaks the media carries in emsg, by id. */
|
|
118
|
+
const inband = /* @__PURE__ */ new Map();
|
|
119
|
+
const timescales = /* @__PURE__ */ new Map();
|
|
120
|
+
const sorted = () => [...entries.values()].sort((a, b) => a.break.start - b.break.start);
|
|
121
|
+
const emit = (event, entry, extra = {}) => ctx.emit(`interstitials:${event}`, _objectSpread2({
|
|
122
|
+
id: entry.break.id,
|
|
123
|
+
break: entry.break
|
|
124
|
+
}, extra));
|
|
125
|
+
function reset() {
|
|
126
|
+
if ((playing === null || playing === void 0 ? void 0 : playing.limit) != null) clearTimeout(playing.limit);
|
|
127
|
+
entries.clear();
|
|
128
|
+
played.clear();
|
|
129
|
+
resolved.clear();
|
|
130
|
+
page.clear();
|
|
131
|
+
told.clear();
|
|
132
|
+
playing = null;
|
|
133
|
+
presentationId = null;
|
|
134
|
+
started = false;
|
|
135
|
+
ended = false;
|
|
136
|
+
over = false;
|
|
137
|
+
liveResume = null;
|
|
138
|
+
inband.clear();
|
|
139
|
+
timescales.clear();
|
|
140
|
+
settling = false;
|
|
141
|
+
lastTime = 0;
|
|
142
|
+
tracks = null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The segment boundaries of the presentation's video, or its audio,
|
|
146
|
+
* for X-SNAP. HLS only, where the segments are a list.
|
|
147
|
+
*/
|
|
148
|
+
function edges(presentation) {
|
|
149
|
+
var _active$get, _presentation$periods;
|
|
150
|
+
const active = ctx.getState().tracks.active;
|
|
151
|
+
const id = (_active$get = active.get("video")) !== null && _active$get !== void 0 ? _active$get : active.get("audio");
|
|
152
|
+
for (const period of (_presentation$periods = presentation === null || presentation === void 0 ? void 0 : presentation.periods) !== null && _presentation$periods !== void 0 ? _presentation$periods : []) for (const track of period.tracks) {
|
|
153
|
+
var _track$renditions$;
|
|
154
|
+
if (track.id !== id) continue;
|
|
155
|
+
const segments = (_track$renditions$ = track.renditions[0]) === null || _track$renditions$ === void 0 ? void 0 : _track$renditions$.segments;
|
|
156
|
+
if (!Array.isArray(segments)) return [];
|
|
157
|
+
return segments.map((s) => s.start);
|
|
158
|
+
}
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
/** Where a break starts: at the segment boundary before it with X-SNAP=OUT. */
|
|
162
|
+
function startOf(entry) {
|
|
163
|
+
var _entry$snap;
|
|
164
|
+
if (((_entry$snap = entry.snap) === null || _entry$snap === void 0 ? void 0 : _entry$snap.out) !== true) return entry.start;
|
|
165
|
+
const before = edges(ctx.getState().presentation).filter((t) => t <= entry.start + .001);
|
|
166
|
+
return before.length > 0 ? before[before.length - 1] : entry.start;
|
|
167
|
+
}
|
|
168
|
+
/** Where the presentation resumes: at the segment boundary after it with X-SNAP=IN. */
|
|
169
|
+
function resumeOf(entry, at) {
|
|
170
|
+
var _entry$snap2, _edges$find;
|
|
171
|
+
if (((_entry$snap2 = entry.snap) === null || _entry$snap2 === void 0 ? void 0 : _entry$snap2.in) !== true) return at;
|
|
172
|
+
return (_edges$find = edges(ctx.getState().presentation).find((t) => t >= at - .001)) !== null && _edges$find !== void 0 ? _edges$find : at;
|
|
173
|
+
}
|
|
174
|
+
/** Rebuilds the schedule from the presentation. */
|
|
175
|
+
function refresh() {
|
|
176
|
+
if (playing !== null || primary === null) return;
|
|
177
|
+
const presentation = ctx.getState().presentation;
|
|
178
|
+
if (presentation === null) return;
|
|
179
|
+
presentationId = presentation.id;
|
|
180
|
+
live = presentation.isLive;
|
|
181
|
+
if (presentation.duration !== void 0) duration = presentation.duration;
|
|
182
|
+
const fresh = [
|
|
183
|
+
...breaksOf(presentation, primary.url),
|
|
184
|
+
...inband.values(),
|
|
185
|
+
...page.values()
|
|
186
|
+
];
|
|
187
|
+
let changed = fresh.length !== entries.size;
|
|
188
|
+
const ids = /* @__PURE__ */ new Set();
|
|
189
|
+
for (const next of fresh) {
|
|
190
|
+
ids.add(next.id);
|
|
191
|
+
const known = entries.get(next.id);
|
|
192
|
+
const filled = page.get(next.id);
|
|
193
|
+
const signalled = filled !== void 0 && next.source === "scte35" ? filled : next;
|
|
194
|
+
const assets = resolved.get(next.id);
|
|
195
|
+
const value = assets !== void 0 && signalled.assets.length === 0 && signalled.assetList !== void 0 ? _objectSpread2(_objectSpread2({}, signalled), {}, { assets }) : signalled;
|
|
196
|
+
if (known === void 0) {
|
|
197
|
+
entries.set(next.id, { break: value });
|
|
198
|
+
changed = true;
|
|
199
|
+
} else if (JSON.stringify(known.break) !== JSON.stringify(value)) {
|
|
200
|
+
known.break = value;
|
|
201
|
+
changed = true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
for (const id of [...entries.keys()]) if (!ids.has(id)) entries.delete(id);
|
|
205
|
+
if (changed) ctx.emit("interstitials:changed", { breaks: api.breaks });
|
|
206
|
+
for (const entry of entries.values()) if (entry.break.source === "scte35" && isBreak(entry.break) && !told.has(entry.break.id)) {
|
|
207
|
+
told.add(entry.break.id);
|
|
208
|
+
emit("opportunity", entry, { duration: entry.break.covers });
|
|
209
|
+
}
|
|
210
|
+
seekLive();
|
|
211
|
+
if (!started) {
|
|
212
|
+
const pre = sorted().find((e) => e.break.cue === "pre" && !played.has(e.break.id));
|
|
213
|
+
if (pre !== void 0) begin(pre, primary.start);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* After a live break, the broadcast resumes where the break said: the
|
|
218
|
+
* same break in the reloaded presentation gives its start on the new
|
|
219
|
+
* timeline, since an HLS live reload restarts the presentation clock.
|
|
220
|
+
* Outside the window, the live edge stays.
|
|
221
|
+
*/
|
|
222
|
+
function seekLive() {
|
|
223
|
+
const target = liveResume;
|
|
224
|
+
const window = ctx.getState().live;
|
|
225
|
+
if (target === null || window === null) return;
|
|
226
|
+
const entry = entries.get(target.id);
|
|
227
|
+
if (entry === void 0) return;
|
|
228
|
+
liveResume = null;
|
|
229
|
+
const at = entry.break.start + target.offset;
|
|
230
|
+
if (at < window.span.start || at > window.edge) return;
|
|
231
|
+
settling = true;
|
|
232
|
+
lastTime = at;
|
|
233
|
+
element.currentTime = at;
|
|
234
|
+
}
|
|
235
|
+
/** Fetches the asset list of a break, once. A failure leaves it with no assets. */
|
|
236
|
+
function resolve(entry) {
|
|
237
|
+
var _entry$resolving;
|
|
238
|
+
const list = entry.break.assetList;
|
|
239
|
+
if (list === void 0 || entry.break.assets.length > 0) return Promise.resolve();
|
|
240
|
+
(_entry$resolving = entry.resolving) !== null && _entry$resolving !== void 0 || (entry.resolving = ctx.request(list, { method: "GET" }).then(function() {
|
|
241
|
+
var _ref = _asyncToGenerator(function* (response) {
|
|
242
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
243
|
+
const assets = assetsOf(yield response.text(), response.url || list);
|
|
244
|
+
resolved.set(entry.break.id, assets);
|
|
245
|
+
entry.break = _objectSpread2(_objectSpread2({}, entry.break), {}, { assets });
|
|
246
|
+
ctx.emit("interstitials:changed", { breaks: api.breaks });
|
|
247
|
+
});
|
|
248
|
+
return function(_x) {
|
|
249
|
+
return _ref.apply(this, arguments);
|
|
250
|
+
};
|
|
251
|
+
}()).catch((error) => {
|
|
252
|
+
var _message;
|
|
253
|
+
ctx.emit("interstitials:warning", {
|
|
254
|
+
id: entry.break.id,
|
|
255
|
+
url: list,
|
|
256
|
+
reason: `asset list: ${String((_message = error.message) !== null && _message !== void 0 ? _message : error)}`
|
|
257
|
+
});
|
|
258
|
+
}));
|
|
259
|
+
return entry.resolving;
|
|
260
|
+
}
|
|
261
|
+
/** Loads in the presentation's place, playing on when the viewer was playing. */
|
|
262
|
+
function load(url, options) {
|
|
263
|
+
const resume = wanted || !element.paused && !element.ended;
|
|
264
|
+
own = true;
|
|
265
|
+
switching = true;
|
|
266
|
+
ctx.load(url, options);
|
|
267
|
+
own = false;
|
|
268
|
+
if (resume) keepPlaying();
|
|
269
|
+
}
|
|
270
|
+
function preload(url, options) {
|
|
271
|
+
ctx.preload(url, _objectSpread2(_objectSpread2({}, options), {}, { segments: SEGMENTS })).catch(() => {});
|
|
272
|
+
}
|
|
273
|
+
/** Plays the new source once it can. */
|
|
274
|
+
function keepPlaying() {
|
|
275
|
+
wanted = true;
|
|
276
|
+
const play = () => {
|
|
277
|
+
var _element$play;
|
|
278
|
+
(_element$play = element.play()) === null || _element$play === void 0 || _element$play.catch(() => {});
|
|
279
|
+
};
|
|
280
|
+
element.addEventListener("canplay", play, { once: true });
|
|
281
|
+
play();
|
|
282
|
+
}
|
|
283
|
+
function begin(_x2, _x3) {
|
|
284
|
+
return _begin.apply(this, arguments);
|
|
285
|
+
}
|
|
286
|
+
function _begin() {
|
|
287
|
+
_begin = _asyncToGenerator(function* (entry, resume, at = element.currentTime, ending = false) {
|
|
288
|
+
if (playing !== null || pending) return;
|
|
289
|
+
played.add(entry.break.id);
|
|
290
|
+
pending = true;
|
|
291
|
+
yield resolve(entry);
|
|
292
|
+
pending = false;
|
|
293
|
+
if (entry.break.assets.length === 0 || primary === null || playing !== null) return;
|
|
294
|
+
const active = ctx.getState().tracks.active;
|
|
295
|
+
tracks = new Map([...active].filter(([type]) => type === "audio" || type === "text"));
|
|
296
|
+
playing = {
|
|
297
|
+
entry,
|
|
298
|
+
asset: -1,
|
|
299
|
+
resume: ending ? resume : resumeOf(entry.break, resume),
|
|
300
|
+
ending,
|
|
301
|
+
at,
|
|
302
|
+
quartiles: 0,
|
|
303
|
+
last: 0,
|
|
304
|
+
limit: null
|
|
305
|
+
};
|
|
306
|
+
if (entry.break.playoutLimit !== void 0) {
|
|
307
|
+
const current = playing;
|
|
308
|
+
current.limit = setTimeout(() => {
|
|
309
|
+
if (playing === current) finish();
|
|
310
|
+
}, entry.break.playoutLimit * 1e3);
|
|
311
|
+
}
|
|
312
|
+
emit("break-start", entry);
|
|
313
|
+
next();
|
|
314
|
+
});
|
|
315
|
+
return _begin.apply(this, arguments);
|
|
316
|
+
}
|
|
317
|
+
/** The next asset of the break, or the return to the presentation. */
|
|
318
|
+
function next() {
|
|
319
|
+
const current = playing;
|
|
320
|
+
if (current === null) return;
|
|
321
|
+
if (current.asset >= 0) emit("asset-end", current.entry, { asset: current.asset });
|
|
322
|
+
current.asset += 1;
|
|
323
|
+
current.quartiles = 0;
|
|
324
|
+
current.last = 0;
|
|
325
|
+
const asset = current.entry.break.assets[current.asset];
|
|
326
|
+
if (asset === void 0) {
|
|
327
|
+
finish();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
load(asset.url, asset.mimeType !== void 0 ? { mimeType: asset.mimeType } : {});
|
|
331
|
+
emit("asset-start", current.entry, {
|
|
332
|
+
asset: current.asset,
|
|
333
|
+
url: asset.url
|
|
334
|
+
});
|
|
335
|
+
const after = current.entry.break.assets[current.asset + 1];
|
|
336
|
+
if (after !== void 0) preload(after.url, after.mimeType !== void 0 ? { mimeType: after.mimeType } : {});
|
|
337
|
+
else if (primary !== null) preload(primary.url, returnOptions(current.resume));
|
|
338
|
+
}
|
|
339
|
+
function returnOptions(resume) {
|
|
340
|
+
return _objectSpread2(_objectSpread2({}, (primary === null || primary === void 0 ? void 0 : primary.mimeType) !== void 0 ? { mimeType: primary.mimeType } : {}), live ? {} : { start: resume });
|
|
341
|
+
}
|
|
342
|
+
function finish() {
|
|
343
|
+
const current = playing;
|
|
344
|
+
if (current === null || primary === null) return;
|
|
345
|
+
if (current.limit !== null) clearTimeout(current.limit);
|
|
346
|
+
if (current.asset >= 0 && current.asset < current.entry.break.assets.length) emit("asset-end", current.entry, { asset: current.asset });
|
|
347
|
+
playing = null;
|
|
348
|
+
emit("break-end", current.entry, { resume: current.resume });
|
|
349
|
+
settling = true;
|
|
350
|
+
lastTime = current.resume;
|
|
351
|
+
if (current.ending) {
|
|
352
|
+
wanted = false;
|
|
353
|
+
load(primary.url, _objectSpread2(_objectSpread2({}, returnOptions(current.resume)), {}, { start: current.resume }));
|
|
354
|
+
over = true;
|
|
355
|
+
ctx.emit("interstitials:ended", {});
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (live) liveResume = {
|
|
359
|
+
id: current.entry.break.id,
|
|
360
|
+
offset: current.resume - current.entry.break.start
|
|
361
|
+
};
|
|
362
|
+
load(primary.url, returnOptions(current.resume));
|
|
363
|
+
}
|
|
364
|
+
/** The last unplayed `noJump` break a seek from one time to another passes. */
|
|
365
|
+
function jumped(from, to) {
|
|
366
|
+
return sorted().filter((e) => e.break.noJump && !played.has(e.break.id) && e.break.cue === void 0 && e.break.assets.length + (e.break.assetList !== void 0 ? 1 : 0) > 0 && e.break.start > from && e.break.start <= to).pop();
|
|
367
|
+
}
|
|
368
|
+
/** Follows the presentation's playhead: starts what it reaches, preloads what comes. */
|
|
369
|
+
function follow() {
|
|
370
|
+
var _seekFrom;
|
|
371
|
+
if (playing !== null) {
|
|
372
|
+
followAsset(playing);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (primary === null || settling) return;
|
|
376
|
+
const presentation = ctx.getState().presentation;
|
|
377
|
+
if (presentation === null || presentation.id !== presentationId) refresh();
|
|
378
|
+
const time = element.currentTime;
|
|
379
|
+
const from = (_seekFrom = seekFrom) !== null && _seekFrom !== void 0 ? _seekFrom : lastTime;
|
|
380
|
+
const seeked = seekFrom !== null || Math.abs(time - lastTime) > JUMP;
|
|
381
|
+
seekFrom = null;
|
|
382
|
+
if (seeked) {
|
|
383
|
+
if (time < primaryHead.duration - 1) {
|
|
384
|
+
ended = false;
|
|
385
|
+
over = false;
|
|
386
|
+
}
|
|
387
|
+
for (const entry of entries.values()) if (!entry.break.once && entry.break.start > time) played.delete(entry.break.id);
|
|
388
|
+
const passed = time > from ? jumped(from, time) : void 0;
|
|
389
|
+
if (passed !== void 0) {
|
|
390
|
+
lastTime = time;
|
|
391
|
+
begin(passed, time, passed.break.start);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
for (const entry of sorted()) {
|
|
396
|
+
var _b$resolveAhead;
|
|
397
|
+
const b = entry.break;
|
|
398
|
+
if (b.cue !== void 0) continue;
|
|
399
|
+
if (b.assets.length === 0 && b.assetList === void 0) {
|
|
400
|
+
if (isBreak(b)) stitched(entry, time);
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
const start = startOf(b);
|
|
404
|
+
const ahead = start - time;
|
|
405
|
+
if (ahead > 0 && ahead <= Math.max(LOOKAHEAD, (_b$resolveAhead = b.resolveAhead) !== null && _b$resolveAhead !== void 0 ? _b$resolveAhead : 0) && !entry.preloaded) {
|
|
406
|
+
entry.preloaded = true;
|
|
407
|
+
resolve(entry).then(() => {
|
|
408
|
+
const first = entry.break.assets[0];
|
|
409
|
+
if (first !== void 0) preload(first.url, first.mimeType !== void 0 ? { mimeType: first.mimeType } : {});
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
const crossed = !seeked && from < start + .001 && time >= start;
|
|
413
|
+
const landed = seeked && b.covers > 0 && time >= start && time < b.start + b.covers;
|
|
414
|
+
if (!played.has(b.id) && (crossed || landed)) {
|
|
415
|
+
lastTime = time;
|
|
416
|
+
begin(entry, b.start + b.resumeOffset, start);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
lastTime = time;
|
|
421
|
+
wake(time);
|
|
422
|
+
}
|
|
423
|
+
/** A break the presentation plays itself: report it as the playhead crosses it. */
|
|
424
|
+
function stitched(entry, time) {
|
|
425
|
+
const b = entry.break;
|
|
426
|
+
const inside = time >= b.start && time < b.start + Math.max(b.covers, .001);
|
|
427
|
+
if (inside && !entry.inside) {
|
|
428
|
+
entry.inside = true;
|
|
429
|
+
entry.quartiles = 0;
|
|
430
|
+
emit("break-start", entry, { stitched: true });
|
|
431
|
+
}
|
|
432
|
+
if (inside && b.covers > 0) {
|
|
433
|
+
var _entry$quartiles, _QUARTILES, _entry$quartiles2;
|
|
434
|
+
const fraction = (time - b.start) / b.covers;
|
|
435
|
+
while (((_entry$quartiles = entry.quartiles) !== null && _entry$quartiles !== void 0 ? _entry$quartiles : 0) < QUARTILES.length && fraction >= ((_QUARTILES = QUARTILES[(_entry$quartiles2 = entry.quartiles) !== null && _entry$quartiles2 !== void 0 ? _entry$quartiles2 : 0]) !== null && _QUARTILES !== void 0 ? _QUARTILES : 1)) {
|
|
436
|
+
var _entry$quartiles3, _entry$quartiles4;
|
|
437
|
+
emit("progress", entry, { quartile: ((_entry$quartiles3 = entry.quartiles) !== null && _entry$quartiles3 !== void 0 ? _entry$quartiles3 : 0) + 1 });
|
|
438
|
+
entry.quartiles = ((_entry$quartiles4 = entry.quartiles) !== null && _entry$quartiles4 !== void 0 ? _entry$quartiles4 : 0) + 1;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (!inside && entry.inside) {
|
|
442
|
+
entry.inside = false;
|
|
443
|
+
emit("break-end", entry, { stitched: true });
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function followAsset(current) {
|
|
447
|
+
const time = element.currentTime;
|
|
448
|
+
if (element.seeking && current.entry.break.noSkip) {
|
|
449
|
+
if (Math.abs(time - current.last) > .5) element.currentTime = current.last;
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
current.last = time;
|
|
453
|
+
const asset = current.entry.break.assets[current.asset];
|
|
454
|
+
const length = Number.isFinite(element.duration) ? element.duration : asset === null || asset === void 0 ? void 0 : asset.duration;
|
|
455
|
+
if (length !== void 0 && length > 0) {
|
|
456
|
+
var _QUARTILES$current$qu;
|
|
457
|
+
const fraction = time / length;
|
|
458
|
+
while (current.quartiles < QUARTILES.length && fraction >= ((_QUARTILES$current$qu = QUARTILES[current.quartiles]) !== null && _QUARTILES$current$qu !== void 0 ? _QUARTILES$current$qu : 1)) {
|
|
459
|
+
current.quartiles += 1;
|
|
460
|
+
emit("progress", current.entry, {
|
|
461
|
+
asset: current.asset,
|
|
462
|
+
quartile: current.quartiles
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/** A timer to the next break start ahead, since `timeupdate` fires only every quarter second. */
|
|
468
|
+
function wake(time) {
|
|
469
|
+
if (timer !== null) clearTimeout(timer);
|
|
470
|
+
timer = null;
|
|
471
|
+
if (element.paused) return;
|
|
472
|
+
let at = Number.POSITIVE_INFINITY;
|
|
473
|
+
for (const entry of entries.values()) {
|
|
474
|
+
const b = entry.break;
|
|
475
|
+
for (const edge of [
|
|
476
|
+
b.start - LOOKAHEAD,
|
|
477
|
+
b.start,
|
|
478
|
+
b.start + b.covers
|
|
479
|
+
]) if (edge > time) at = Math.min(at, edge);
|
|
480
|
+
}
|
|
481
|
+
if (!Number.isFinite(at)) return;
|
|
482
|
+
const rate = element.playbackRate > 0 ? element.playbackRate : 1;
|
|
483
|
+
timer = setTimeout(follow, (at - time) / rate * 1e3 + 10);
|
|
484
|
+
}
|
|
485
|
+
const onLoading = ctx.on("lifecycle:loading", (payload) => {
|
|
486
|
+
if (own) return;
|
|
487
|
+
const { url, mimeType, start } = payload;
|
|
488
|
+
reset();
|
|
489
|
+
primary = _objectSpread2(_objectSpread2({ url }, mimeType !== void 0 ? { mimeType } : {}), {}, { start: start !== null && start !== void 0 ? start : 0 });
|
|
490
|
+
const kept = memory;
|
|
491
|
+
memory = null;
|
|
492
|
+
if (kept !== null && kept.url === url && start !== void 0) {
|
|
493
|
+
for (const id of kept.played) played.add(id);
|
|
494
|
+
for (const [id, assets] of kept.resolved) resolved.set(id, assets);
|
|
495
|
+
started = true;
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
/** After a return, the viewer's audio and subtitles again. */
|
|
499
|
+
function restoreTracks() {
|
|
500
|
+
if (tracks === null || settling || playing !== null) return;
|
|
501
|
+
const state = ctx.getState();
|
|
502
|
+
if (state.presentation === null) return;
|
|
503
|
+
const active = [...state.tracks.active.values()];
|
|
504
|
+
for (const trackId of tracks.values()) if (state.tracks.available.includes(trackId) && !active.includes(trackId)) ctx.dispatch({
|
|
505
|
+
type: "SELECT_TRACK",
|
|
506
|
+
trackId
|
|
507
|
+
});
|
|
508
|
+
tracks = null;
|
|
509
|
+
}
|
|
510
|
+
const onTracks = ctx.on("tracks:changed", () => {
|
|
511
|
+
if (playing !== null) return;
|
|
512
|
+
refresh();
|
|
513
|
+
restoreTracks();
|
|
514
|
+
});
|
|
515
|
+
const onPresentation = ctx.on("presentation:changed", refresh);
|
|
516
|
+
const onError = ctx.on("error", (payload) => {
|
|
517
|
+
var _current$entry$break$;
|
|
518
|
+
const current = playing;
|
|
519
|
+
if (current === null || (payload === null || payload === void 0 ? void 0 : payload.fatal) !== true) return;
|
|
520
|
+
ctx.emit("interstitials:warning", {
|
|
521
|
+
id: current.entry.break.id,
|
|
522
|
+
url: (_current$entry$break$ = current.entry.break.assets[current.asset]) === null || _current$entry$break$ === void 0 ? void 0 : _current$entry$break$.url,
|
|
523
|
+
reason: "asset failed"
|
|
524
|
+
});
|
|
525
|
+
queueMicrotask(() => {
|
|
526
|
+
if (playing === current) next();
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
const onSeeking = () => {
|
|
530
|
+
var _seekFrom2;
|
|
531
|
+
if (playing === null && !settling) (_seekFrom2 = seekFrom) !== null && _seekFrom2 !== void 0 || (seekFrom = lastTime);
|
|
532
|
+
follow();
|
|
533
|
+
};
|
|
534
|
+
/** The return landed: the presentation's own seek to the resume point is behind. */
|
|
535
|
+
function settle() {
|
|
536
|
+
settling = false;
|
|
537
|
+
lastTime = element.currentTime;
|
|
538
|
+
seekFrom = null;
|
|
539
|
+
restoreTracks();
|
|
540
|
+
}
|
|
541
|
+
const onSeeked = () => {
|
|
542
|
+
if (settling && playing === null) {
|
|
543
|
+
settle();
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
follow();
|
|
547
|
+
};
|
|
548
|
+
const onPlaying = () => {
|
|
549
|
+
switching = false;
|
|
550
|
+
if (settling && playing === null) settle();
|
|
551
|
+
if (playing === null) started = true;
|
|
552
|
+
seekLive();
|
|
553
|
+
follow();
|
|
554
|
+
};
|
|
555
|
+
const onPlay = () => {
|
|
556
|
+
wanted = true;
|
|
557
|
+
follow();
|
|
558
|
+
};
|
|
559
|
+
const onPause = () => {
|
|
560
|
+
if (!switching && !element.ended) wanted = false;
|
|
561
|
+
follow();
|
|
562
|
+
};
|
|
563
|
+
const onCanPlay = () => {
|
|
564
|
+
switching = false;
|
|
565
|
+
};
|
|
566
|
+
const onEnded = () => {
|
|
567
|
+
if (!element.ended) return;
|
|
568
|
+
if (playing !== null) {
|
|
569
|
+
next();
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (ended || primary === null || settling) return;
|
|
573
|
+
ended = true;
|
|
574
|
+
const post = sorted().find((e) => e.break.cue === "post" && !played.has(e.break.id));
|
|
575
|
+
if (post !== void 0) {
|
|
576
|
+
begin(post, primaryHead.duration, element.currentTime, true);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
over = true;
|
|
580
|
+
ctx.emit("interstitials:ended", {});
|
|
581
|
+
};
|
|
582
|
+
const onTime = () => follow();
|
|
583
|
+
element.addEventListener("timeupdate", onTime);
|
|
584
|
+
element.addEventListener("play", onPlay);
|
|
585
|
+
element.addEventListener("pause", onPause);
|
|
586
|
+
element.addEventListener("canplay", onCanPlay);
|
|
587
|
+
element.addEventListener("seeking", onSeeking);
|
|
588
|
+
element.addEventListener("seeked", onSeeked);
|
|
589
|
+
element.addEventListener("playing", onPlaying);
|
|
590
|
+
element.addEventListener("ended", onEnded);
|
|
591
|
+
const primaryHead = {
|
|
592
|
+
get currentTime() {
|
|
593
|
+
return playing !== null ? playing.at : element.currentTime;
|
|
594
|
+
},
|
|
595
|
+
get duration() {
|
|
596
|
+
return Number.isFinite(duration) ? duration : element.duration;
|
|
597
|
+
},
|
|
598
|
+
seek(time) {
|
|
599
|
+
if (playing === null) {
|
|
600
|
+
element.currentTime = time;
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (playing.entry.break.noSkip) return;
|
|
604
|
+
playing.resume = time;
|
|
605
|
+
finish();
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
/** The inserted breaks behind a presentation time, which add their length to it. */
|
|
609
|
+
const before = (time) => sorted().filter((e) => e.break.covers === 0 && e.break.cue !== "post" && (e.break.start < time || played.has(e.break.id) && e.break.start <= time)).reduce((sum, e) => sum + lengthOf(e.break), 0);
|
|
610
|
+
const api = {
|
|
611
|
+
get breaks() {
|
|
612
|
+
return sorted().map((e) => e.break);
|
|
613
|
+
},
|
|
614
|
+
get ended() {
|
|
615
|
+
if (over) return true;
|
|
616
|
+
const due = sorted().some((e) => e.break.cue === "post" && !played.has(e.break.id));
|
|
617
|
+
return element.ended && playing === null && !pending && !settling && !due;
|
|
618
|
+
},
|
|
619
|
+
get playing() {
|
|
620
|
+
return playing === null || playing.asset < 0 ? null : {
|
|
621
|
+
break: playing.entry.break,
|
|
622
|
+
asset: playing.asset
|
|
623
|
+
};
|
|
624
|
+
},
|
|
625
|
+
primary: primaryHead,
|
|
626
|
+
integrated: {
|
|
627
|
+
get currentTime() {
|
|
628
|
+
if (playing === null) return element.currentTime + before(element.currentTime);
|
|
629
|
+
const spent = playing.entry.break.assets.slice(0, Math.max(0, playing.asset)).reduce((sum, asset) => {
|
|
630
|
+
var _asset$duration2;
|
|
631
|
+
return sum + ((_asset$duration2 = asset.duration) !== null && _asset$duration2 !== void 0 ? _asset$duration2 : 0);
|
|
632
|
+
}, 0);
|
|
633
|
+
return playing.at + before(playing.at - .001) + spent + element.currentTime;
|
|
634
|
+
},
|
|
635
|
+
get duration() {
|
|
636
|
+
const all = sorted().filter((e) => e.break.covers === 0).reduce((sum, e) => sum + lengthOf(e.break), 0);
|
|
637
|
+
return primaryHead.duration + all;
|
|
638
|
+
},
|
|
639
|
+
seek(time) {
|
|
640
|
+
let primaryTime = time;
|
|
641
|
+
for (const entry of sorted()) {
|
|
642
|
+
if (entry.break.covers > 0 || entry.break.start >= primaryTime) continue;
|
|
643
|
+
primaryTime -= lengthOf(entry.break);
|
|
644
|
+
}
|
|
645
|
+
primaryHead.seek(Math.max(0, primaryTime));
|
|
646
|
+
}
|
|
647
|
+
},
|
|
648
|
+
schedule(entry) {
|
|
649
|
+
var _entry$id, _entry$covers, _entry$once, _entry$resumeOffset, _entry$noSkip, _entry$noJump;
|
|
650
|
+
seq += 1;
|
|
651
|
+
const id = (_entry$id = entry.id) !== null && _entry$id !== void 0 ? _entry$id : `page-${seq}`;
|
|
652
|
+
const covers = (_entry$covers = entry.covers) !== null && _entry$covers !== void 0 ? _entry$covers : 0;
|
|
653
|
+
const value = _objectSpread2(_objectSpread2(_objectSpread2({
|
|
654
|
+
id,
|
|
655
|
+
source: "page",
|
|
656
|
+
start: entry.cue === "pre" ? 0 : entry.cue === "post" ? Number.isFinite(duration) ? duration : entry.start : entry.start
|
|
657
|
+
}, entry.cue !== void 0 ? { cue: entry.cue } : {}), {}, {
|
|
658
|
+
once: (_entry$once = entry.once) !== null && _entry$once !== void 0 ? _entry$once : false,
|
|
659
|
+
assets: entry.assets,
|
|
660
|
+
covers,
|
|
661
|
+
resumeOffset: (_entry$resumeOffset = entry.resumeOffset) !== null && _entry$resumeOffset !== void 0 ? _entry$resumeOffset : covers,
|
|
662
|
+
noSkip: (_entry$noSkip = entry.noSkip) !== null && _entry$noSkip !== void 0 ? _entry$noSkip : false,
|
|
663
|
+
noJump: (_entry$noJump = entry.noJump) !== null && _entry$noJump !== void 0 ? _entry$noJump : false
|
|
664
|
+
}, entry.skipAfter !== void 0 ? { skipAfter: entry.skipAfter } : {}), {}, { attributes: {} });
|
|
665
|
+
page.set(id, value);
|
|
666
|
+
const known = entries.get(id);
|
|
667
|
+
if (known !== void 0 && (playing === null || playing === void 0 ? void 0 : playing.entry) !== known) known.break = value;
|
|
668
|
+
else if (known === void 0) entries.set(id, { break: value });
|
|
669
|
+
ctx.emit("interstitials:changed", { breaks: api.breaks });
|
|
670
|
+
if (value.cue === "pre" && primary !== null && playing === null) {
|
|
671
|
+
if (started && element.currentTime < 1) begin(entries.get(id), primary.start);
|
|
672
|
+
else if (!started) refresh();
|
|
673
|
+
}
|
|
674
|
+
return value;
|
|
675
|
+
},
|
|
676
|
+
cancel(id) {
|
|
677
|
+
const known = entries.get(id);
|
|
678
|
+
if (known === void 0 || (playing === null || playing === void 0 ? void 0 : playing.entry) === known) return;
|
|
679
|
+
page.delete(id);
|
|
680
|
+
entries.delete(id);
|
|
681
|
+
ctx.emit("interstitials:changed", { breaks: api.breaks });
|
|
682
|
+
},
|
|
683
|
+
skip() {
|
|
684
|
+
const current = playing;
|
|
685
|
+
if (current === null) return false;
|
|
686
|
+
const after = current.entry.break.skipAfter;
|
|
687
|
+
if (current.entry.break.noSkip && after === void 0) return false;
|
|
688
|
+
if (after !== void 0 && element.currentTime < after) return false;
|
|
689
|
+
ctx.emit("interstitials:skipped", {
|
|
690
|
+
id: current.entry.break.id,
|
|
691
|
+
asset: current.asset
|
|
692
|
+
});
|
|
693
|
+
next();
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
ctx.registerNamespace("interstitials", api);
|
|
698
|
+
ctx.registerTransform({
|
|
699
|
+
name: "interstitials-emsg",
|
|
700
|
+
order: 161,
|
|
701
|
+
transform(data, meta) {
|
|
702
|
+
if (playing !== null || primary === null) return data;
|
|
703
|
+
if (meta.contentType !== "video" && meta.contentType !== "audio") return data;
|
|
704
|
+
if (meta.isInit || findBox(data, "moov") !== null) {
|
|
705
|
+
const scales = trackTimescales(data);
|
|
706
|
+
if (scales.size > 0) timescales.set(meta.renditionId, scales);
|
|
707
|
+
}
|
|
708
|
+
let added = false;
|
|
709
|
+
for (const { box, start, end } of placeEmsg(data, meta.start, timescales.get(meta.renditionId))) {
|
|
710
|
+
const entry = fromEvent(_objectSpread2(_objectSpread2(_objectSpread2({ scheme: box.scheme }, box.value !== "" ? { value: box.value } : {}), {}, {
|
|
711
|
+
id: String(box.id),
|
|
712
|
+
start
|
|
713
|
+
}, end !== null ? { duration: end - start } : {}), {}, {
|
|
714
|
+
data: bytesToBase64(box.data),
|
|
715
|
+
timescale: box.timescale,
|
|
716
|
+
elements: presentationElements(box.data)
|
|
717
|
+
}), primary.url);
|
|
718
|
+
if (entry === null || inband.has(entry.id)) continue;
|
|
719
|
+
inband.set(entry.id, entry);
|
|
720
|
+
added = true;
|
|
721
|
+
}
|
|
722
|
+
if (added) refresh();
|
|
723
|
+
return data;
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
return () => {
|
|
727
|
+
if (primary !== null) memory = {
|
|
728
|
+
url: primary.url,
|
|
729
|
+
played: [...played],
|
|
730
|
+
resolved: new Map(resolved)
|
|
731
|
+
};
|
|
732
|
+
onLoading();
|
|
733
|
+
onTracks();
|
|
734
|
+
onPresentation();
|
|
735
|
+
onError();
|
|
736
|
+
if (timer !== null) clearTimeout(timer);
|
|
737
|
+
if ((playing === null || playing === void 0 ? void 0 : playing.limit) != null) clearTimeout(playing.limit);
|
|
738
|
+
element.removeEventListener("timeupdate", onTime);
|
|
739
|
+
element.removeEventListener("play", onPlay);
|
|
740
|
+
element.removeEventListener("pause", onPause);
|
|
741
|
+
element.removeEventListener("canplay", onCanPlay);
|
|
742
|
+
element.removeEventListener("seeking", onSeeking);
|
|
743
|
+
element.removeEventListener("seeked", onSeeked);
|
|
744
|
+
element.removeEventListener("playing", onPlaying);
|
|
745
|
+
element.removeEventListener("ended", onEnded);
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
export { interstitials as default };
|