itube-modern-player 0.4.2 → 0.4.3
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 +10 -2
- package/dist/core/dom.d.ts +8 -1
- package/dist/core.cjs +3 -3
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +179 -176
- package/dist/core.js.map +1 -1
- package/dist/itube-modern-player.iife.js +3 -3
- package/dist/itube-modern-player.iife.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +12 -9
- package/dist/vue.d.ts +2 -2
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -9,7 +9,19 @@ function g(a, t, e) {
|
|
|
9
9
|
const i = o("button", `imp-btn ${a}`, { type: "button", "aria-label": t, title: t });
|
|
10
10
|
return i.innerHTML = e, i;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function Q(a, t) {
|
|
13
|
+
const e = o("div", `${t}__meta`);
|
|
14
|
+
return a.forEach((i, s) => {
|
|
15
|
+
s > 0 && e.append(document.createTextNode(" "));
|
|
16
|
+
const n = typeof i == "string" ? i : i.text, r = typeof i == "string" ? void 0 : i.icon, l = o("span", `${t}__meta-chunk`);
|
|
17
|
+
if (r) {
|
|
18
|
+
const h = o("span", `${t}__meta-icon`);
|
|
19
|
+
h.innerHTML = r, l.append(h);
|
|
20
|
+
}
|
|
21
|
+
l.append(document.createTextNode(n)), e.append(l);
|
|
22
|
+
}), e;
|
|
23
|
+
}
|
|
24
|
+
function C(a, t, e) {
|
|
13
25
|
a.innerHTML = t, e !== void 0 && (a.setAttribute("aria-label", e), a.setAttribute("title", e));
|
|
14
26
|
}
|
|
15
27
|
function w(a, t, e) {
|
|
@@ -26,14 +38,14 @@ function I(a) {
|
|
|
26
38
|
const e = t[1] ? Number(t[1]) : 0, i = Number(t[2]), s = Number(t[3]), n = t[4] ? Number(t[4].padEnd(3, "0")) : 0;
|
|
27
39
|
return e * 3600 + i * 60 + s + n / 1e3;
|
|
28
40
|
}
|
|
29
|
-
function
|
|
41
|
+
function z(a) {
|
|
30
42
|
const t = [], e = a.replace(/\r\n?/g, `
|
|
31
43
|
`).split(/\n\n+/);
|
|
32
44
|
for (const i of e) {
|
|
33
45
|
const s = i.split(`
|
|
34
|
-
`).filter((
|
|
46
|
+
`).filter((p) => p.trim() !== "");
|
|
35
47
|
if (s.length === 0) continue;
|
|
36
|
-
let n = s.findIndex((
|
|
48
|
+
let n = s.findIndex((p) => p.includes("-->"));
|
|
37
49
|
if (n === -1) continue;
|
|
38
50
|
const [r, l] = s[n].split("-->"), h = I(r), c = I((l ?? "").split(" ")[1] ?? l ?? "") ?? I(l ?? "");
|
|
39
51
|
if (h === null || c === null) continue;
|
|
@@ -43,14 +55,14 @@ function Q(a) {
|
|
|
43
55
|
}
|
|
44
56
|
return t;
|
|
45
57
|
}
|
|
46
|
-
function
|
|
58
|
+
function X(a, t) {
|
|
47
59
|
try {
|
|
48
60
|
return new URL(a, new URL(t, window.location.href)).toString();
|
|
49
61
|
} catch {
|
|
50
62
|
return a;
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
|
-
class
|
|
65
|
+
class J {
|
|
54
66
|
constructor() {
|
|
55
67
|
this.listeners = /* @__PURE__ */ new Map();
|
|
56
68
|
}
|
|
@@ -82,56 +94,56 @@ class X {
|
|
|
82
94
|
this.listeners.clear();
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
|
-
const
|
|
86
|
-
play:
|
|
87
|
-
pause:
|
|
88
|
-
replay:
|
|
89
|
-
bigPlay:
|
|
90
|
-
volumeHigh:
|
|
91
|
-
volumeLow:
|
|
92
|
-
volumeMute:
|
|
93
|
-
fullscreen:
|
|
94
|
-
fullscreenExit:
|
|
95
|
-
pip:
|
|
96
|
-
settings:
|
|
97
|
-
speed:
|
|
98
|
-
scenes:
|
|
99
|
-
shuffle:
|
|
100
|
-
repeat:
|
|
101
|
-
subtitles:
|
|
102
|
-
list:
|
|
103
|
-
next:
|
|
104
|
-
previous:
|
|
97
|
+
const v = (a, t = "0 0 24 24") => `<svg viewBox="${t}" fill="currentColor" aria-hidden="true" focusable="false">${a}</svg>`, Y = {
|
|
98
|
+
play: v('<path d="M8 5.14v13.72c0 .8.87 1.3 1.56.88l10.54-6.86a1.05 1.05 0 0 0 0-1.76L9.56 4.26C8.87 3.84 8 4.34 8 5.14Z"/>'),
|
|
99
|
+
pause: v('<rect x="6" y="5" width="4" height="14" rx="1"/><rect x="14" y="5" width="4" height="14" rx="1"/>'),
|
|
100
|
+
replay: v('<path d="M12 5V2.5L7.5 6 12 9.5V7a5 5 0 1 1-5 5H5a7 7 0 1 0 7-7Z"/>'),
|
|
101
|
+
bigPlay: v('<path d="M8 5.14v13.72c0 .8.87 1.3 1.56.88l10.54-6.86a1.05 1.05 0 0 0 0-1.76L9.56 4.26C8.87 3.84 8 4.34 8 5.14Z"/>'),
|
|
102
|
+
volumeHigh: v('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="M14.5 8.6a4.5 4.5 0 0 1 0 6.8v-1.9a2.5 2.5 0 0 0 0-3v-1.9Z"/><path d="M14.5 5.2a8 8 0 0 1 0 13.6v-2a6 6 0 0 0 0-9.6v-2Z"/>'),
|
|
103
|
+
volumeLow: v('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="M14.5 8.6a4.5 4.5 0 0 1 0 6.8v-1.9a2.5 2.5 0 0 0 0-3v-1.9Z"/>'),
|
|
104
|
+
volumeMute: v('<path d="M4 9v6h3.5L12 19.5v-15L7.5 9H4Z"/><path d="m15.3 9.3 1.4 1.4 1.4-1.4 1.4 1.4-1.4 1.4 1.4 1.4-1.4 1.4-1.4-1.4-1.4 1.4-1.4-1.4 1.4-1.4-1.4-1.4 1.4-1.4Z"/>'),
|
|
105
|
+
fullscreen: v('<path d="M5 5h5v2H7v3H5V5Zm9 0h5v5h-2V7h-3V5ZM5 14h2v3h3v2H5v-5Zm12 0h2v5h-5v-2h3v-3Z"/>'),
|
|
106
|
+
fullscreenExit: v('<path d="M10 10H5V8h3V5h2v5Zm4 0V5h2v3h3v2h-5Zm-4 4v5H8v-3H5v-2h5Zm4 0h5v2h-3v3h-2v-5Z"/>'),
|
|
107
|
+
pip: v('<path d="M3 5h18v14H3V5Zm2 2v10h14V7H5Z"/><rect x="12" y="11" width="6" height="4"/>'),
|
|
108
|
+
settings: v('<path d="M12 8.5A3.5 3.5 0 1 0 12 15.5 3.5 3.5 0 0 0 12 8.5Zm0 2a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z"/><path d="M10.3 2.8 9.9 5.1a7 7 0 0 0-1.5.86l-2.2-.8-1.7 3 1.8 1.5a7 7 0 0 0 0 1.7l-1.8 1.5 1.7 3 2.2-.8c.46.36.97.65 1.5.86l.4 2.3h3.4l.4-2.3a7 7 0 0 0 1.5-.86l2.2.8 1.7-3-1.8-1.5a7 7 0 0 0 0-1.7l1.8-1.5-1.7-3-2.2.8a7 7 0 0 0-1.5-.86l-.4-2.3h-3.4Zm1.7 5.7a3.5 3.5 0 1 1 0 7 3.5 3.5 0 0 1 0-7Z"/>'),
|
|
109
|
+
speed: v('<path d="M12 4a9 9 0 0 0-9 9 8.96 8.96 0 0 0 1.62 5.16l1.64-1.15A7 7 0 0 1 5 13a7 7 0 1 1 12.74 4.01l1.64 1.15A8.96 8.96 0 0 0 21 13a9 9 0 0 0-9-9Z"/><path d="m15.6 8.3-3.95 3.13a1.5 1.5 0 1 0 1.92 1.92L16.7 9.4a.78.78 0 0 0-1.1-1.1Z"/>'),
|
|
110
|
+
scenes: v('<path d="M3 5h18v14H3V5Zm2 2v10h3V7H5Zm5 0v10h9V7h-9Zm-5 3h3v1H5v-1Zm0 3h3v1H5v-1Z"/>'),
|
|
111
|
+
shuffle: v('<path d="M4 6h2.6c1.5 0 2.9.7 3.8 1.9l4.1 5.4a2.75 2.75 0 0 0 2.2 1.1H19l-1.8-1.8 1.4-1.4 4.2 4.2-4.2 4.2-1.4-1.4L19 16.4h-2.3a4.75 4.75 0 0 1-3.8-1.9L8.8 9.1A2.75 2.75 0 0 0 6.6 8H4V6Z"/><path d="M19 7.6h-2.3c-.86 0-1.67.41-2.18 1.1l-.93 1.23-1.25-1.65.58-.77A4.75 4.75 0 0 1 16.7 5.6H19L17.2 3.8l1.4-1.4 4.2 4.2-4.2 4.2-1.4-1.4L19 7.6Z" transform="translate(0 1.2)"/>'),
|
|
112
|
+
repeat: v('<path d="M7 7h10v2.5L21 6l-4-3.5V5H5v6h2V7Zm10 10H7v-2.5L3 18l4 3.5V19h12v-6h-2v4Z"/>'),
|
|
113
|
+
subtitles: v('<path d="M3 5h18v14H3V5Zm2 2v10h14V7H5Zm2 3h6v2H7v-2Zm8 0h2v2h-2v-2ZM7 14h2v2H7v-2Zm4 0h6v2h-6v-2Z"/>'),
|
|
114
|
+
list: v('<path d="M4 6h2v2H4V6Zm4 0h12v2H8V6ZM4 11h2v2H4v-2Zm4 0h12v2H8v-2ZM4 16h2v2H4v-2Zm4 0h12v2H8v-2Z"/>'),
|
|
115
|
+
next: v('<path d="M6 5.5v13c0 .77.84 1.25 1.5.85l9-6.5a1 1 0 0 0 0-1.7l-9-6.5c-.66-.4-1.5.08-1.5.85Z"/><rect x="17" y="5" width="2.5" height="14" rx="1"/>'),
|
|
116
|
+
previous: v('<path d="M18 5.5v13c0 .77-.84 1.25-1.5.85l-9-6.5a1 1 0 0 1 0-1.7l9-6.5c.66-.4 1.5.08 1.5.85Z"/><rect x="4.5" y="5" width="2.5" height="14" rx="1"/>'),
|
|
105
117
|
// Thin circular-arrow ("rotate") icons — open center so the step number reads
|
|
106
118
|
// clearly inside the ring (matches the reference skip ±N look).
|
|
107
119
|
seekForward: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/></svg>',
|
|
108
120
|
seekBack: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',
|
|
109
|
-
like:
|
|
110
|
-
dislike:
|
|
111
|
-
addTo:
|
|
112
|
-
share:
|
|
113
|
-
report:
|
|
114
|
-
more:
|
|
115
|
-
close:
|
|
121
|
+
like: v('<path d="M9 21H5a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h4v11Zm2 0h7.1a2 2 0 0 0 2-1.6l1.3-7a2 2 0 0 0-2-2.4H14V5.5A2.5 2.5 0 0 0 11.5 3l-.5.1V10h-.9L11 21Z"/>'),
|
|
122
|
+
dislike: v('<path d="M15 3h4a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-4V3Zm-2 0H5.9a2 2 0 0 0-2 1.6l-1.3 7a2 2 0 0 0 2 2.4H10v4.5A2.5 2.5 0 0 0 12.5 21l.5-.1V14h.9L13 3Z"/>'),
|
|
123
|
+
addTo: v('<path d="M4 6h12v2H4V6Zm0 4h12v2H4v-2Zm0 4h8v2H4v-2Zm14 0v-4h2v4h4v2h-4v4h-2v-4h-4v-2h4Z"/>'),
|
|
124
|
+
share: v('<path d="M18 8a3 3 0 1 0-2.83-4H15a3 3 0 0 0 .14 1.06L8.4 8.94a3 3 0 1 0 0 6.12l6.74 3.88A3 3 0 1 0 16 16.6l-6.74-3.88a3.03 3.03 0 0 0 0-1.44L16 7.4c.55.38 1.24.6 2 .6Z"/>'),
|
|
125
|
+
report: v('<path d="M5 3h2v18H5V3Zm4 1h10l-2.5 4L19 12H9V4Z"/>'),
|
|
126
|
+
more: v('<circle cx="12" cy="5" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="12" cy="19" r="2"/>'),
|
|
127
|
+
close: v('<path d="m6.4 5 5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19 5 17.6 10.6 12 5 6.4 6.4 5Z"/>'),
|
|
116
128
|
// Generic "uploaded by a user" glyph (head + shoulders) for preview meta.
|
|
117
|
-
user:
|
|
129
|
+
user: v('<path d="M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm0 2c-3.6 0-8 1.8-8 4.4V21h16v-2.6c0-2.6-4.4-4.4-8-4.4Z"/>'),
|
|
118
130
|
// Generic "channel" glyph (play badge) for preview meta when a channel is set.
|
|
119
|
-
channel:
|
|
131
|
+
channel: v('<path d="M3 5h18a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Zm7 3.5v7l6-3.5-6-3.5Z"/>')
|
|
120
132
|
}, P = { en: V };
|
|
121
|
-
function
|
|
133
|
+
function Lt(a, t) {
|
|
122
134
|
P[a] = t;
|
|
123
135
|
}
|
|
124
|
-
function
|
|
136
|
+
function Bt(a) {
|
|
125
137
|
for (const [t, e] of Object.entries(a))
|
|
126
138
|
e && (P[t] = e);
|
|
127
139
|
}
|
|
128
|
-
function
|
|
140
|
+
function tt(a) {
|
|
129
141
|
return a && P[a] || V;
|
|
130
142
|
}
|
|
131
|
-
function
|
|
143
|
+
function Tt() {
|
|
132
144
|
return Object.keys(P);
|
|
133
145
|
}
|
|
134
|
-
function
|
|
146
|
+
function et(a, t, e = 100) {
|
|
135
147
|
if (a.length === 0 || !Number.isFinite(t) || t <= 0) return [];
|
|
136
148
|
const i = new Array(e).fill(0);
|
|
137
149
|
let s = !1;
|
|
@@ -139,18 +151,18 @@ function tt(a, t, e = 100) {
|
|
|
139
151
|
if (!Number.isFinite(c.time) || c.time < 0 || c.time > t) continue;
|
|
140
152
|
const u = Math.max(0, c.value);
|
|
141
153
|
if (u === 0) continue;
|
|
142
|
-
const
|
|
143
|
-
i[
|
|
154
|
+
const p = Math.min(e - 1, Math.floor(c.time / t * e));
|
|
155
|
+
i[p] += u, s = !0;
|
|
144
156
|
}
|
|
145
157
|
if (!s) return [];
|
|
146
158
|
const n = [0.06, 0.24, 0.4, 0.24, 0.06], r = i.map(
|
|
147
|
-
(c, u) => n.reduce((
|
|
159
|
+
(c, u) => n.reduce((p, f, m) => p + f * (i[u + m - 2] ?? 0), 0)
|
|
148
160
|
), l = Math.max(...r);
|
|
149
161
|
if (l <= 0) return [];
|
|
150
162
|
const h = 0.08;
|
|
151
163
|
return r.map((c) => h + (1 - h) * (c / l));
|
|
152
164
|
}
|
|
153
|
-
function
|
|
165
|
+
function it(a, t = 1e3, e = 100) {
|
|
154
166
|
if (a.length === 0) return "";
|
|
155
167
|
const i = t / (a.length - 1 || 1);
|
|
156
168
|
let s = `M 0 ${e}`;
|
|
@@ -158,7 +170,7 @@ function et(a, t = 1e3, e = 100) {
|
|
|
158
170
|
s += ` L ${(r * i).toFixed(1)} ${(e - n * e).toFixed(1)}`;
|
|
159
171
|
}), s += ` L ${t} ${e} Z`, s;
|
|
160
172
|
}
|
|
161
|
-
async function
|
|
173
|
+
async function st(a, t) {
|
|
162
174
|
if (a.src)
|
|
163
175
|
return {
|
|
164
176
|
roll: a.roll,
|
|
@@ -168,9 +180,9 @@ async function it(a, t) {
|
|
|
168
180
|
tracking: {}
|
|
169
181
|
};
|
|
170
182
|
if (!a.vastTag) throw new Error('Ad roll has neither "vastTag" nor "src"');
|
|
171
|
-
return
|
|
183
|
+
return U(a, a.vastTag, t, 0, { impressions: [], tracking: {} });
|
|
172
184
|
}
|
|
173
|
-
async function
|
|
185
|
+
async function U(a, t, e, i, s) {
|
|
174
186
|
if (i > e.maxWrapperDepth) throw new Error("VAST wrapper depth limit exceeded");
|
|
175
187
|
const n = new AbortController(), r = setTimeout(() => n.abort(), e.requestTimeout);
|
|
176
188
|
let l;
|
|
@@ -185,35 +197,35 @@ async function z(a, t, e, i, s) {
|
|
|
185
197
|
if (h.querySelector("parsererror")) throw new Error("VAST response is not valid XML");
|
|
186
198
|
const c = h.querySelector("VAST > Ad");
|
|
187
199
|
if (!c) throw new Error("VAST response contains no ads");
|
|
188
|
-
|
|
200
|
+
nt(c, s);
|
|
189
201
|
const u = c.querySelector(":scope > Wrapper");
|
|
190
202
|
if (u) {
|
|
191
203
|
const y = S(u.querySelector("VASTAdTagURI"));
|
|
192
204
|
if (!y) throw new Error("VAST wrapper without VASTAdTagURI");
|
|
193
|
-
return
|
|
194
|
-
}
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
197
|
-
const
|
|
198
|
-
if (!
|
|
199
|
-
const
|
|
200
|
-
if (!
|
|
205
|
+
return U(a, y, e, i + 1, s);
|
|
206
|
+
}
|
|
207
|
+
const p = c.querySelector(":scope > InLine");
|
|
208
|
+
if (!p) throw new Error("VAST ad has neither InLine nor Wrapper");
|
|
209
|
+
const f = p.querySelector("Creatives > Creative > Linear");
|
|
210
|
+
if (!f) throw new Error("VAST ad has no Linear creative");
|
|
211
|
+
const m = rt(f);
|
|
212
|
+
if (!m) throw new Error("VAST ad has no playable MediaFile");
|
|
201
213
|
return {
|
|
202
214
|
roll: a.roll,
|
|
203
|
-
mediaUrl:
|
|
204
|
-
mediaType:
|
|
205
|
-
clickThrough: S(
|
|
206
|
-
duration: N(S(
|
|
207
|
-
skipOffset:
|
|
208
|
-
|
|
209
|
-
N(S(
|
|
215
|
+
mediaUrl: m.url,
|
|
216
|
+
mediaType: m.type,
|
|
217
|
+
clickThrough: S(f.querySelector("VideoClicks > ClickThrough")) ?? a.clickUrl,
|
|
218
|
+
duration: N(S(f.querySelector(":scope > Duration"))),
|
|
219
|
+
skipOffset: ot(
|
|
220
|
+
f.getAttribute("skipoffset"),
|
|
221
|
+
N(S(f.querySelector(":scope > Duration")))
|
|
210
222
|
),
|
|
211
223
|
impressions: s.impressions,
|
|
212
224
|
tracking: s.tracking,
|
|
213
|
-
adTitle: S(
|
|
225
|
+
adTitle: S(p.querySelector(":scope > AdTitle")) ?? void 0
|
|
214
226
|
};
|
|
215
227
|
}
|
|
216
|
-
function
|
|
228
|
+
function nt(a, t) {
|
|
217
229
|
var e, i;
|
|
218
230
|
for (const s of a.querySelectorAll("Impression")) {
|
|
219
231
|
const n = S(s);
|
|
@@ -228,7 +240,7 @@ function st(a, t) {
|
|
|
228
240
|
n && ((i = t.tracking).click ?? (i.click = [])).push(n);
|
|
229
241
|
}
|
|
230
242
|
}
|
|
231
|
-
function
|
|
243
|
+
function rt(a) {
|
|
232
244
|
const e = [...a.querySelectorAll("MediaFiles > MediaFile")].map((r) => ({
|
|
233
245
|
url: S(r) ?? "",
|
|
234
246
|
type: r.getAttribute("type") ?? void 0,
|
|
@@ -249,7 +261,7 @@ function N(a) {
|
|
|
249
261
|
if (t)
|
|
250
262
|
return (t[1] ? Number(t[1]) * 3600 : 0) + Number(t[2]) * 60 + Number(t[3]) + (t[4] ? Number(t[4].padEnd(3, "0")) / 1e3 : 0);
|
|
251
263
|
}
|
|
252
|
-
function
|
|
264
|
+
function ot(a, t) {
|
|
253
265
|
if (!a) return;
|
|
254
266
|
const e = a.trim().match(/^(\d+(?:\.\d+)?)%$/);
|
|
255
267
|
return e ? t !== void 0 ? Number(e[1]) / 100 * t : void 0 : N(a);
|
|
@@ -265,7 +277,7 @@ function M(a) {
|
|
|
265
277
|
function S(a) {
|
|
266
278
|
return a?.textContent?.trim().replace(/^<!\[CDATA\[|\]\]>$/g, "").trim() || null;
|
|
267
279
|
}
|
|
268
|
-
class
|
|
280
|
+
class lt {
|
|
269
281
|
constructor(t, e) {
|
|
270
282
|
this.host = t, this.playedRolls = /* @__PURE__ */ new Set(), this.sourcesSeen = 0, this.activeBreak = null, this.layer = null, this.adVideo = null, this.destroyed = !1, this.opts = {
|
|
271
283
|
skipDelay: 5,
|
|
@@ -332,7 +344,7 @@ class ot {
|
|
|
332
344
|
for (const n of t) {
|
|
333
345
|
this.playedRolls.add(n);
|
|
334
346
|
try {
|
|
335
|
-
const r = await
|
|
347
|
+
const r = await st(n, this.opts);
|
|
336
348
|
await this.playAd(r);
|
|
337
349
|
} catch (r) {
|
|
338
350
|
const l = r instanceof Error ? r : new Error(String(r));
|
|
@@ -353,18 +365,18 @@ class ot {
|
|
|
353
365
|
n.src = t.mediaUrl, n.muted = this.host.contentVideo.muted, n.volume = this.host.contentVideo.volume;
|
|
354
366
|
const h = o("div", "imp-spinner imp-ad__spinner"), c = o("div", "imp-ad__hud"), u = o("span", "imp-ad__badge");
|
|
355
367
|
u.textContent = t.adTitle ? `${i.adLabel} · ${t.adTitle}` : i.adLabel;
|
|
356
|
-
const
|
|
357
|
-
c.append(u,
|
|
358
|
-
const
|
|
359
|
-
let
|
|
360
|
-
t.clickThrough && (
|
|
368
|
+
const p = o("span", "imp-ad__countdown");
|
|
369
|
+
c.append(u, p);
|
|
370
|
+
const f = o("div", "imp-ad__actions");
|
|
371
|
+
let m = null;
|
|
372
|
+
t.clickThrough && (m = o("button", "imp-ad__visit", { type: "button" }), m.textContent = i.visitAdvertiser, f.append(m));
|
|
361
373
|
const y = o("button", "imp-ad__skip", { type: "button" });
|
|
362
|
-
y.hidden = !0,
|
|
374
|
+
y.hidden = !0, f.append(y), s.append(n, h, c, f), this.host.container.append(s), this.layer = s;
|
|
363
375
|
const T = t.skipOffset ?? this.opts.skipDelay, d = /* @__PURE__ */ new Set(), b = (k) => {
|
|
364
376
|
d.has(k) || (d.add(k), M(t.tracking[k]));
|
|
365
377
|
};
|
|
366
378
|
let A = Date.now(), F = -1;
|
|
367
|
-
const
|
|
379
|
+
const K = setInterval(() => {
|
|
368
380
|
if (n.paused) {
|
|
369
381
|
A = Date.now();
|
|
370
382
|
return;
|
|
@@ -378,7 +390,7 @@ class ot {
|
|
|
378
390
|
error: new Error(`Ad media stalled for ${this.opts.mediaTimeout} ms — skipping`)
|
|
379
391
|
}), R());
|
|
380
392
|
}, 500), R = () => {
|
|
381
|
-
clearInterval(
|
|
393
|
+
clearInterval(K), r.abort(), n.pause(), n.removeAttribute("src"), n.load(), s.remove(), this.layer = null, e();
|
|
382
394
|
}, H = (k) => {
|
|
383
395
|
k ? (b("skip"), this.host.emitter.emit("adskip", { ad: t })) : b("complete"), this.host.emitter.emit("adend", { ad: t }), R();
|
|
384
396
|
};
|
|
@@ -390,7 +402,7 @@ class ot {
|
|
|
390
402
|
h.hidden = !1;
|
|
391
403
|
}, { signal: l }), n.addEventListener("timeupdate", () => {
|
|
392
404
|
const k = n.currentTime, L = n.duration;
|
|
393
|
-
if (Number.isFinite(L) && L > 0 && (
|
|
405
|
+
if (Number.isFinite(L) && L > 0 && (p.textContent = x(Math.max(0, L - k)), k / L >= 0.25 && b("firstQuartile"), k / L >= 0.5 && b("midpoint"), k / L >= 0.75 && b("thirdQuartile")), T >= 0) {
|
|
394
406
|
const D = Math.ceil(T - k);
|
|
395
407
|
D > 0 ? (y.hidden = !1, y.disabled = !0, y.textContent = `${i.skipAdIn} ${D}`) : (y.hidden = !1, y.disabled = !1, y.textContent = i.skipAd);
|
|
396
408
|
}
|
|
@@ -403,14 +415,14 @@ class ot {
|
|
|
403
415
|
const O = () => {
|
|
404
416
|
t.clickThrough && (b("click"), this.host.emitter.emit("adclick", { ad: t }), window.open(t.clickThrough, "_blank", "noopener"), n.pause());
|
|
405
417
|
};
|
|
406
|
-
n.addEventListener("click", O, { signal: l }),
|
|
407
|
-
let Z = !1,
|
|
418
|
+
n.addEventListener("click", O, { signal: l }), m?.addEventListener("click", O);
|
|
419
|
+
let Z = !1, E = !1;
|
|
408
420
|
n.addEventListener("playing", () => {
|
|
409
421
|
Z = !0;
|
|
410
422
|
}, { once: !0, signal: l }), n.addEventListener("pause", () => {
|
|
411
|
-
n.ended || !s.isConnected || (s.classList.add("imp-ad--paused"), Z && !
|
|
423
|
+
n.ended || !s.isConnected || (s.classList.add("imp-ad--paused"), Z && !E && (E = !0, M(t.tracking.pause), this.host.emitter.emit("adpause", { ad: t })));
|
|
412
424
|
}, { signal: l }), n.addEventListener("play", () => {
|
|
413
|
-
s.classList.remove("imp-ad--paused"),
|
|
425
|
+
s.classList.remove("imp-ad--paused"), E && (E = !1, M(t.tracking.resume), this.host.emitter.emit("adresume", { ad: t }));
|
|
414
426
|
}, { signal: l }), s.addEventListener("click", (k) => {
|
|
415
427
|
(k.target === s || s.classList.contains("imp-ad--paused")) && n.paused && n.play().catch(() => {
|
|
416
428
|
});
|
|
@@ -437,22 +449,22 @@ function W(a, t) {
|
|
|
437
449
|
}
|
|
438
450
|
return i;
|
|
439
451
|
}
|
|
440
|
-
async function
|
|
452
|
+
async function at(a) {
|
|
441
453
|
const t = await fetch(a);
|
|
442
454
|
if (!t.ok) throw new Error(`Failed to load chapters VTT (${t.status})`);
|
|
443
455
|
const e = await t.text();
|
|
444
|
-
return
|
|
456
|
+
return z(e).map((i) => ({ start: i.start, end: i.end, title: i.text }));
|
|
445
457
|
}
|
|
446
|
-
function
|
|
458
|
+
function j(a, t) {
|
|
447
459
|
for (const e of a)
|
|
448
460
|
if (t >= e.start && t < e.end) return e;
|
|
449
461
|
return null;
|
|
450
462
|
}
|
|
451
|
-
function
|
|
463
|
+
function ht(a, t) {
|
|
452
464
|
return t ? /application\/(x-mpegurl|vnd\.apple\.mpegurl)/i.test(t) : /\.m3u8(\?|#|$)/i.test(a);
|
|
453
465
|
}
|
|
454
466
|
let _;
|
|
455
|
-
async function
|
|
467
|
+
async function ct() {
|
|
456
468
|
if (_ !== void 0) return _;
|
|
457
469
|
const a = globalThis.Hls;
|
|
458
470
|
if (a)
|
|
@@ -464,10 +476,10 @@ async function ht() {
|
|
|
464
476
|
}
|
|
465
477
|
return _;
|
|
466
478
|
}
|
|
467
|
-
async function
|
|
468
|
-
if (
|
|
469
|
-
const s = a.canPlayType("application/vnd.apple.mpegurl"), n = s ? null : await
|
|
470
|
-
return n && n.isSupported() ?
|
|
479
|
+
async function dt(a, t, e, i) {
|
|
480
|
+
if (ht(t, e)) {
|
|
481
|
+
const s = a.canPlayType("application/vnd.apple.mpegurl"), n = s ? null : await ct();
|
|
482
|
+
return n && n.isSupported() ? ut(n, a, t, i) : s ? (a.src = t, $(a)) : (i.onError("HLS is not supported in this browser and hls.js could not be loaded."), $(a));
|
|
471
483
|
}
|
|
472
484
|
return a.src = t, $(a);
|
|
473
485
|
}
|
|
@@ -483,7 +495,7 @@ function $(a) {
|
|
|
483
495
|
}
|
|
484
496
|
};
|
|
485
497
|
}
|
|
486
|
-
function
|
|
498
|
+
function ut(a, t, e, i) {
|
|
487
499
|
const s = new a({ enableWorker: !0 }), n = {
|
|
488
500
|
kind: "hls",
|
|
489
501
|
levels: [],
|
|
@@ -536,13 +548,13 @@ class q {
|
|
|
536
548
|
const e = await fetch(t);
|
|
537
549
|
if (!e.ok) throw new Error(`Failed to load thumbnails VTT (${e.status})`);
|
|
538
550
|
const i = await e.text(), s = [];
|
|
539
|
-
for (const n of
|
|
551
|
+
for (const n of z(i)) {
|
|
540
552
|
const [r, l] = n.text.trim().split("#");
|
|
541
553
|
if (!r) continue;
|
|
542
554
|
const h = {
|
|
543
555
|
start: n.start,
|
|
544
556
|
end: n.end,
|
|
545
|
-
src:
|
|
557
|
+
src: X(r, t)
|
|
546
558
|
}, c = l?.match(/xywh=(\d+),(\d+),(\d+),(\d+)/);
|
|
547
559
|
c && (h.xywh = { x: Number(c[1]), y: Number(c[2]), w: Number(c[3]), h: Number(c[4]) }), s.push(h);
|
|
548
560
|
}
|
|
@@ -559,7 +571,7 @@ class q {
|
|
|
559
571
|
return null;
|
|
560
572
|
}
|
|
561
573
|
}
|
|
562
|
-
const
|
|
574
|
+
const pt = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"/></svg>', mt = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg>';
|
|
563
575
|
class B {
|
|
564
576
|
constructor(t) {
|
|
565
577
|
this.anchor = t, this.outsideListener = null, this.root = o("div", "imp-menu"), this.root.hidden = !0, this.backdrop = o("div", "imp-menu__backdrop"), this.backdrop.hidden = !0, this.backdrop.addEventListener("pointerdown", (e) => {
|
|
@@ -598,7 +610,7 @@ class B {
|
|
|
598
610
|
const r = o("span", "imp-menu__value");
|
|
599
611
|
r.textContent = i.value ?? "";
|
|
600
612
|
const l = o("span", "imp-menu__chevron");
|
|
601
|
-
l.innerHTML =
|
|
613
|
+
l.innerHTML = pt, s.append(n, r, l), s.addEventListener("click", () => this.renderSettingsDetail(t, i)), e.append(s);
|
|
602
614
|
}
|
|
603
615
|
this.root.append(e);
|
|
604
616
|
}
|
|
@@ -620,7 +632,7 @@ class B {
|
|
|
620
632
|
if (!e.section) return;
|
|
621
633
|
this.root.textContent = "";
|
|
622
634
|
const i = o("button", "imp-menu__item imp-menu__back", { type: "button" }), s = o("span", "imp-menu__chevron");
|
|
623
|
-
s.innerHTML =
|
|
635
|
+
s.innerHTML = mt;
|
|
624
636
|
const n = o("span", "imp-menu__label");
|
|
625
637
|
n.textContent = e.label, i.append(s, n), i.addEventListener("click", () => this.renderSettingsRoot(t)), this.root.append(i), this.root.append(this.renderSection(e.section())), this.root.scrollTop = 0;
|
|
626
638
|
}
|
|
@@ -660,7 +672,7 @@ class B {
|
|
|
660
672
|
this.close(), this.root.remove();
|
|
661
673
|
}
|
|
662
674
|
}
|
|
663
|
-
class
|
|
675
|
+
class vt {
|
|
664
676
|
constructor(t) {
|
|
665
677
|
this.cb = t, this.segments = [], this.duration = 0, this.chapters = [], this.thumbnails = null, this.scrubbing = !1, this.root = o("div", "imp-progress", { role: "slider", "aria-label": "Seek", tabindex: "-1" }), this.buffered = o("div", "imp-progress__buffered"), this.track = o("div", "imp-progress__track"), this.handle = o("div", "imp-progress__handle"), this.tooltipThumb = o("div", "imp-progress__thumb"), this.tooltipChapter = o("div", "imp-progress__tooltip-chapter"), this.tooltipTime = o("div", "imp-progress__tooltip-time"), this.tooltip = o("div", "imp-progress__tooltip"), this.tooltip.append(this.tooltipThumb, this.tooltipChapter, this.tooltipTime), this.heatmap = o("div", "imp-progress__heatmap"), this.heatmap.hidden = !0, this.root.append(this.heatmap, this.buffered, this.track, this.handle, this.tooltip), this.setChapters([]), this.bindPointer();
|
|
666
678
|
}
|
|
@@ -670,7 +682,7 @@ class mt {
|
|
|
670
682
|
this.heatmap.hidden = !0, this.heatmap.textContent = "";
|
|
671
683
|
return;
|
|
672
684
|
}
|
|
673
|
-
this.heatmap.innerHTML = `<svg viewBox="0 0 1000 100" preserveAspectRatio="none" aria-hidden="true"><path d="${
|
|
685
|
+
this.heatmap.innerHTML = `<svg viewBox="0 0 1000 100" preserveAspectRatio="none" aria-hidden="true"><path d="${it(t)}"/></svg>`, this.heatmap.hidden = !1;
|
|
674
686
|
}
|
|
675
687
|
setDuration(t) {
|
|
676
688
|
this.duration = Number.isFinite(t) ? t : 0, this.root.classList.toggle("imp-progress--live", !Number.isFinite(t)), this.chapters.length === 0 && this.setChapters([]);
|
|
@@ -724,7 +736,7 @@ class mt {
|
|
|
724
736
|
showTooltip(t) {
|
|
725
737
|
const e = this.timeFromEvent(t);
|
|
726
738
|
this.tooltipTime.textContent = x(e);
|
|
727
|
-
const i =
|
|
739
|
+
const i = j(this.chapters, e);
|
|
728
740
|
this.tooltipChapter.textContent = i?.title ?? "", this.tooltipChapter.hidden = !i?.title;
|
|
729
741
|
const s = this.thumbnails?.cueAt(e) ?? null;
|
|
730
742
|
s ? (this.tooltipThumb.hidden = !1, this.tooltipThumb.style.backgroundImage = `url("${s.src}")`, s.xywh ? (this.tooltipThumb.style.width = `${s.xywh.w}px`, this.tooltipThumb.style.height = `${s.xywh.h}px`, this.tooltipThumb.style.backgroundPosition = `-${s.xywh.x}px -${s.xywh.y}px`, this.tooltipThumb.style.backgroundSize = "auto") : (this.tooltipThumb.style.width = "160px", this.tooltipThumb.style.height = "90px", this.tooltipThumb.style.backgroundPosition = "center", this.tooltipThumb.style.backgroundSize = "cover")) : this.tooltipThumb.hidden = !0, this.tooltip.classList.add("imp-progress__tooltip--visible");
|
|
@@ -735,11 +747,11 @@ class mt {
|
|
|
735
747
|
this.tooltip.classList.remove("imp-progress__tooltip--visible");
|
|
736
748
|
}
|
|
737
749
|
}
|
|
738
|
-
class
|
|
750
|
+
class ft {
|
|
739
751
|
constructor(t) {
|
|
740
752
|
this.player = t, this.rightItems = /* @__PURE__ */ new Map(), this.subtitlesBtn = null, this.settingsBtn = null, this.settingsMenu = null, this.subtitlesMenu = null, this.moreMenu = null, this.moreWrap = null, this.qualityBtn = null, this.qualityMenu = null, this.gearBtn = null, this.gearMenu = null, this.gear = { speed: !1, quality: !1, subtitles: !1 }, this.nextPreviewEl = null, this.nextPreviewOpts = null, this.scenesBtn = null, this.sceneTypeBtn = null, this.sceneTypeMenu = null, this.likeBtn = null, this.dislikeBtn = null, this.likeCountEl = null, this.dislikeCountEl = null, this.prevBtn = null, this.nextBtn = null, this.seekBackBtn = null, this.seekFwdBtn = null, this.centerPlayBtn = null, this.centerPrevBtn = null, this.centerNextBtn = null, this.collapsibles = [], this.overflowed = /* @__PURE__ */ new Set(), this.resizeObserver = null, this.reflowScheduled = !1, this.actionItems = [], this.wasPlayingBeforeScrub = !1, this.disposers = [], this.onWindowResize = null;
|
|
741
753
|
const { labels: e, icons: i } = t, s = t.controlsOptions;
|
|
742
|
-
this.root = o("div", "imp-controls"), this.progress = new
|
|
754
|
+
this.root = o("div", "imp-controls"), this.progress = new vt({
|
|
743
755
|
onSeek: (d) => t.seek(d),
|
|
744
756
|
onScrubStart: () => {
|
|
745
757
|
this.wasPlayingBeforeScrub = !t.paused, t.pause();
|
|
@@ -754,8 +766,8 @@ class vt {
|
|
|
754
766
|
this.rightGroup = l;
|
|
755
767
|
const h = o("div", "imp-controls__spacer");
|
|
756
768
|
this.chapterLabel = o("div", "imp-controls__chapter"), n.append(r, h, l), h.append(this.chapterLabel);
|
|
757
|
-
const c = typeof s.seekButtons == "object" ? s.seekButtons : {}, u = c.back ?? t.seekStep,
|
|
758
|
-
if (this.seekLabelFn = c.label, s.playlist && t.hasPlaylist && !s.hidePrev && (this.prevBtn = g("imp-btn--prev", e.previous, i.previous), this.prevBtn.addEventListener("click", () => t.previous()), r.append(this.prevBtn)), s.seekButtons && (this.seekBackBtn = g("imp-btn--seek-back", `${e.seekBack} ${u}s`, i.seekBack), this.addStepBadge(this.seekBackBtn, u, "back"), this.seekBackBtn.addEventListener("click", () => t.skip(-u)), r.append(this.seekBackBtn)), s.play && (this.playBtn = g("imp-btn--play", e.play, i.play), this.playBtn.addEventListener("click", () => t.togglePlay()), r.append(this.playBtn)), s.seekButtons && (this.seekFwdBtn = g("imp-btn--seek-forward", `${e.seekForward} ${
|
|
769
|
+
const c = typeof s.seekButtons == "object" ? s.seekButtons : {}, u = c.back ?? t.seekStep, p = c.forward ?? t.seekStep;
|
|
770
|
+
if (this.seekLabelFn = c.label, s.playlist && t.hasPlaylist && !s.hidePrev && (this.prevBtn = g("imp-btn--prev", e.previous, i.previous), this.prevBtn.addEventListener("click", () => t.previous()), r.append(this.prevBtn)), s.seekButtons && (this.seekBackBtn = g("imp-btn--seek-back", `${e.seekBack} ${u}s`, i.seekBack), this.addStepBadge(this.seekBackBtn, u, "back"), this.seekBackBtn.addEventListener("click", () => t.skip(-u)), r.append(this.seekBackBtn)), s.play && (this.playBtn = g("imp-btn--play", e.play, i.play), this.playBtn.addEventListener("click", () => t.togglePlay()), r.append(this.playBtn)), s.seekButtons && (this.seekFwdBtn = g("imp-btn--seek-forward", `${e.seekForward} ${p}s`, i.seekForward), this.addStepBadge(this.seekFwdBtn, p, "forward"), this.seekFwdBtn.addEventListener("click", () => t.skip(p)), r.append(this.seekFwdBtn)), s.playlist && t.hasPlaylist && (this.nextBtn = g("imp-btn--next", e.next, i.next), this.nextBtn.addEventListener("click", () => t.next()), r.append(this.nextBtn)), s.volume) {
|
|
759
771
|
const d = o("div", "imp-volume");
|
|
760
772
|
this.muteBtn = g("imp-btn--mute", e.mute, i.volumeHigh), this.muteBtn.addEventListener("click", () => t.toggleMute()), this.volumeSlider = o("input", "imp-volume__slider", {
|
|
761
773
|
type: "range",
|
|
@@ -778,8 +790,8 @@ class vt {
|
|
|
778
790
|
section: () => this.simpleSection(`custom:${d.id}`, d.title, d.icon ?? i.more, () => t.emit("customaction", { id: d.id }))
|
|
779
791
|
});
|
|
780
792
|
}
|
|
781
|
-
const
|
|
782
|
-
if (this.gear = { speed: T === "gear", quality: y === "gear", subtitles:
|
|
793
|
+
const f = (d) => d === !1 ? "off" : d === "bar" ? "bar" : "gear", m = f(s.subtitles), y = f(s.quality), T = f(s.speed);
|
|
794
|
+
if (this.gear = { speed: T === "gear", quality: y === "gear", subtitles: m === "gear" }, m === "bar") {
|
|
783
795
|
this.subtitlesBtn = g("imp-btn--subtitles", e.subtitles, i.subtitles), this.subtitlesMenu = new B(this.subtitlesBtn);
|
|
784
796
|
const d = o("div", "imp-controls__menu-anchor");
|
|
785
797
|
d.append(this.subtitlesBtn, this.subtitlesMenu.root), this.subtitlesBtn.addEventListener("click", () => this.toggleSubtitlesMenu()), this.rightItems.set("subtitles", d), this.registerCollapsible({
|
|
@@ -878,7 +890,7 @@ class vt {
|
|
|
878
890
|
el: d,
|
|
879
891
|
priority: 82,
|
|
880
892
|
available: () => Number.isFinite(t.duration) && t.duration > 0,
|
|
881
|
-
section: () => this.simpleSection("seekFwd", `${e.seekForward} ${
|
|
893
|
+
section: () => this.simpleSection("seekFwd", `${e.seekForward} ${p}s`, i.seekForward, () => t.skip(p))
|
|
882
894
|
});
|
|
883
895
|
}
|
|
884
896
|
if (this.center = o("div", "imp-center-controls"), s.playlist && t.hasPlaylist && (this.centerPrevBtn = this.makeCenterButton("prev", e.previous, i.previous), this.centerPrevBtn.addEventListener("click", () => t.previous()), this.center.append(this.centerPrevBtn)), s.seekButtons) {
|
|
@@ -886,8 +898,8 @@ class vt {
|
|
|
886
898
|
this.addStepBadge(d, u, "back"), d.addEventListener("click", () => t.skip(-u)), this.center.append(d);
|
|
887
899
|
}
|
|
888
900
|
if (s.play && (this.centerPlayBtn = this.makeCenterButton("play", e.play, i.play), this.centerPlayBtn.addEventListener("click", () => t.togglePlay()), this.center.append(this.centerPlayBtn)), s.seekButtons) {
|
|
889
|
-
const d = this.makeCenterButton("seek-forward", `${e.seekForward} ${
|
|
890
|
-
this.addStepBadge(d,
|
|
901
|
+
const d = this.makeCenterButton("seek-forward", `${e.seekForward} ${p}s`, i.seekForward);
|
|
902
|
+
this.addStepBadge(d, p, "forward"), d.addEventListener("click", () => t.skip(p)), this.center.append(d);
|
|
891
903
|
}
|
|
892
904
|
if (s.playlist && t.hasPlaylist && (this.centerNextBtn = this.makeCenterButton("next", e.next, i.next), this.centerNextBtn.addEventListener("click", () => t.next()), this.center.append(this.centerNextBtn)), this.center.style.display = "none", this.setupNextPreview(), this.gear.speed || this.gear.quality || this.gear.subtitles) {
|
|
893
905
|
this.gearBtn = g("imp-btn--settings", e.settings, i.settings), this.gearMenu = new B(this.gearBtn);
|
|
@@ -1024,24 +1036,20 @@ class vt {
|
|
|
1024
1036
|
e.textContent = "";
|
|
1025
1037
|
const n = o("div", "imp-next-preview__kicker");
|
|
1026
1038
|
if (n.textContent = this.player.labels.next, e.append(n), i.thumbnail && s.poster) {
|
|
1027
|
-
const
|
|
1028
|
-
if (
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1039
|
+
const f = o("div", "imp-next-preview__thumb");
|
|
1040
|
+
if (f.style.backgroundImage = `url("${s.poster}")`, i.duration && s.duration) {
|
|
1041
|
+
const m = o("span", "imp-next-preview__duration");
|
|
1042
|
+
m.textContent = x(s.duration), f.append(m);
|
|
1031
1043
|
}
|
|
1032
|
-
e.append(
|
|
1044
|
+
e.append(f);
|
|
1033
1045
|
}
|
|
1034
1046
|
if (i.title && s.title) {
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1047
|
+
const f = o("div", "imp-next-preview__title");
|
|
1048
|
+
f.textContent = s.title, e.append(f);
|
|
1037
1049
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
e.hidden = !1;
|
|
1043
|
-
const r = this.player.container.getBoundingClientRect(), l = t.getBoundingClientRect(), h = 8, c = e.offsetWidth, u = l.left - r.left + l.width / 2 - c / 2, m = Math.max(h, Math.min(u, r.width - c - h));
|
|
1044
|
-
e.style.left = `${m}px`, e.style.bottom = `${r.height - (l.top - r.top) + 10}px`;
|
|
1050
|
+
i.meta && s.previewMeta?.length && e.append(Q(s.previewMeta, "imp-next-preview")), e.hidden = !1;
|
|
1051
|
+
const r = this.player.container.getBoundingClientRect(), l = t.getBoundingClientRect(), h = 8, c = e.offsetWidth, u = l.left - r.left + l.width / 2 - c / 2, p = Math.max(h, Math.min(u, r.width - c - h));
|
|
1052
|
+
e.style.left = `${p}px`, e.style.bottom = `${r.height - (l.top - r.top) + 10}px`;
|
|
1045
1053
|
}
|
|
1046
1054
|
hideNextPreview() {
|
|
1047
1055
|
this.nextPreviewEl && (this.nextPreviewEl.hidden = !0);
|
|
@@ -1219,7 +1227,7 @@ class vt {
|
|
|
1219
1227
|
this.chapterLabel.textContent = e?.title ?? "";
|
|
1220
1228
|
}),
|
|
1221
1229
|
t.on("fullscreenchange", ({ active: e }) => {
|
|
1222
|
-
this.fullscreenBtn &&
|
|
1230
|
+
this.fullscreenBtn && C(this.fullscreenBtn, e ? t.icons.fullscreenExit : t.icons.fullscreen, e ? t.labels.exitFullscreen : t.labels.fullscreen), this.scheduleReflow();
|
|
1223
1231
|
}),
|
|
1224
1232
|
t.on("playlistitemchange", () => {
|
|
1225
1233
|
this.syncPlaylistButtons(), this.scheduleReflow();
|
|
@@ -1231,12 +1239,12 @@ class vt {
|
|
|
1231
1239
|
}
|
|
1232
1240
|
syncPlayState() {
|
|
1233
1241
|
const t = this.player, [e, i] = t.ended ? [t.icons.replay, t.labels.replay] : t.paused ? [t.icons.play, t.labels.play] : [t.icons.pause, t.labels.pause];
|
|
1234
|
-
this.playBtn &&
|
|
1242
|
+
this.playBtn && C(this.playBtn, e, i), this.centerPlayBtn && C(this.centerPlayBtn, e, i);
|
|
1235
1243
|
}
|
|
1236
1244
|
syncVolume() {
|
|
1237
1245
|
if (!this.muteBtn) return;
|
|
1238
1246
|
const t = this.player, e = t.muted ? 0 : t.volume, i = e === 0 ? t.icons.volumeMute : e < 0.5 ? t.icons.volumeLow : t.icons.volumeHigh;
|
|
1239
|
-
|
|
1247
|
+
C(this.muteBtn, i, t.muted ? t.labels.unmute : t.labels.mute), this.volumeSlider.value = String(e), this.volumeSlider.style.setProperty("--imp-volume-fill", `${e * 100}%`);
|
|
1240
1248
|
}
|
|
1241
1249
|
/** Called by the player when per-source data (chapters/quality/subtitles) changes. */
|
|
1242
1250
|
syncFeatureButtons() {
|
|
@@ -1264,7 +1272,7 @@ class vt {
|
|
|
1264
1272
|
this.disposers = [], this.resizeObserver?.disconnect(), this.onWindowResize && window.removeEventListener("resize", this.onWindowResize), this.gearMenu?.destroy(), this.sceneTypeMenu?.destroy(), this.settingsMenu?.destroy(), this.subtitlesMenu?.destroy(), this.qualityMenu?.destroy(), this.moreMenu?.destroy(), this.nextPreviewEl?.remove(), this.root.remove();
|
|
1265
1273
|
}
|
|
1266
1274
|
}
|
|
1267
|
-
class
|
|
1275
|
+
class gt {
|
|
1268
1276
|
constructor(t) {
|
|
1269
1277
|
this.root = o("div", "imp-poster"), this.image = o("img", "imp-poster__image", { alt: "", decoding: "async" }), this.image.hidden = !0;
|
|
1270
1278
|
const e = g("imp-poster__play", t.labels.play, t.icons.bigPlay);
|
|
@@ -1282,7 +1290,7 @@ class ft {
|
|
|
1282
1290
|
this.root.hidden = !0;
|
|
1283
1291
|
}
|
|
1284
1292
|
}
|
|
1285
|
-
class
|
|
1293
|
+
class yt {
|
|
1286
1294
|
constructor(t) {
|
|
1287
1295
|
this.labels = t, this.channelUrl = null, this.custom = null, this.visible = { title: !0, description: !0, sponsor: !0 }, this.root = o("div", "imp-pause-screen"), this.root.hidden = !0, this.defaultContent = o("div", "imp-pause-screen__default"), this.channel = o("button", "imp-channel", { type: "button" }), this.channel.hidden = !0, this.channelAvatar = o("div", "imp-channel__avatar"), this.channelName = o("div", "imp-channel__name"), this.channel.append(this.channelName, this.channelAvatar), this.channel.addEventListener("click", () => {
|
|
1288
1296
|
this.channelUrl && window.open(this.channelUrl, "_blank", "noopener");
|
|
@@ -1319,7 +1327,7 @@ class gt {
|
|
|
1319
1327
|
this.root.hidden = !0;
|
|
1320
1328
|
}
|
|
1321
1329
|
}
|
|
1322
|
-
class
|
|
1330
|
+
class bt {
|
|
1323
1331
|
constructor(t) {
|
|
1324
1332
|
this.player = t, this.clickBehavior = "player", this.root = o("div", "imp-related"), this.root.hidden = !0, this.heading = o("div", "imp-related__title"), this.grid = o("div", "imp-related__grid");
|
|
1325
1333
|
const e = g("imp-related__close", "Close", t.icons.close);
|
|
@@ -1368,7 +1376,7 @@ class yt {
|
|
|
1368
1376
|
this.root.hidden = !0;
|
|
1369
1377
|
}
|
|
1370
1378
|
}
|
|
1371
|
-
class
|
|
1379
|
+
class kt {
|
|
1372
1380
|
constructor(t) {
|
|
1373
1381
|
this.player = t, this.root = o("div", "imp-upnext"), this.root.hidden = !0;
|
|
1374
1382
|
}
|
|
@@ -1394,12 +1402,7 @@ class bt {
|
|
|
1394
1402
|
const r = o("div", "imp-upnext__title");
|
|
1395
1403
|
r.textContent = t.title, i.append(r);
|
|
1396
1404
|
}
|
|
1397
|
-
|
|
1398
|
-
const r = o("div", "imp-upnext__meta"), l = o("span", "imp-upnext__meta-icon");
|
|
1399
|
-
l.innerHTML = t.metaIcon ?? (t.channel ? this.player.icons.channel : this.player.icons.user);
|
|
1400
|
-
const h = o("span", "imp-upnext__meta-text");
|
|
1401
|
-
h.textContent = t.previewMeta.join(" · "), r.append(l, h), i.append(r);
|
|
1402
|
-
}
|
|
1405
|
+
t.previewMeta?.length && i.append(Q(t.previewMeta, "imp-upnext"));
|
|
1403
1406
|
const n = o("button", "imp-upnext__btn", { type: "button" });
|
|
1404
1407
|
n.textContent = e.playNext, n.addEventListener("click", () => this.player.next()), i.append(n), this.root.append(i), this.root.hidden = !1;
|
|
1405
1408
|
}
|
|
@@ -1407,7 +1410,7 @@ class bt {
|
|
|
1407
1410
|
this.root.hidden = !0;
|
|
1408
1411
|
}
|
|
1409
1412
|
}
|
|
1410
|
-
class
|
|
1413
|
+
class wt {
|
|
1411
1414
|
constructor(t, e = "sidebar", i) {
|
|
1412
1415
|
this.player = t, this.root = o("div", `imp-playlist imp-playlist--${e}`), this.root.hidden = !0;
|
|
1413
1416
|
const s = o("div", "imp-playlist__header"), n = o("div", "imp-playlist__heading");
|
|
@@ -1459,7 +1462,7 @@ class kt {
|
|
|
1459
1462
|
this.visible ? this.hide() : this.show();
|
|
1460
1463
|
}
|
|
1461
1464
|
}
|
|
1462
|
-
class
|
|
1465
|
+
class xt {
|
|
1463
1466
|
constructor(t, e = "bottom") {
|
|
1464
1467
|
this.player = t, this.items = [], this.root = o("div", `imp-playlist imp-scenes imp-playlist--${e}`), this.root.hidden = !0;
|
|
1465
1468
|
const i = o("div", "imp-playlist__header"), s = o("span");
|
|
@@ -1508,7 +1511,7 @@ class wt {
|
|
|
1508
1511
|
function G(a) {
|
|
1509
1512
|
return a ? typeof a == "string" ? [{ src: a, label: "Subtitles" }] : Array.isArray(a) ? a : [a] : [];
|
|
1510
1513
|
}
|
|
1511
|
-
const
|
|
1514
|
+
const St = {
|
|
1512
1515
|
play: !0,
|
|
1513
1516
|
progress: !0,
|
|
1514
1517
|
time: !0,
|
|
@@ -1534,49 +1537,49 @@ const xt = {
|
|
|
1534
1537
|
nextPreview: !0,
|
|
1535
1538
|
hideDelay: 2500
|
|
1536
1539
|
};
|
|
1537
|
-
class
|
|
1540
|
+
class Et {
|
|
1538
1541
|
constructor(t, e = {}) {
|
|
1539
|
-
this.scrubbing = !1, this.emitter = new
|
|
1542
|
+
this.scrubbing = !1, this.emitter = new J(), this.abort = new AbortController(), this.sources = [], this.currentIndex = -1, this.sourceController = null, this.loadToken = 0, this.chapters = [], this.currentChapter = null, this.sceneGroupList = [], this.activeSceneGroupId = "", this.progressiveQuality = -1, this.thumbTrack = null, this.shuffleMode = !1, this.autoAdvanceEnabled = !0, this.persistKey = null, this.persistVolume = !1, this.persistAutoAdvance = !1, this.decodeRecoveries = 0, this.adManager = null, this.playedOnce = !1, this.idleTimer = null, this.destroyed = !1;
|
|
1540
1543
|
const i = typeof t == "string" ? document.querySelector(t) : t;
|
|
1541
1544
|
if (!i) throw new Error(`[itube-player] mount target not found: ${String(t)}`);
|
|
1542
|
-
this.mount = i, this.options = e, this.labels = { ...V, ...
|
|
1545
|
+
this.mount = i, this.options = e, this.labels = { ...V, ...tt(e.language), ...e.labels }, this.icons = { ...Y, ...e.icons };
|
|
1543
1546
|
const s = e.controls ?? {}, n = s.speed ?? s.settings ?? "gear";
|
|
1544
|
-
if (this.controlsOptions = { ...
|
|
1545
|
-
const
|
|
1546
|
-
this.persistKey =
|
|
1547
|
+
if (this.controlsOptions = { ...St, ...s, speed: n, settings: n }, this.actionsOptions = e.actions ?? {}, this.playbackRates = e.playbackRates ?? [0.5, 0.75, 1, 1.25, 1.5, 2], this.seekStep = e.seekStep ?? 15, this.playlistOptions = { title: "", autoAdvance: !0, loop: !1, shuffle: !1, startIndex: 0, layout: "sidebar", ...e.playlist }, this.shuffleMode = this.playlistOptions.shuffle, e.persist) {
|
|
1548
|
+
const m = e.persist === !0 ? {} : e.persist;
|
|
1549
|
+
this.persistKey = m.key ?? "itube-player", this.persistVolume = m.volume !== !1, this.persistAutoAdvance = m.autoAdvance !== !1;
|
|
1547
1550
|
}
|
|
1548
1551
|
const r = this.readPersisted();
|
|
1549
1552
|
this.autoAdvanceEnabled = this.persistAutoAdvance && typeof r?.autoAdvance == "boolean" ? r.autoAdvance : this.playlistOptions.autoAdvance, this.sources = e.source ? Array.isArray(e.source) ? [...e.source] : [e.source] : [], this.container = o("div", "imp-player", { tabindex: "0" }), e.className && this.container.classList.add(e.className);
|
|
1550
1553
|
const l = e.styling;
|
|
1551
1554
|
if (l?.themeColor && this.container.style.setProperty("--imp-accent", l.themeColor), l?.likeColor && this.container.style.setProperty("--imp-like", l.likeColor), l?.dislikeColor && this.container.style.setProperty("--imp-dislike", l.dislikeColor), l?.borderRadius !== void 0) {
|
|
1552
|
-
const
|
|
1553
|
-
this.container.style.setProperty("--imp-radius",
|
|
1555
|
+
const m = typeof l.borderRadius == "number" ? `${l.borderRadius}px` : l.borderRadius;
|
|
1556
|
+
this.container.style.setProperty("--imp-radius", m);
|
|
1554
1557
|
}
|
|
1555
1558
|
l?.playButtonStyle === "inverted" && this.container.classList.add("imp-player--play-inverted"), this.video = o("video", "imp-video"), e.playsInline !== !1 && this.video.setAttribute("playsinline", ""), e.crossOrigin !== void 0 && (this.video.crossOrigin = e.crossOrigin), this.video.preload = "metadata", e.loop && (this.video.loop = !0);
|
|
1556
1559
|
const h = this.persistVolume ? r : null;
|
|
1557
1560
|
this.video.volume = w(h?.volume ?? e.volume ?? 1, 0, 1), (h?.muted ?? e.muted) && (this.video.muted = !0);
|
|
1558
1561
|
const c = o("div", "imp-layer");
|
|
1559
|
-
this.spinner = o("div", "imp-spinner"), this.spinner.hidden = !0, this.errorBox = o("div", "imp-error"), this.errorBox.hidden = !0, this.pauseScreen = new
|
|
1562
|
+
this.spinner = o("div", "imp-spinner"), this.spinner.hidden = !0, this.errorBox = o("div", "imp-error"), this.errorBox.hidden = !0, this.pauseScreen = new yt(this.labels), this.poster = new gt(this), this.related = new bt(this), this.related.setOptions(e.related), this.upNext = new kt(this), this.controls = new ft(this), this.playlistPanel = new wt(this, this.playlistOptions.layout, this.playlistOptions.title || void 0), this.scenesPanel = new xt(this, e.scenes?.layout ?? "bottom");
|
|
1560
1563
|
const u = o("div", "imp-layer__middle");
|
|
1561
1564
|
u.append(this.spinner, this.errorBox, this.controls.center);
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
const
|
|
1565
|
-
|
|
1565
|
+
const p = o("div", "imp-layer__bottom");
|
|
1566
|
+
p.append(this.controls.root), c.append(this.pauseScreen.root, this.related.root, this.upNext.root, u, p), this.container.append(this.video, c, this.poster.root, this.playlistPanel.root, this.scenesPanel.root), this.mount.append(this.container), e.pauseScreen instanceof HTMLElement ? this.pauseScreen.setCustomContent(e.pauseScreen) : typeof e.pauseScreen == "function" ? this.pauseScreen.setCustomContent(e.pauseScreen(this)) : e.pauseScreen && typeof e.pauseScreen == "object" && this.pauseScreen.setVisibility(e.pauseScreen);
|
|
1567
|
+
const f = e.adConfig ?? e.ads;
|
|
1568
|
+
f && f.adList.length > 0 && (this.adManager = new lt(
|
|
1566
1569
|
{ container: this.container, contentVideo: this.video, emitter: this.emitter, labels: this.labels, closeIcon: this.icons.close },
|
|
1567
|
-
|
|
1568
|
-
)), this.emitter.on("error", ({ message:
|
|
1569
|
-
this.errorBox.textContent =
|
|
1570
|
-
}), this.bindVideoEvents(), this.bindIdleHide(), e.keyboard !== !1 && this.bindKeyboard(), this.video.addEventListener("pointerup", (
|
|
1570
|
+
f
|
|
1571
|
+
)), this.emitter.on("error", ({ message: m }) => {
|
|
1572
|
+
this.errorBox.textContent = m, this.errorBox.hidden = !1, this.spinner.hidden = !0, this.poster.hide();
|
|
1573
|
+
}), this.bindVideoEvents(), this.bindIdleHide(), e.keyboard !== !1 && this.bindKeyboard(), this.video.addEventListener("pointerup", (m) => {
|
|
1571
1574
|
if (!(this.adPlaying || !this.playedOnce)) {
|
|
1572
|
-
if (
|
|
1575
|
+
if (m.pointerType === "mouse") {
|
|
1573
1576
|
this.togglePlay();
|
|
1574
1577
|
return;
|
|
1575
1578
|
}
|
|
1576
1579
|
this.container.classList.contains("imp-player--idle") ? (this.showControlsNow(), this.scheduleIdle()) : this.video.paused || this.container.classList.add("imp-player--idle");
|
|
1577
1580
|
}
|
|
1578
|
-
}, { signal: this.abort.signal }), this.pauseScreen.root.addEventListener("click", (
|
|
1579
|
-
this.pauseScreen.hasCustom ||
|
|
1581
|
+
}, { signal: this.abort.signal }), this.pauseScreen.root.addEventListener("click", (m) => {
|
|
1582
|
+
this.pauseScreen.hasCustom || m.target === this.pauseScreen.root && this.togglePlay();
|
|
1580
1583
|
}, { signal: this.abort.signal }), this.sources.length > 0 && this.loadItem(w(this.playlistOptions.startIndex, 0, this.sources.length - 1), !!e.autoplay), this.emitter.emit("ready", { player: this });
|
|
1581
1584
|
}
|
|
1582
1585
|
// === events ===========================================================
|
|
@@ -1888,7 +1891,7 @@ class Tt {
|
|
|
1888
1891
|
this.progressiveQuality = h, n = s.qualities[h].src, r = s.qualities[h].type ?? r;
|
|
1889
1892
|
}
|
|
1890
1893
|
this.video.preload = this.adManager?.hasPendingPreRoll ? "auto" : "metadata";
|
|
1891
|
-
const l = await
|
|
1894
|
+
const l = await dt(this.video, n, r, {
|
|
1892
1895
|
onLevels: () => {
|
|
1893
1896
|
i === this.loadToken && this.controls.syncFeatureButtons();
|
|
1894
1897
|
},
|
|
@@ -1914,11 +1917,11 @@ class Tt {
|
|
|
1914
1917
|
};
|
|
1915
1918
|
Number.isFinite(this.video.duration) && this.video.duration > 0 ? u() : this.video.addEventListener("loadedmetadata", u, { once: !0, signal: this.abort.signal });
|
|
1916
1919
|
};
|
|
1917
|
-
typeof s.chapters == "string" ?
|
|
1920
|
+
typeof s.chapters == "string" ? at(s.chapters).then((c) => h(c)).catch((c) => this.emitter.emit("error", { message: "Failed to load chapters track", cause: c })) : h(s.chapters);
|
|
1918
1921
|
}
|
|
1919
1922
|
if (s.heatmap && s.heatmap.length > 0 && this.controlsOptions.heatmap) {
|
|
1920
1923
|
const h = s.heatmap, c = () => {
|
|
1921
|
-
i === this.loadToken && this.controls.progress.setHeatmap(
|
|
1924
|
+
i === this.loadToken && this.controls.progress.setHeatmap(et(h, this.video.duration));
|
|
1922
1925
|
};
|
|
1923
1926
|
Number.isFinite(this.video.duration) && this.video.duration > 0 ? c() : this.video.addEventListener("loadedmetadata", c, { once: !0, signal: this.abort.signal });
|
|
1924
1927
|
}
|
|
@@ -1936,7 +1939,7 @@ class Tt {
|
|
|
1936
1939
|
this.handleEnded();
|
|
1937
1940
|
}, { signal: t }), e.addEventListener("timeupdate", () => {
|
|
1938
1941
|
this.emitter.emit("timeupdate", { currentTime: e.currentTime, duration: e.duration || 0 }), this.adManager?.checkMidRolls(e.currentTime);
|
|
1939
|
-
const i =
|
|
1942
|
+
const i = j(this.chapters, e.currentTime);
|
|
1940
1943
|
i !== this.currentChapter && (this.currentChapter = i, this.emitter.emit("chapterchange", { chapter: i }));
|
|
1941
1944
|
}, { signal: t }), e.addEventListener("progress", () => {
|
|
1942
1945
|
this.emitter.emit("progress", { buffered: this.bufferedEnd });
|
|
@@ -2056,22 +2059,22 @@ class Tt {
|
|
|
2056
2059
|
}
|
|
2057
2060
|
}
|
|
2058
2061
|
export {
|
|
2059
|
-
|
|
2060
|
-
|
|
2062
|
+
J as Emitter,
|
|
2063
|
+
Et as Player,
|
|
2061
2064
|
q as ThumbnailTrack,
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
+
et as buildHeatmapValues,
|
|
2066
|
+
j as chapterAt,
|
|
2067
|
+
Y as defaultIcons,
|
|
2065
2068
|
V as defaultLabels,
|
|
2066
2069
|
x as formatTime,
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2070
|
+
tt as getLocale,
|
|
2071
|
+
it as heatmapPath,
|
|
2072
|
+
ht as isHlsSource,
|
|
2073
|
+
at as loadChaptersVtt,
|
|
2071
2074
|
W as normalizeChapters,
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2075
|
+
Lt as registerLocale,
|
|
2076
|
+
Bt as registerLocales,
|
|
2077
|
+
Tt as registeredLanguages,
|
|
2078
|
+
st as resolveVast
|
|
2076
2079
|
};
|
|
2077
2080
|
//# sourceMappingURL=core.js.map
|