@tidal-music/player-web-components 0.2.0 → 0.2.2
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/active-device-changed-DKzZonX1--oMxdziu.js +7 -0
- package/dist/active-device-mode-changed-Dj16yzUX-BbRjSd-6.js +7 -0
- package/dist/audio-context-store-Ccv6WKna-C-yxIXdl.js +36 -0
- package/dist/basePlayer-CxowZx76-CfK9Qp4M.js +380 -0
- package/dist/browserPlayer-CJUIZMXc-Cwz_EqKS.js +170 -0
- package/dist/generate-guid-DMif1b6n-WXvDGKGF.js +1716 -0
- package/dist/index.js +363 -10
- package/dist/load-D2Tka_Qx-BNIMgt7e.js +29305 -0
- package/dist/media-element-error-circuit-breaker-fMDQ6k4B-B9oZKZUK.js +22 -0
- package/dist/nativePlayer-Bk8Y048r-S6bg9D6D.js +232 -0
- package/dist/output-devices-kF_iC6GM-CnAUEjc9.js +156 -0
- package/dist/pushkin-BJAKy5lP-BDJR20nC.js +117 -0
- package/dist/pushkin-CVLqA7Zj-DJu6_unL.js +2 -0
- package/dist/shakaPlayer-BvtoIIdC-CizBy6it.js +1448 -0
- package/dist/src/helpers.d.ts +18 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/tidal-current-time.d.ts +9 -0
- package/dist/src/tidal-duration-time.d.ts +9 -0
- package/dist/src/tidal-play-trigger.d.ts +2 -0
- package/dist/src/tidal-progress-bar.d.ts +2 -0
- package/dist/src/tidal-video-view.d.ts +2 -0
- package/dist/state-B888KJag-C7pa4Xs7.js +210 -0
- package/package.json +15 -13
- package/dist/_commonjsHelpers-DaMA6jEr-DtILRGNx.js +0 -8
- package/dist/basePlayer-C5QIyqfj-Dxhlf4BZ.js +0 -528
- package/dist/browserPlayer-HE2uqs17-DJrIq6Jp.js +0 -259
- package/dist/index-vp_MoGvy.js +0 -3417
- package/dist/index.d.ts +0 -24
- package/dist/nativePlayer-B3eHKegV-DdXsvi0F.js +0 -323
- package/dist/output-devices-Jno8Kp5B-CAnEAv_Z.js +0 -224
- package/dist/shakaPlayer-CCJQsypf-DHT2kwDp.js +0 -24411
|
@@ -0,0 +1,1448 @@
|
|
|
1
|
+
import { a as e, d as t, i as n, n as r, o as i, t as a, u as o } from "./state-B888KJag-C7pa4Xs7.js";
|
|
2
|
+
import { t as s } from "./pushkin-BJAKy5lP-BDJR20nC.js";
|
|
3
|
+
import { a as c, i as l, n as u } from "./audio-context-store-Ccv6WKna-C-yxIXdl.js";
|
|
4
|
+
import { t as d } from "./generate-guid-DMif1b6n-WXvDGKGF.js";
|
|
5
|
+
import { i as f, n as p, o as m, r as h, s as g } from "./load-D2Tka_Qx-BNIMgt7e.js";
|
|
6
|
+
import { t as _ } from "./active-device-changed-DKzZonX1--oMxdziu.js";
|
|
7
|
+
import { n as v, r as y, t as b } from "./basePlayer-CxowZx76-CfK9Qp4M.js";
|
|
8
|
+
import { t as x } from "./media-element-error-circuit-breaker-fMDQ6k4B-B9oZKZUK.js";
|
|
9
|
+
//#region ../player/dist/shakaPlayer-BvtoIIdC.js
|
|
10
|
+
var S = /* @__PURE__ */ d(f(), 1);
|
|
11
|
+
function C(e) {
|
|
12
|
+
return new CustomEvent("playback-quality-changed", { detail: { playbackContext: e } });
|
|
13
|
+
}
|
|
14
|
+
function w(e) {
|
|
15
|
+
let t = e.audioCodec;
|
|
16
|
+
if (t === "flac") {
|
|
17
|
+
let t = e.originalAudioId == null ? void 0 : T(e.originalAudioId);
|
|
18
|
+
return e.audioSamplingRate && e.audioSamplingRate > 44100 || t != null && t > 16 ? "HI_RES_LOSSLESS" : "LOSSLESS";
|
|
19
|
+
}
|
|
20
|
+
return t === "mp4a.40.2" ? "HIGH" : "LOW";
|
|
21
|
+
}
|
|
22
|
+
function T(e) {
|
|
23
|
+
if (!e?.includes(",")) return;
|
|
24
|
+
let t = e.match(/\d+/g)?.at(-1);
|
|
25
|
+
return t == null ? void 0 : Number(t);
|
|
26
|
+
}
|
|
27
|
+
function E(t, r) {
|
|
28
|
+
if (t && r?.audioCodec) {
|
|
29
|
+
let i = n.getMediaProductTransition(t);
|
|
30
|
+
if (!i) {
|
|
31
|
+
console.warn("No media product transition saved.");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let { mediaProduct: a, playbackContext: o } = i, s = {
|
|
35
|
+
...o,
|
|
36
|
+
actualAudioQuality: w(r),
|
|
37
|
+
bandwidth: r.bandwidth ?? null,
|
|
38
|
+
bitDepth: r.originalAudioId ? T(r.originalAudioId) ?? null : null,
|
|
39
|
+
codec: r.audioCodec ? g(r.audioCodec) ?? null : null,
|
|
40
|
+
sampleRate: r.audioSamplingRate ?? null
|
|
41
|
+
};
|
|
42
|
+
n.saveMediaProductTransition(t, {
|
|
43
|
+
mediaProduct: a,
|
|
44
|
+
playbackContext: s
|
|
45
|
+
}), e.dispatchEvent(C(s));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function D(e, t) {
|
|
49
|
+
let n = s.now(), r = e.mimeType, i = e.codecs, a = e.bandwidth, o = e.width;
|
|
50
|
+
return {
|
|
51
|
+
assetPosition: t,
|
|
52
|
+
bandwidth: a,
|
|
53
|
+
codecs: i,
|
|
54
|
+
mimeType: r,
|
|
55
|
+
timestamp: n,
|
|
56
|
+
videoHeight: e.height,
|
|
57
|
+
videoWidth: o
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function O(e, t, n) {
|
|
61
|
+
let r = D(t, n);
|
|
62
|
+
return r.mimeType && r.codecs && await p({
|
|
63
|
+
adaptations: [r],
|
|
64
|
+
streamingSessionId: e
|
|
65
|
+
}), r;
|
|
66
|
+
}
|
|
67
|
+
function k(e, t, n) {
|
|
68
|
+
let r = () => {
|
|
69
|
+
if (!n()) return;
|
|
70
|
+
let r = e.getVariantTracks().find((e) => e.active), i = e.getMediaElement(), a = t();
|
|
71
|
+
a && i && O(a, r, i.currentTime).catch(console.error);
|
|
72
|
+
}, i = (e) => {
|
|
73
|
+
if (!n()) return;
|
|
74
|
+
r();
|
|
75
|
+
let i = e.newTrack, a = t();
|
|
76
|
+
a && E(a, i);
|
|
77
|
+
};
|
|
78
|
+
return e.addEventListener("adaptation", i), e.addEventListener("variantchanged", r), function() {
|
|
79
|
+
e.removeEventListener("adaptation", i), e.removeEventListener("variantchanged", r);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async function A() {
|
|
83
|
+
try {
|
|
84
|
+
let e = await (await fetch("https://fp.fa.tidal.com/certificate")).arrayBuffer();
|
|
85
|
+
return new Uint8Array(e);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
throw console.error("Failed to retrieve the server certificate.", e);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var j = {
|
|
91
|
+
isPlaying: !1,
|
|
92
|
+
isSeeking: !1
|
|
93
|
+
}, M = (e) => new Promise((t) => e.addEventListener("waiting", () => t(), { once: !0 })), N = (e) => new Promise((t) => e.addEventListener("playing", () => t(), { once: !0 }));
|
|
94
|
+
function P() {
|
|
95
|
+
j.isSeeking = !0;
|
|
96
|
+
}
|
|
97
|
+
function F() {
|
|
98
|
+
j.isSeeking = !1;
|
|
99
|
+
}
|
|
100
|
+
function I() {
|
|
101
|
+
j.isPlaying = !1;
|
|
102
|
+
}
|
|
103
|
+
async function L(e, t) {
|
|
104
|
+
j.isPlaying = !0, await M(e);
|
|
105
|
+
let n = e.currentTime;
|
|
106
|
+
if (!j.isPlaying || n === 0) return;
|
|
107
|
+
let r = s.now(), i = j.isSeeking ? "SEEK" : "UNEXPECTED";
|
|
108
|
+
await N(e), p({
|
|
109
|
+
stalls: [{
|
|
110
|
+
assetPosition: n,
|
|
111
|
+
endTimestamp: s.now(),
|
|
112
|
+
reason: i,
|
|
113
|
+
startTimestamp: r
|
|
114
|
+
}],
|
|
115
|
+
streamingSessionId: t
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function R(t) {
|
|
119
|
+
let n;
|
|
120
|
+
e.addEventListener("media-product-transition", (e) => {
|
|
121
|
+
e instanceof CustomEvent && (n = e.detail.playbackContext.playbackSessionId);
|
|
122
|
+
});
|
|
123
|
+
let r = () => I(), i = () => {
|
|
124
|
+
n && L(t, n).catch(console.error);
|
|
125
|
+
}, a = () => P(), o = () => F();
|
|
126
|
+
return t.addEventListener("seeking", a), t.addEventListener("seeked", o), t.addEventListener("playing", i), t.addEventListener("paused", r), function() {
|
|
127
|
+
t.removeEventListener("seeking", a), t.removeEventListener("seeked", o), t.removeEventListener("playing", i), t.removeEventListener("paused", r);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
var z;
|
|
131
|
+
function B(e) {
|
|
132
|
+
switch (e.split("/").pop()?.split("?")[0]) {
|
|
133
|
+
case "fairplay": return "FAIR_PLAY";
|
|
134
|
+
case "widevine": return "WIDEVINE";
|
|
135
|
+
default: return "NONE";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
var V = new Uint8Array([
|
|
139
|
+
10,
|
|
140
|
+
193,
|
|
141
|
+
2,
|
|
142
|
+
8,
|
|
143
|
+
3,
|
|
144
|
+
18,
|
|
145
|
+
16,
|
|
146
|
+
23,
|
|
147
|
+
5,
|
|
148
|
+
185,
|
|
149
|
+
23,
|
|
150
|
+
204,
|
|
151
|
+
18,
|
|
152
|
+
4,
|
|
153
|
+
134,
|
|
154
|
+
139,
|
|
155
|
+
6,
|
|
156
|
+
51,
|
|
157
|
+
58,
|
|
158
|
+
47,
|
|
159
|
+
119,
|
|
160
|
+
42,
|
|
161
|
+
140,
|
|
162
|
+
24,
|
|
163
|
+
130,
|
|
164
|
+
180,
|
|
165
|
+
130,
|
|
166
|
+
146,
|
|
167
|
+
5,
|
|
168
|
+
34,
|
|
169
|
+
142,
|
|
170
|
+
2,
|
|
171
|
+
48,
|
|
172
|
+
130,
|
|
173
|
+
1,
|
|
174
|
+
10,
|
|
175
|
+
2,
|
|
176
|
+
130,
|
|
177
|
+
1,
|
|
178
|
+
1,
|
|
179
|
+
0,
|
|
180
|
+
153,
|
|
181
|
+
237,
|
|
182
|
+
91,
|
|
183
|
+
59,
|
|
184
|
+
50,
|
|
185
|
+
125,
|
|
186
|
+
171,
|
|
187
|
+
94,
|
|
188
|
+
36,
|
|
189
|
+
239,
|
|
190
|
+
195,
|
|
191
|
+
182,
|
|
192
|
+
42,
|
|
193
|
+
149,
|
|
194
|
+
181,
|
|
195
|
+
152,
|
|
196
|
+
82,
|
|
197
|
+
10,
|
|
198
|
+
213,
|
|
199
|
+
188,
|
|
200
|
+
203,
|
|
201
|
+
55,
|
|
202
|
+
80,
|
|
203
|
+
62,
|
|
204
|
+
6,
|
|
205
|
+
69,
|
|
206
|
+
184,
|
|
207
|
+
20,
|
|
208
|
+
216,
|
|
209
|
+
118,
|
|
210
|
+
184,
|
|
211
|
+
223,
|
|
212
|
+
64,
|
|
213
|
+
81,
|
|
214
|
+
4,
|
|
215
|
+
65,
|
|
216
|
+
173,
|
|
217
|
+
140,
|
|
218
|
+
227,
|
|
219
|
+
173,
|
|
220
|
+
177,
|
|
221
|
+
27,
|
|
222
|
+
184,
|
|
223
|
+
140,
|
|
224
|
+
78,
|
|
225
|
+
114,
|
|
226
|
+
90,
|
|
227
|
+
94,
|
|
228
|
+
74,
|
|
229
|
+
158,
|
|
230
|
+
7,
|
|
231
|
+
149,
|
|
232
|
+
41,
|
|
233
|
+
29,
|
|
234
|
+
88,
|
|
235
|
+
88,
|
|
236
|
+
64,
|
|
237
|
+
35,
|
|
238
|
+
167,
|
|
239
|
+
225,
|
|
240
|
+
175,
|
|
241
|
+
14,
|
|
242
|
+
56,
|
|
243
|
+
169,
|
|
244
|
+
18,
|
|
245
|
+
121,
|
|
246
|
+
57,
|
|
247
|
+
48,
|
|
248
|
+
8,
|
|
249
|
+
97,
|
|
250
|
+
11,
|
|
251
|
+
111,
|
|
252
|
+
21,
|
|
253
|
+
140,
|
|
254
|
+
135,
|
|
255
|
+
140,
|
|
256
|
+
126,
|
|
257
|
+
33,
|
|
258
|
+
191,
|
|
259
|
+
251,
|
|
260
|
+
254,
|
|
261
|
+
234,
|
|
262
|
+
119,
|
|
263
|
+
225,
|
|
264
|
+
1,
|
|
265
|
+
158,
|
|
266
|
+
30,
|
|
267
|
+
87,
|
|
268
|
+
129,
|
|
269
|
+
232,
|
|
270
|
+
164,
|
|
271
|
+
95,
|
|
272
|
+
70,
|
|
273
|
+
38,
|
|
274
|
+
61,
|
|
275
|
+
20,
|
|
276
|
+
230,
|
|
277
|
+
14,
|
|
278
|
+
128,
|
|
279
|
+
88,
|
|
280
|
+
168,
|
|
281
|
+
96,
|
|
282
|
+
122,
|
|
283
|
+
220,
|
|
284
|
+
224,
|
|
285
|
+
79,
|
|
286
|
+
172,
|
|
287
|
+
132,
|
|
288
|
+
87,
|
|
289
|
+
177,
|
|
290
|
+
55,
|
|
291
|
+
168,
|
|
292
|
+
214,
|
|
293
|
+
124,
|
|
294
|
+
205,
|
|
295
|
+
235,
|
|
296
|
+
51,
|
|
297
|
+
112,
|
|
298
|
+
93,
|
|
299
|
+
152,
|
|
300
|
+
58,
|
|
301
|
+
33,
|
|
302
|
+
251,
|
|
303
|
+
78,
|
|
304
|
+
236,
|
|
305
|
+
189,
|
|
306
|
+
74,
|
|
307
|
+
16,
|
|
308
|
+
202,
|
|
309
|
+
71,
|
|
310
|
+
73,
|
|
311
|
+
12,
|
|
312
|
+
164,
|
|
313
|
+
126,
|
|
314
|
+
170,
|
|
315
|
+
93,
|
|
316
|
+
67,
|
|
317
|
+
130,
|
|
318
|
+
24,
|
|
319
|
+
221,
|
|
320
|
+
186,
|
|
321
|
+
241,
|
|
322
|
+
202,
|
|
323
|
+
222,
|
|
324
|
+
51,
|
|
325
|
+
146,
|
|
326
|
+
241,
|
|
327
|
+
61,
|
|
328
|
+
111,
|
|
329
|
+
251,
|
|
330
|
+
100,
|
|
331
|
+
66,
|
|
332
|
+
253,
|
|
333
|
+
49,
|
|
334
|
+
225,
|
|
335
|
+
191,
|
|
336
|
+
64,
|
|
337
|
+
176,
|
|
338
|
+
198,
|
|
339
|
+
4,
|
|
340
|
+
209,
|
|
341
|
+
196,
|
|
342
|
+
186,
|
|
343
|
+
76,
|
|
344
|
+
149,
|
|
345
|
+
32,
|
|
346
|
+
164,
|
|
347
|
+
191,
|
|
348
|
+
151,
|
|
349
|
+
238,
|
|
350
|
+
189,
|
|
351
|
+
96,
|
|
352
|
+
146,
|
|
353
|
+
154,
|
|
354
|
+
252,
|
|
355
|
+
238,
|
|
356
|
+
245,
|
|
357
|
+
91,
|
|
358
|
+
186,
|
|
359
|
+
245,
|
|
360
|
+
100,
|
|
361
|
+
226,
|
|
362
|
+
208,
|
|
363
|
+
231,
|
|
364
|
+
108,
|
|
365
|
+
215,
|
|
366
|
+
197,
|
|
367
|
+
92,
|
|
368
|
+
115,
|
|
369
|
+
160,
|
|
370
|
+
130,
|
|
371
|
+
185,
|
|
372
|
+
150,
|
|
373
|
+
18,
|
|
374
|
+
11,
|
|
375
|
+
131,
|
|
376
|
+
89,
|
|
377
|
+
237,
|
|
378
|
+
206,
|
|
379
|
+
36,
|
|
380
|
+
112,
|
|
381
|
+
112,
|
|
382
|
+
130,
|
|
383
|
+
104,
|
|
384
|
+
13,
|
|
385
|
+
111,
|
|
386
|
+
103,
|
|
387
|
+
198,
|
|
388
|
+
216,
|
|
389
|
+
44,
|
|
390
|
+
74,
|
|
391
|
+
197,
|
|
392
|
+
243,
|
|
393
|
+
19,
|
|
394
|
+
68,
|
|
395
|
+
144,
|
|
396
|
+
167,
|
|
397
|
+
78,
|
|
398
|
+
236,
|
|
399
|
+
55,
|
|
400
|
+
175,
|
|
401
|
+
75,
|
|
402
|
+
47,
|
|
403
|
+
1,
|
|
404
|
+
12,
|
|
405
|
+
89,
|
|
406
|
+
232,
|
|
407
|
+
40,
|
|
408
|
+
67,
|
|
409
|
+
226,
|
|
410
|
+
88,
|
|
411
|
+
47,
|
|
412
|
+
11,
|
|
413
|
+
107,
|
|
414
|
+
159,
|
|
415
|
+
93,
|
|
416
|
+
176,
|
|
417
|
+
252,
|
|
418
|
+
94,
|
|
419
|
+
110,
|
|
420
|
+
223,
|
|
421
|
+
100,
|
|
422
|
+
251,
|
|
423
|
+
211,
|
|
424
|
+
8,
|
|
425
|
+
180,
|
|
426
|
+
113,
|
|
427
|
+
27,
|
|
428
|
+
207,
|
|
429
|
+
18,
|
|
430
|
+
80,
|
|
431
|
+
1,
|
|
432
|
+
156,
|
|
433
|
+
159,
|
|
434
|
+
90,
|
|
435
|
+
9,
|
|
436
|
+
2,
|
|
437
|
+
3,
|
|
438
|
+
1,
|
|
439
|
+
0,
|
|
440
|
+
1,
|
|
441
|
+
58,
|
|
442
|
+
20,
|
|
443
|
+
108,
|
|
444
|
+
105,
|
|
445
|
+
99,
|
|
446
|
+
101,
|
|
447
|
+
110,
|
|
448
|
+
115,
|
|
449
|
+
101,
|
|
450
|
+
46,
|
|
451
|
+
119,
|
|
452
|
+
105,
|
|
453
|
+
100,
|
|
454
|
+
101,
|
|
455
|
+
118,
|
|
456
|
+
105,
|
|
457
|
+
110,
|
|
458
|
+
101,
|
|
459
|
+
46,
|
|
460
|
+
99,
|
|
461
|
+
111,
|
|
462
|
+
109,
|
|
463
|
+
18,
|
|
464
|
+
128,
|
|
465
|
+
3,
|
|
466
|
+
174,
|
|
467
|
+
52,
|
|
468
|
+
115,
|
|
469
|
+
20,
|
|
470
|
+
181,
|
|
471
|
+
168,
|
|
472
|
+
53,
|
|
473
|
+
41,
|
|
474
|
+
127,
|
|
475
|
+
39,
|
|
476
|
+
19,
|
|
477
|
+
136,
|
|
478
|
+
251,
|
|
479
|
+
123,
|
|
480
|
+
184,
|
|
481
|
+
203,
|
|
482
|
+
82,
|
|
483
|
+
119,
|
|
484
|
+
210,
|
|
485
|
+
73,
|
|
486
|
+
130,
|
|
487
|
+
60,
|
|
488
|
+
221,
|
|
489
|
+
209,
|
|
490
|
+
218,
|
|
491
|
+
48,
|
|
492
|
+
185,
|
|
493
|
+
51,
|
|
494
|
+
57,
|
|
495
|
+
81,
|
|
496
|
+
30,
|
|
497
|
+
179,
|
|
498
|
+
204,
|
|
499
|
+
189,
|
|
500
|
+
234,
|
|
501
|
+
4,
|
|
502
|
+
185,
|
|
503
|
+
68,
|
|
504
|
+
185,
|
|
505
|
+
39,
|
|
506
|
+
193,
|
|
507
|
+
33,
|
|
508
|
+
52,
|
|
509
|
+
110,
|
|
510
|
+
253,
|
|
511
|
+
189,
|
|
512
|
+
234,
|
|
513
|
+
201,
|
|
514
|
+
212,
|
|
515
|
+
19,
|
|
516
|
+
145,
|
|
517
|
+
126,
|
|
518
|
+
110,
|
|
519
|
+
193,
|
|
520
|
+
118,
|
|
521
|
+
161,
|
|
522
|
+
4,
|
|
523
|
+
56,
|
|
524
|
+
70,
|
|
525
|
+
10,
|
|
526
|
+
80,
|
|
527
|
+
59,
|
|
528
|
+
193,
|
|
529
|
+
149,
|
|
530
|
+
43,
|
|
531
|
+
155,
|
|
532
|
+
164,
|
|
533
|
+
228,
|
|
534
|
+
206,
|
|
535
|
+
15,
|
|
536
|
+
196,
|
|
537
|
+
191,
|
|
538
|
+
194,
|
|
539
|
+
10,
|
|
540
|
+
152,
|
|
541
|
+
8,
|
|
542
|
+
170,
|
|
543
|
+
175,
|
|
544
|
+
75,
|
|
545
|
+
252,
|
|
546
|
+
209,
|
|
547
|
+
156,
|
|
548
|
+
29,
|
|
549
|
+
207,
|
|
550
|
+
205,
|
|
551
|
+
245,
|
|
552
|
+
116,
|
|
553
|
+
204,
|
|
554
|
+
172,
|
|
555
|
+
40,
|
|
556
|
+
209,
|
|
557
|
+
180,
|
|
558
|
+
16,
|
|
559
|
+
65,
|
|
560
|
+
108,
|
|
561
|
+
249,
|
|
562
|
+
222,
|
|
563
|
+
136,
|
|
564
|
+
4,
|
|
565
|
+
48,
|
|
566
|
+
28,
|
|
567
|
+
189,
|
|
568
|
+
179,
|
|
569
|
+
52,
|
|
570
|
+
202,
|
|
571
|
+
252,
|
|
572
|
+
208,
|
|
573
|
+
212,
|
|
574
|
+
9,
|
|
575
|
+
120,
|
|
576
|
+
66,
|
|
577
|
+
58,
|
|
578
|
+
100,
|
|
579
|
+
46,
|
|
580
|
+
84,
|
|
581
|
+
97,
|
|
582
|
+
61,
|
|
583
|
+
240,
|
|
584
|
+
175,
|
|
585
|
+
207,
|
|
586
|
+
150,
|
|
587
|
+
202,
|
|
588
|
+
74,
|
|
589
|
+
146,
|
|
590
|
+
73,
|
|
591
|
+
216,
|
|
592
|
+
85,
|
|
593
|
+
228,
|
|
594
|
+
43,
|
|
595
|
+
58,
|
|
596
|
+
112,
|
|
597
|
+
62,
|
|
598
|
+
241,
|
|
599
|
+
118,
|
|
600
|
+
127,
|
|
601
|
+
106,
|
|
602
|
+
155,
|
|
603
|
+
211,
|
|
604
|
+
109,
|
|
605
|
+
107,
|
|
606
|
+
248,
|
|
607
|
+
43,
|
|
608
|
+
231,
|
|
609
|
+
107,
|
|
610
|
+
191,
|
|
611
|
+
12,
|
|
612
|
+
186,
|
|
613
|
+
79,
|
|
614
|
+
222,
|
|
615
|
+
89,
|
|
616
|
+
210,
|
|
617
|
+
171,
|
|
618
|
+
204,
|
|
619
|
+
118,
|
|
620
|
+
254,
|
|
621
|
+
182,
|
|
622
|
+
66,
|
|
623
|
+
71,
|
|
624
|
+
184,
|
|
625
|
+
92,
|
|
626
|
+
67,
|
|
627
|
+
31,
|
|
628
|
+
188,
|
|
629
|
+
165,
|
|
630
|
+
34,
|
|
631
|
+
102,
|
|
632
|
+
182,
|
|
633
|
+
25,
|
|
634
|
+
252,
|
|
635
|
+
54,
|
|
636
|
+
151,
|
|
637
|
+
149,
|
|
638
|
+
67,
|
|
639
|
+
252,
|
|
640
|
+
169,
|
|
641
|
+
203,
|
|
642
|
+
189,
|
|
643
|
+
187,
|
|
644
|
+
250,
|
|
645
|
+
250,
|
|
646
|
+
14,
|
|
647
|
+
26,
|
|
648
|
+
85,
|
|
649
|
+
231,
|
|
650
|
+
85,
|
|
651
|
+
163,
|
|
652
|
+
199,
|
|
653
|
+
188,
|
|
654
|
+
230,
|
|
655
|
+
85,
|
|
656
|
+
249,
|
|
657
|
+
100,
|
|
658
|
+
111,
|
|
659
|
+
88,
|
|
660
|
+
42,
|
|
661
|
+
185,
|
|
662
|
+
207,
|
|
663
|
+
112,
|
|
664
|
+
170,
|
|
665
|
+
8,
|
|
666
|
+
185,
|
|
667
|
+
121,
|
|
668
|
+
248,
|
|
669
|
+
103,
|
|
670
|
+
246,
|
|
671
|
+
58,
|
|
672
|
+
11,
|
|
673
|
+
43,
|
|
674
|
+
127,
|
|
675
|
+
219,
|
|
676
|
+
54,
|
|
677
|
+
44,
|
|
678
|
+
91,
|
|
679
|
+
196,
|
|
680
|
+
236,
|
|
681
|
+
213,
|
|
682
|
+
85,
|
|
683
|
+
216,
|
|
684
|
+
91,
|
|
685
|
+
202,
|
|
686
|
+
169,
|
|
687
|
+
197,
|
|
688
|
+
147,
|
|
689
|
+
195,
|
|
690
|
+
131,
|
|
691
|
+
200,
|
|
692
|
+
87,
|
|
693
|
+
212,
|
|
694
|
+
157,
|
|
695
|
+
170,
|
|
696
|
+
183,
|
|
697
|
+
126,
|
|
698
|
+
64,
|
|
699
|
+
183,
|
|
700
|
+
133,
|
|
701
|
+
29,
|
|
702
|
+
223,
|
|
703
|
+
210,
|
|
704
|
+
73,
|
|
705
|
+
152,
|
|
706
|
+
128,
|
|
707
|
+
142,
|
|
708
|
+
53,
|
|
709
|
+
178,
|
|
710
|
+
88,
|
|
711
|
+
231,
|
|
712
|
+
93,
|
|
713
|
+
120,
|
|
714
|
+
234,
|
|
715
|
+
192,
|
|
716
|
+
202,
|
|
717
|
+
22,
|
|
718
|
+
247,
|
|
719
|
+
4,
|
|
720
|
+
115,
|
|
721
|
+
4,
|
|
722
|
+
194,
|
|
723
|
+
13,
|
|
724
|
+
147,
|
|
725
|
+
237,
|
|
726
|
+
228,
|
|
727
|
+
232,
|
|
728
|
+
255,
|
|
729
|
+
28,
|
|
730
|
+
111,
|
|
731
|
+
23,
|
|
732
|
+
230,
|
|
733
|
+
36,
|
|
734
|
+
62,
|
|
735
|
+
63,
|
|
736
|
+
61,
|
|
737
|
+
168,
|
|
738
|
+
252,
|
|
739
|
+
23,
|
|
740
|
+
9,
|
|
741
|
+
135,
|
|
742
|
+
14,
|
|
743
|
+
196,
|
|
744
|
+
95,
|
|
745
|
+
186,
|
|
746
|
+
130,
|
|
747
|
+
58,
|
|
748
|
+
38,
|
|
749
|
+
63,
|
|
750
|
+
12,
|
|
751
|
+
239,
|
|
752
|
+
161,
|
|
753
|
+
247,
|
|
754
|
+
9,
|
|
755
|
+
59,
|
|
756
|
+
25,
|
|
757
|
+
9,
|
|
758
|
+
146,
|
|
759
|
+
131,
|
|
760
|
+
38,
|
|
761
|
+
51,
|
|
762
|
+
55,
|
|
763
|
+
5,
|
|
764
|
+
4,
|
|
765
|
+
58,
|
|
766
|
+
41,
|
|
767
|
+
189,
|
|
768
|
+
166,
|
|
769
|
+
249,
|
|
770
|
+
180,
|
|
771
|
+
52,
|
|
772
|
+
44,
|
|
773
|
+
200,
|
|
774
|
+
223,
|
|
775
|
+
84,
|
|
776
|
+
60,
|
|
777
|
+
177,
|
|
778
|
+
161,
|
|
779
|
+
24,
|
|
780
|
+
47,
|
|
781
|
+
124,
|
|
782
|
+
95,
|
|
783
|
+
255,
|
|
784
|
+
51,
|
|
785
|
+
241,
|
|
786
|
+
4,
|
|
787
|
+
144,
|
|
788
|
+
250,
|
|
789
|
+
202,
|
|
790
|
+
91,
|
|
791
|
+
37,
|
|
792
|
+
54,
|
|
793
|
+
11,
|
|
794
|
+
118,
|
|
795
|
+
1,
|
|
796
|
+
94,
|
|
797
|
+
156,
|
|
798
|
+
90,
|
|
799
|
+
6,
|
|
800
|
+
171,
|
|
801
|
+
142,
|
|
802
|
+
224,
|
|
803
|
+
47,
|
|
804
|
+
0,
|
|
805
|
+
210,
|
|
806
|
+
232,
|
|
807
|
+
213,
|
|
808
|
+
152,
|
|
809
|
+
97,
|
|
810
|
+
4,
|
|
811
|
+
170,
|
|
812
|
+
204,
|
|
813
|
+
77,
|
|
814
|
+
212,
|
|
815
|
+
117,
|
|
816
|
+
253,
|
|
817
|
+
150,
|
|
818
|
+
238,
|
|
819
|
+
156,
|
|
820
|
+
228,
|
|
821
|
+
227,
|
|
822
|
+
38,
|
|
823
|
+
242,
|
|
824
|
+
27,
|
|
825
|
+
131,
|
|
826
|
+
199,
|
|
827
|
+
5,
|
|
828
|
+
133,
|
|
829
|
+
119,
|
|
830
|
+
179,
|
|
831
|
+
135,
|
|
832
|
+
50,
|
|
833
|
+
205,
|
|
834
|
+
218,
|
|
835
|
+
188,
|
|
836
|
+
106,
|
|
837
|
+
107,
|
|
838
|
+
237,
|
|
839
|
+
19,
|
|
840
|
+
251,
|
|
841
|
+
13,
|
|
842
|
+
73,
|
|
843
|
+
211,
|
|
844
|
+
138,
|
|
845
|
+
69,
|
|
846
|
+
235,
|
|
847
|
+
135,
|
|
848
|
+
165,
|
|
849
|
+
244
|
|
850
|
+
]), H = class d extends b {
|
|
851
|
+
static #e = 250;
|
|
852
|
+
static #t = .25;
|
|
853
|
+
#n = 1;
|
|
854
|
+
#r = null;
|
|
855
|
+
#i = !1;
|
|
856
|
+
#a = null;
|
|
857
|
+
#o = null;
|
|
858
|
+
#s = void 0;
|
|
859
|
+
#c = !0;
|
|
860
|
+
#l;
|
|
861
|
+
#u = x();
|
|
862
|
+
#d;
|
|
863
|
+
#f;
|
|
864
|
+
#p;
|
|
865
|
+
#m = !1;
|
|
866
|
+
#h = null;
|
|
867
|
+
#g;
|
|
868
|
+
#_;
|
|
869
|
+
#v;
|
|
870
|
+
#y = !1;
|
|
871
|
+
name = "shakaPlayer";
|
|
872
|
+
constructor() {
|
|
873
|
+
super(), this.playbackState = "IDLE", this.#l = this.#M(), o("outputDevicesEnabled") && (async () => {
|
|
874
|
+
z = (await import("./output-devices-kF_iC6GM-CnAUEjc9.js")).outputDevices;
|
|
875
|
+
})();
|
|
876
|
+
let e = (e) => {
|
|
877
|
+
if (!e) return !1;
|
|
878
|
+
let t = e.target;
|
|
879
|
+
return t instanceof HTMLMediaElement ? t !== this.#T() : t instanceof S.default.Player ? t !== this.#E() : !0;
|
|
880
|
+
}, t = (t) => {
|
|
881
|
+
e(t) || (this.mediaElement && !this.mediaElement.paused && (this.playbackState = "PLAYING"), t?.target === this.#T() && this.#m && this.#h && !this.#i && this.#o == null && this.#P());
|
|
882
|
+
}, r = (t) => {
|
|
883
|
+
if (e(t)) return;
|
|
884
|
+
let n = t.type === "buffering" && this.mediaElement?.networkState === HTMLMediaElement.NETWORK_LOADING;
|
|
885
|
+
(this.mediaElement?.paused || n) && (this.playbackState = "STALLED");
|
|
886
|
+
}, a = (t) => {
|
|
887
|
+
e(t) || (async () => {
|
|
888
|
+
this.mediaElement && this.preloadedStreamingSessionId && this.mediaElement.currentTime === this.mediaElement.duration && (await i(1e3), this.mediaElement && this.mediaElement.currentTime !== this.mediaElement.duration) || (this.playbackState = "NOT_PLAYING");
|
|
889
|
+
})().catch(console.error);
|
|
890
|
+
}, s = (e) => {
|
|
891
|
+
let t = e.target, n = t === this.#T();
|
|
892
|
+
if (n && t.readyState > HTMLMediaElement.HAVE_NOTHING && (this.currentTime = t.currentTime), n && this.#h && this.#m) {
|
|
893
|
+
let e = t.duration - t.currentTime, { startBeforeEndS: n } = this.#k();
|
|
894
|
+
!this.#i && !t.paused && e <= n && e > 0 && this.#R().catch(console.error);
|
|
895
|
+
}
|
|
896
|
+
}, c = (e) => {
|
|
897
|
+
this.currentStreamingSessionId && e.target instanceof HTMLMediaElement && e.target === this.#T() && n.overwriteDuration(this.currentStreamingSessionId, e.target.duration);
|
|
898
|
+
}, l = (e) => {
|
|
899
|
+
let t = e.target;
|
|
900
|
+
s(e);
|
|
901
|
+
let n = t === u, r = n ? this.#f : this.#p;
|
|
902
|
+
if (r) {
|
|
903
|
+
let e = this.currentStreamingSessionId === r;
|
|
904
|
+
if (e && this.#i) {
|
|
905
|
+
this.debugLog(`Active track ended mid-crossfade (session: ${r}) -- letting #completeTransition finalize`);
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
if (t.readyState > HTMLMediaElement.HAVE_NOTHING && (this.currentTime = t.currentTime), this.debugLog(`Ended event from player ${n ? 1 : 2} (session: ${r})`), e) this.finishCurrentMediaProduct("completed");
|
|
909
|
+
else {
|
|
910
|
+
let e = this.playbackState, t = this.currentStreamingSessionId;
|
|
911
|
+
this.currentStreamingSessionId = r, this.finishCurrentMediaProduct("completed", !0), this.currentStreamingSessionId = t, this.playbackState = e;
|
|
912
|
+
let n = this.#T();
|
|
913
|
+
n && n.readyState > HTMLMediaElement.HAVE_NOTHING && (this.currentTime = n.currentTime);
|
|
914
|
+
}
|
|
915
|
+
n ? this.#f = void 0 : this.#p = void 0;
|
|
916
|
+
}
|
|
917
|
+
}, d = (e) => this.#u.handleError(e), f = (t) => {
|
|
918
|
+
e(t) || (this.currentTime = this.mediaElement ? this.mediaElement.currentTime : 0, this.seekEnd(this.currentTime));
|
|
919
|
+
};
|
|
920
|
+
this.#d = {
|
|
921
|
+
durationChangeHandler: c,
|
|
922
|
+
endedHandler: l,
|
|
923
|
+
errorHandler: d,
|
|
924
|
+
pauseHandler: a,
|
|
925
|
+
playHandler: t,
|
|
926
|
+
playingHandler: t,
|
|
927
|
+
seekedHandler: f,
|
|
928
|
+
stalledHandler: r,
|
|
929
|
+
timeUpdateHandler: s,
|
|
930
|
+
waitingHandler: r
|
|
931
|
+
}, this.#g = {
|
|
932
|
+
bufferingHandler: (e) => {
|
|
933
|
+
e.buffering ? r(e) : this.hasStarted() && t(e);
|
|
934
|
+
},
|
|
935
|
+
errorHandler: (e) => this.#A(e),
|
|
936
|
+
loadedHandler: a,
|
|
937
|
+
stallDetectedHandler: r
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
#b() {
|
|
941
|
+
this.#a != null && (clearTimeout(this.#a), this.#a = null), this.#r != null && (clearTimeout(this.#r), this.#r = null), this.#o != null && (clearTimeout(this.#o), this.#o = null);
|
|
942
|
+
}
|
|
943
|
+
#x(t, r, i) {
|
|
944
|
+
if (i !== void 0 && i !== this.#s) return;
|
|
945
|
+
this.#s = void 0, this.#b(), this.debugLog("Crossfade complete - swapping active player");
|
|
946
|
+
let a = this.#T(), o = this.#n === 1 ? this.#f : this.#p;
|
|
947
|
+
if (o) {
|
|
948
|
+
let e = this.playbackState, t = this.currentStreamingSessionId;
|
|
949
|
+
this.currentTime = a.currentTime, this.currentStreamingSessionId = o, this.finishCurrentMediaProduct("completed", !0), this.currentStreamingSessionId = t, this.playbackState = e, this.#n === 1 ? this.#f = void 0 : this.#p = void 0;
|
|
950
|
+
}
|
|
951
|
+
a.volume = 0;
|
|
952
|
+
try {
|
|
953
|
+
a.pause();
|
|
954
|
+
} catch {}
|
|
955
|
+
this.#n = this.#n === 1 ? 2 : 1, this.currentTime = t.currentTime, this.currentStreamingSessionId = r.streamInfo.streamingSessionId, this.preloadedStreamingSessionId = void 0, this.startAssetPosition = 0;
|
|
956
|
+
let c = Number.isFinite(t.duration) ? t.duration : r.streamInfo.duration ?? 0, l = t.currentTime, u = y({
|
|
957
|
+
assetPosition: l,
|
|
958
|
+
duration: c,
|
|
959
|
+
playbackInfo: r.playbackInfo,
|
|
960
|
+
streamInfo: r.streamInfo
|
|
961
|
+
});
|
|
962
|
+
n.saveMediaProductTransition(r.streamInfo.streamingSessionId, {
|
|
963
|
+
mediaProduct: r.mediaProduct,
|
|
964
|
+
playbackContext: u
|
|
965
|
+
}), this.debugLog("Media product transition saved for track"), e.dispatchEvent(v(r.mediaProduct, u)), performance.mark("streaming_metrics:playback_statistics:idealStartTimestamp", {
|
|
966
|
+
detail: r.streamInfo.streamingSessionId,
|
|
967
|
+
startTime: s.now()
|
|
968
|
+
}), this.mediaProductStarted(r.streamInfo.streamingSessionId), this.debugLog("Transition complete! Active player is now:", this.#n), this.#i = !1;
|
|
969
|
+
}
|
|
970
|
+
async #S(e) {
|
|
971
|
+
if ("Cypress" in window) return;
|
|
972
|
+
let t = await S.default.Player.probeSupport();
|
|
973
|
+
if (t.drm["com.widevine.alpha"]) {
|
|
974
|
+
this.debugLog("Configuring widevine DRM."), e.configure({ drm: {
|
|
975
|
+
advanced: { "com.widevine.alpha": {
|
|
976
|
+
audioRobustness: ["SW_SECURE_CRYPTO"],
|
|
977
|
+
serverCertificate: V,
|
|
978
|
+
videoRobustness: ["SW_SECURE_CRYPTO"]
|
|
979
|
+
} },
|
|
980
|
+
servers: { "com.widevine.alpha": "https://api.tidal.com/v2/widevine" }
|
|
981
|
+
} });
|
|
982
|
+
return;
|
|
983
|
+
} else if (t.drm["com.apple.fps.1_0"]) {
|
|
984
|
+
this.debugLog("Configuring fairplay DRM."), S.default.polyfill.PatchedMediaKeysApple.install();
|
|
985
|
+
let t = await A();
|
|
986
|
+
e.configure({ drm: {
|
|
987
|
+
advanced: { "com.apple.fps.1_0": {
|
|
988
|
+
serverCertificate: t,
|
|
989
|
+
serverCertificateUri: "https://fp.fa.tidal.com/certificate"
|
|
990
|
+
} },
|
|
991
|
+
initDataTransform: S.default.drm.FairPlay.verimatrixInitDataTransform,
|
|
992
|
+
servers: { "com.apple.fps.1_0": "https://fp.fa.tidal.com/license" }
|
|
993
|
+
} });
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
async #C(e) {
|
|
998
|
+
await S.default.drm.FairPlay.isFairPlaySupported() && e && (e.getConfiguration().streaming.preferNativeHls !== !0 && e.configure("streaming.preferNativeHls", !0), e.getConfiguration().streaming.useNativeHlsForFairPlay !== !0 && e.configure("streaming.useNativeHlsForFairPlay", !0), await e.unload(!0));
|
|
999
|
+
}
|
|
1000
|
+
async #w(e, n) {
|
|
1001
|
+
this.debugLog("createShakaPlayer", e);
|
|
1002
|
+
let r = new S.default.Player();
|
|
1003
|
+
await r.attach(e), R(e), k(r, () => n === 1 ? this.#f : this.#p, () => this.#n === n);
|
|
1004
|
+
let i = await S.default.drm.FairPlay.isFairPlaySupported(), a = {
|
|
1005
|
+
backoffFactor: 2,
|
|
1006
|
+
baseDelay: 1e3,
|
|
1007
|
+
fuzzFactor: .5,
|
|
1008
|
+
maxAttempts: 5,
|
|
1009
|
+
timeout: 5e3
|
|
1010
|
+
};
|
|
1011
|
+
r.configure({
|
|
1012
|
+
abr: { enabled: !0 },
|
|
1013
|
+
drm: { retryParameters: a },
|
|
1014
|
+
manifest: {
|
|
1015
|
+
defaultPresentationDelay: 0,
|
|
1016
|
+
disableText: !0,
|
|
1017
|
+
disableThumbnails: !0,
|
|
1018
|
+
retryParameters: a
|
|
1019
|
+
},
|
|
1020
|
+
streaming: {
|
|
1021
|
+
bufferBehind: 40,
|
|
1022
|
+
bufferingGoal: 40,
|
|
1023
|
+
preferNativeHls: i,
|
|
1024
|
+
retryParameters: a,
|
|
1025
|
+
useNativeHlsForFairPlay: i
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
try {
|
|
1029
|
+
await this.#S(r);
|
|
1030
|
+
} catch {
|
|
1031
|
+
this.finishCurrentMediaProduct("error");
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
return r.getNetworkingEngine()?.registerRequestFilter(async (e, r, i) => {
|
|
1035
|
+
if (e === S.default.net.NetworkingEngine.RequestType.LICENSE) {
|
|
1036
|
+
let e = i?.isPreload ?? n !== this.#n ? this.preloadedStreamingSessionId ?? this.currentStreamingSessionId : this.currentStreamingSessionId;
|
|
1037
|
+
performance.mark("streaming_metrics:drm_license_fetch:startTimestamp", {
|
|
1038
|
+
detail: e,
|
|
1039
|
+
startTime: s.now()
|
|
1040
|
+
}), r.headers["Content-Type"] = "application/octet-stream";
|
|
1041
|
+
let { token: a } = await t.credentialsProvider.getCredentials();
|
|
1042
|
+
a && (r.headers.authorization = `Bearer ${a}`);
|
|
1043
|
+
}
|
|
1044
|
+
}), r.getNetworkingEngine()?.registerResponseFilter((e, t, r) => {
|
|
1045
|
+
let i = r?.isPreload ?? n !== this.#n ? this.preloadedStreamingSessionId ?? this.currentStreamingSessionId : this.currentStreamingSessionId;
|
|
1046
|
+
e === S.default.net.NetworkingEngine.RequestType.LICENSE && i && (performance.mark("streaming_metrics:drm_license_fetch:endTimestamp", {
|
|
1047
|
+
detail: i,
|
|
1048
|
+
startTime: s.now()
|
|
1049
|
+
}), performance.measure("streaming_metrics:drm_license_fetch", {
|
|
1050
|
+
detail: i,
|
|
1051
|
+
end: "streaming_metrics:drm_license_fetch:endTimestamp",
|
|
1052
|
+
start: "streaming_metrics:drm_license_fetch:startTimestamp"
|
|
1053
|
+
}), p({
|
|
1054
|
+
cdm: B(t.uri),
|
|
1055
|
+
cdmVersion: null,
|
|
1056
|
+
streamingSessionId: i
|
|
1057
|
+
}), m([h({
|
|
1058
|
+
endReason: "COMPLETE",
|
|
1059
|
+
endTimestamp: s.timestamp("streaming_metrics:drm_license_fetch:endTimestamp"),
|
|
1060
|
+
errorCode: null,
|
|
1061
|
+
errorMessage: null,
|
|
1062
|
+
startTimestamp: s.timestamp("streaming_metrics:drm_license_fetch:startTimestamp"),
|
|
1063
|
+
streamingSessionId: i
|
|
1064
|
+
})]).catch(console.error), performance.clearMarks("streaming_metrics:drm_license_fetch:endTimestamp"), performance.clearMarks("streaming_metrics:drm_license_fetch:startTimestamp"));
|
|
1065
|
+
}), this.#F(r, !0), this.#N(e, !0), r;
|
|
1066
|
+
}
|
|
1067
|
+
#T() {
|
|
1068
|
+
return this.#n === 1 ? u : l;
|
|
1069
|
+
}
|
|
1070
|
+
#E() {
|
|
1071
|
+
return this.#n === 1 ? this.#_ : this.#v;
|
|
1072
|
+
}
|
|
1073
|
+
#D() {
|
|
1074
|
+
return this.#n === 1 ? l : u;
|
|
1075
|
+
}
|
|
1076
|
+
#O() {
|
|
1077
|
+
return this.#n === 1 ? this.#v : this.#_;
|
|
1078
|
+
}
|
|
1079
|
+
#k() {
|
|
1080
|
+
let e = o("crossfadeInMs");
|
|
1081
|
+
return e > 0 ? {
|
|
1082
|
+
crossfadeDurationMs: e,
|
|
1083
|
+
startBeforeEndS: e / 1e3
|
|
1084
|
+
} : {
|
|
1085
|
+
crossfadeDurationMs: d.#e,
|
|
1086
|
+
startBeforeEndS: d.#t
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
#A(t) {
|
|
1090
|
+
if (this.#c) return;
|
|
1091
|
+
let n = t.target instanceof S.default.Player && t.target !== this.#E(), i = t.detail, a = `S${i.code}`;
|
|
1092
|
+
switch (i.code) {
|
|
1093
|
+
case S.default.util.Error.Code.LICENSE_REQUEST_FAILED: {
|
|
1094
|
+
let e = n ? this.preloadedStreamingSessionId ?? this.currentStreamingSessionId : this.currentStreamingSessionId;
|
|
1095
|
+
e && m([h({
|
|
1096
|
+
endReason: "ERROR",
|
|
1097
|
+
endTimestamp: s.timestamp("streaming_metrics:drm_license_fetch:endTimestamp"),
|
|
1098
|
+
errorCode: a,
|
|
1099
|
+
errorMessage: JSON.stringify(i),
|
|
1100
|
+
startTimestamp: s.timestamp("streaming_metrics:drm_license_fetch:startTimestamp"),
|
|
1101
|
+
streamingSessionId: e
|
|
1102
|
+
})]).catch(console.error);
|
|
1103
|
+
break;
|
|
1104
|
+
}
|
|
1105
|
+
case S.default.util.Error.Code.LOAD_INTERRUPTED: return;
|
|
1106
|
+
case S.default.util.Error.Code.SRC_EQUALS_PRELOAD_NOT_SUPPORTED: return;
|
|
1107
|
+
case S.default.util.Error.Code.TIMEOUT:
|
|
1108
|
+
console.warn("Shaka: TIMEOUT"), console.warn("Shaka: URI", i.data[0]), console.warn("Shaka: RequestType", i.data[1]);
|
|
1109
|
+
break;
|
|
1110
|
+
default: break;
|
|
1111
|
+
}
|
|
1112
|
+
let o = i.category === S.default.util.Error.Category.NETWORK;
|
|
1113
|
+
if (i.severity === S.default.util.Error.Severity.CRITICAL) {
|
|
1114
|
+
if (n) {
|
|
1115
|
+
this.debugLog("Critical error from inactive player, clearing preload:", a), this.#m = !1, this.unloadPreloadedMediaProduct().catch(console.error), e.dispatchError(new r(o ? "PENetwork" : "EUnexpected", a));
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
this.playbackState = "STALLED", this.mediaElement && this.mediaElement.pause(), this.currentStreamingSessionId && p({
|
|
1119
|
+
errorCode: a,
|
|
1120
|
+
errorMessage: JSON.stringify(i),
|
|
1121
|
+
streamingSessionId: this.currentStreamingSessionId
|
|
1122
|
+
}), e.dispatchError(new r(o ? "PENetwork" : "EUnexpected", a)), o || this.finishCurrentMediaProduct("error");
|
|
1123
|
+
}
|
|
1124
|
+
o && (this.#y = !0);
|
|
1125
|
+
}
|
|
1126
|
+
async #j({ assetPosition: t, assetUriOrPreloader: r, mediaProduct: i, playbackInfo: a, streamInfo: o }) {
|
|
1127
|
+
this.debugLog("loadAndDispatchMediaProductTransition"), this.currentTime = t;
|
|
1128
|
+
let s = this.#E(), c = this.#T();
|
|
1129
|
+
if (!s || !c) return;
|
|
1130
|
+
let l, u = new Promise((e) => {
|
|
1131
|
+
l = e;
|
|
1132
|
+
}), d = () => l();
|
|
1133
|
+
s.addEventListener("loaded", d, { once: !0 }), this.debugLog("Loading with", typeof r == "string" ? "URL" : "PreloadManager", "at position", t), this.currentStreamingSessionId = a.streamingSessionId, this.preloadedStreamingSessionId = void 0, this.#n === 1 ? this.#f = a.streamingSessionId : this.#p = a.streamingSessionId;
|
|
1134
|
+
let f, p = n.hasMediaProductTransition(a.streamingSessionId);
|
|
1135
|
+
p ? f = n.getMediaProductTransition(a.streamingSessionId).playbackContext : (f = y({
|
|
1136
|
+
assetPosition: t,
|
|
1137
|
+
duration: o.duration ?? 0,
|
|
1138
|
+
playbackInfo: a,
|
|
1139
|
+
streamInfo: o
|
|
1140
|
+
}), n.saveMediaProductTransition(o.streamingSessionId, {
|
|
1141
|
+
mediaProduct: i,
|
|
1142
|
+
playbackContext: f
|
|
1143
|
+
}));
|
|
1144
|
+
let m = new AbortController(), h;
|
|
1145
|
+
p || (h = new Promise((e) => c.addEventListener("durationchange", (t) => {
|
|
1146
|
+
t.target instanceof HTMLMediaElement && e(t.target.duration);
|
|
1147
|
+
}, {
|
|
1148
|
+
once: !0,
|
|
1149
|
+
signal: m.signal
|
|
1150
|
+
})));
|
|
1151
|
+
try {
|
|
1152
|
+
await s.load(r, t), this.debugLog("Load completed successfully");
|
|
1153
|
+
} catch (e) {
|
|
1154
|
+
let t = e;
|
|
1155
|
+
console.error("Load failed:", t), this.#A(new CustomEvent("shaka-error", { detail: t })), s.removeEventListener("loaded", d), m.abort(), n.deleteSession(o.streamingSessionId);
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
h && (f = y({
|
|
1159
|
+
assetPosition: t,
|
|
1160
|
+
duration: await h,
|
|
1161
|
+
playbackInfo: a,
|
|
1162
|
+
streamInfo: o
|
|
1163
|
+
}), n.saveMediaProductTransition(o.streamingSessionId, {
|
|
1164
|
+
mediaProduct: i,
|
|
1165
|
+
playbackContext: f
|
|
1166
|
+
})), await u, this.currentStreamingSessionId === o.streamingSessionId && e.dispatchEvent(v(i, f));
|
|
1167
|
+
}
|
|
1168
|
+
async #M() {
|
|
1169
|
+
this.debugLog("loadLibraries"), S.default.polyfill.installAll(), await c(), this.#_ = await this.#w(u, 1), this.#v = await this.#w(l, 2), l.volume = 0, this.debugLog("Both Shaka players initialized for gapless playback");
|
|
1170
|
+
}
|
|
1171
|
+
#N(e, t) {
|
|
1172
|
+
this.debugLog("mediaElementEvents", t ? "adding to" : "removing from", e);
|
|
1173
|
+
let n = t ? "addEventListener" : "removeEventListener";
|
|
1174
|
+
e[n]("durationchange", this.#d.durationChangeHandler, { passive: !0 }), e[n]("play", this.#d.playHandler, { passive: !0 }), e[n]("playing", this.#d.playingHandler, { passive: !0 }), e[n]("timeupdate", this.#d.timeUpdateHandler, { passive: !0 }), e[n]("pause", this.#d.pauseHandler, { passive: !0 }), e[n]("ended", this.#d.endedHandler, { passive: !0 }), e[n]("error", this.#d.errorHandler, { passive: !0 }), e[n]("waiting", this.#d.waitingHandler, { passive: !0 }), e[n]("stalled", this.#d.stalledHandler, { passive: !0 }), e[n]("seeked", this.#d.seekedHandler, { passive: !0 });
|
|
1175
|
+
}
|
|
1176
|
+
#P() {
|
|
1177
|
+
this.#o != null && (clearTimeout(this.#o), this.#o = null);
|
|
1178
|
+
let e = this.#T(), t = e.duration;
|
|
1179
|
+
if (!Number.isFinite(t) || t <= 0) {
|
|
1180
|
+
this.debugLog("scheduleCrossfadeTrigger: invalid duration, skipping");
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
let n = e.playbackRate || 1, r = t - e.currentTime, { startBeforeEndS: i } = this.#k(), a = (r - i) * 1e3 / n;
|
|
1184
|
+
if (a <= 0) {
|
|
1185
|
+
if (e.paused) {
|
|
1186
|
+
this.debugLog("scheduleCrossfadeTrigger: inside trigger window but paused -- deferring to timeUpdateHandler");
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
this.debugLog("scheduleCrossfadeTrigger: inside trigger window -- firing now"), this.#R().catch(console.error);
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
this.#o = setTimeout(() => {
|
|
1193
|
+
this.#o = null;
|
|
1194
|
+
let { startBeforeEndS: t } = this.#k();
|
|
1195
|
+
if ((e.duration - e.currentTime - t) * 1e3 / (e.playbackRate || 1) > 0) {
|
|
1196
|
+
if (!this.#m || !this.#h || this.#i) {
|
|
1197
|
+
this.debugLog("scheduleCrossfadeTrigger: preload no longer valid -- not rescheduling");
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
if (e.paused) {
|
|
1201
|
+
this.debugLog("scheduleCrossfadeTrigger: paused while waiting -- deferring re-arm to play event");
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
this.debugLog("scheduleCrossfadeTrigger: no longer inside trigger window -- rescheduling"), this.#P();
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
this.#m && this.#h && !this.#i && !e.paused && e === this.#T() ? this.#R().catch(console.error) : this.debugLog("scheduleCrossfadeTrigger: guards failed, NOT starting");
|
|
1208
|
+
}, a);
|
|
1209
|
+
}
|
|
1210
|
+
#F(e, t) {
|
|
1211
|
+
this.debugLog("shakaEvents");
|
|
1212
|
+
let n = t ? "addEventListener" : "removeEventListener";
|
|
1213
|
+
e[n]("error", this.#g.errorHandler, !1), e[n]("buffering", this.#g.bufferingHandler, !1), e[n]("stalldetected", this.#g.stallDetectedHandler, !1), e[n]("loaded", this.#g.loadedHandler, !1);
|
|
1214
|
+
}
|
|
1215
|
+
async #I(e) {
|
|
1216
|
+
this.debugLog(`Starting crossfade transition (${e}ms)`);
|
|
1217
|
+
let t = this.#T(), r = this.#D(), i = this.#h;
|
|
1218
|
+
this.#m = !1, this.#h = null;
|
|
1219
|
+
let a = {};
|
|
1220
|
+
this.#s = a;
|
|
1221
|
+
let o = n.getStreamInfo(this.currentStreamingSessionId);
|
|
1222
|
+
try {
|
|
1223
|
+
r.currentTime = 0, r.volume = .001, await r.play(), r.volume = 0;
|
|
1224
|
+
} catch (e) {
|
|
1225
|
+
this.debugLog("Error while starting crossfade", e);
|
|
1226
|
+
try {
|
|
1227
|
+
r.pause();
|
|
1228
|
+
} catch {}
|
|
1229
|
+
this.#b(), this.#i = !1, this.#s = void 0, this.unloadPreloadedMediaProduct().catch(console.error);
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
let s = performance.now(), c = () => {
|
|
1233
|
+
if (this.#s !== a) return;
|
|
1234
|
+
let n = performance.now() - s, l = Math.min(n / e, 1), u = Math.cos(l * Math.PI / 2), d = Math.sin(l * Math.PI / 2), f = o ? this.adjustedVolume(o) : t.volume, p = this.adjustedVolume(i.streamInfo);
|
|
1235
|
+
t.volume = Math.max(0, Math.min(1, f * u)), r.volume = Math.max(0, Math.min(1, p * d)), l < 1 ? this.#a = setTimeout(c, 16) : this.#x(r, i, a);
|
|
1236
|
+
};
|
|
1237
|
+
this.#r = setTimeout(() => {
|
|
1238
|
+
this.#s === a && (this.debugLog("Crossfade hit hard deadline -- forcing completion"), t.volume = 0, r.volume = this.adjustedVolume(i.streamInfo), this.#x(r, i, a));
|
|
1239
|
+
}, e + 200), c();
|
|
1240
|
+
}
|
|
1241
|
+
async #L() {
|
|
1242
|
+
this.debugLog("Starting instant transition (no fade)");
|
|
1243
|
+
let e = this.#D(), t = this.#h;
|
|
1244
|
+
this.#m = !1, this.#h = null;
|
|
1245
|
+
let n = {};
|
|
1246
|
+
this.#s = n;
|
|
1247
|
+
let r = this.adjustedVolume(t.streamInfo);
|
|
1248
|
+
try {
|
|
1249
|
+
e.currentTime = 0, e.volume = r, await e.play();
|
|
1250
|
+
} catch (e) {
|
|
1251
|
+
this.debugLog("Error while starting instant transition", e), this.#i = !1, this.#s = void 0, this.unloadPreloadedMediaProduct().catch(console.error);
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
this.#s === n && this.#x(e, t, n);
|
|
1255
|
+
}
|
|
1256
|
+
async #R({ instant: e = !1 } = {}) {
|
|
1257
|
+
if (this.#i || !this.#h || !this.#m) return;
|
|
1258
|
+
if (this.#i = !0, e) {
|
|
1259
|
+
await this.#L();
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
let { crossfadeDurationMs: t } = this.#k(), n = this.#T(), r = n.playbackRate || 1, i = Math.max(0, (n.duration - n.currentTime) * 1e3 / r), a = Math.max(1, Math.min(t, i));
|
|
1263
|
+
await this.#I(a);
|
|
1264
|
+
}
|
|
1265
|
+
async #z(e) {
|
|
1266
|
+
return e.readyState > HTMLMediaElement.HAVE_NOTHING ? !0 : new Promise((t) => {
|
|
1267
|
+
let n = !1, r = () => {
|
|
1268
|
+
e.removeEventListener("loadedmetadata", a), e.removeEventListener("loadeddata", a), e.removeEventListener("canplay", a), clearTimeout(o);
|
|
1269
|
+
}, i = (e) => {
|
|
1270
|
+
n || (n = !0, r(), t(e));
|
|
1271
|
+
}, a = () => i(!0), o = setTimeout(() => i(!1), 1e3);
|
|
1272
|
+
e.addEventListener("loadedmetadata", a, { once: !0 }), e.addEventListener("loadeddata", a, { once: !0 }), e.addEventListener("canplay", a, { once: !0 });
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
getPosition() {
|
|
1276
|
+
return this.currentTime;
|
|
1277
|
+
}
|
|
1278
|
+
async load(e, t) {
|
|
1279
|
+
this.debugLog("load", e), await this.ready, this.currentTime = e.assetPosition, this.startAssetPosition = e.assetPosition, await this.reset(), this.#c = !1, await this.#C(this.#E()), await c();
|
|
1280
|
+
let { assetPosition: n, mediaProduct: r, playbackInfo: i, streamInfo: a } = e;
|
|
1281
|
+
this.currentStreamingSessionId = a.streamingSessionId, t === "explicit" && (this.playbackState = "NOT_PLAYING");
|
|
1282
|
+
let o = this.#T();
|
|
1283
|
+
if (!this.#E() || !o) return;
|
|
1284
|
+
this.#i && (this.#i = !1, this.#s = void 0), this.#b(), this.#m = !1, this.#h = null;
|
|
1285
|
+
let s = this.#D();
|
|
1286
|
+
return s.pause(), s.volume = 0, this.#j({
|
|
1287
|
+
assetPosition: n,
|
|
1288
|
+
assetUriOrPreloader: a.streamUrl,
|
|
1289
|
+
mediaProduct: r,
|
|
1290
|
+
playbackInfo: i,
|
|
1291
|
+
streamInfo: a
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
get mediaElement() {
|
|
1295
|
+
return this.#T();
|
|
1296
|
+
}
|
|
1297
|
+
async next(e) {
|
|
1298
|
+
this.debugLog("next", e);
|
|
1299
|
+
let t = this.#O(), r = this.#D();
|
|
1300
|
+
if (!t || !r) {
|
|
1301
|
+
console.warn("Inactive Shaka instance or media element not initialized.");
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
this.#m = !1, this.#h = e, this.preloadedStreamingSessionId = e.streamInfo.streamingSessionId;
|
|
1305
|
+
let i = this.#n === 1 ? this.#p : this.#f;
|
|
1306
|
+
if (i) {
|
|
1307
|
+
this.debugLog(`Finalizing pending session ${i} on inactive player before preload`);
|
|
1308
|
+
let e = this.playbackState, t = this.currentStreamingSessionId, n = this.currentTime;
|
|
1309
|
+
r.readyState > HTMLMediaElement.HAVE_NOTHING && (this.currentTime = r.currentTime), this.currentStreamingSessionId = i, this.finishCurrentMediaProduct("completed", !0), this.currentStreamingSessionId = t, this.playbackState = e, this.currentTime = n;
|
|
1310
|
+
}
|
|
1311
|
+
this.#n === 1 ? this.#p = e.streamInfo.streamingSessionId : this.#f = e.streamInfo.streamingSessionId;
|
|
1312
|
+
let a = y({
|
|
1313
|
+
assetPosition: 0,
|
|
1314
|
+
duration: e.streamInfo.duration || 0,
|
|
1315
|
+
playbackInfo: e.playbackInfo,
|
|
1316
|
+
streamInfo: e.streamInfo
|
|
1317
|
+
});
|
|
1318
|
+
n.saveMediaProductTransition(e.streamInfo.streamingSessionId, {
|
|
1319
|
+
mediaProduct: e.mediaProduct,
|
|
1320
|
+
playbackContext: a
|
|
1321
|
+
}), this.debugLog("Loading next track in inactive player");
|
|
1322
|
+
try {
|
|
1323
|
+
if (await t.load(e.streamInfo.streamUrl), this.debugLog("Next track loaded in inactive player"), r.volume = 0, r.currentTime !== 0 && (r.currentTime = 0), !await this.#z(r)) throw Error(`Preloaded media element did not become ready after Shaka load (readyState=${r.readyState})`);
|
|
1324
|
+
this.debugLog("Next track loaded and ready in inactive player"), this.playbackState === "IDLE" && (this.playbackState = "NOT_PLAYING"), (!r.duration || isNaN(r.duration)) && await new Promise((e) => {
|
|
1325
|
+
let t = () => {
|
|
1326
|
+
clearTimeout(n), e();
|
|
1327
|
+
}, n = setTimeout(() => {
|
|
1328
|
+
r.removeEventListener("durationchange", t), this.debugLog("next(): durationchange did not fire within 3000ms -- falling back to payload duration"), e();
|
|
1329
|
+
}, 3e3);
|
|
1330
|
+
r.addEventListener("durationchange", t, { once: !0 });
|
|
1331
|
+
});
|
|
1332
|
+
let i = y({
|
|
1333
|
+
assetPosition: 0,
|
|
1334
|
+
duration: r.duration || e.streamInfo.duration || 0,
|
|
1335
|
+
playbackInfo: e.playbackInfo,
|
|
1336
|
+
streamInfo: e.streamInfo
|
|
1337
|
+
});
|
|
1338
|
+
if (n.saveMediaProductTransition(e.streamInfo.streamingSessionId, {
|
|
1339
|
+
mediaProduct: e.mediaProduct,
|
|
1340
|
+
playbackContext: i
|
|
1341
|
+
}), this.debugLog("Media product transition saved for next track"), this.preloadedStreamingSessionId !== e.streamInfo.streamingSessionId) {
|
|
1342
|
+
this.debugLog(`next(): preload superseded during load (${e.streamInfo.streamingSessionId} -> ${this.preloadedStreamingSessionId ?? "none"}) -- not arming preload`);
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
this.#m = !0, this.#c = !1, this.#P();
|
|
1346
|
+
} catch (e) {
|
|
1347
|
+
console.error("Failed to load next track:", e);
|
|
1348
|
+
try {
|
|
1349
|
+
await t.unload(!0);
|
|
1350
|
+
} catch {}
|
|
1351
|
+
this.#m = !1, this.#h = null, this.cleanUpStoredPreloadInfo(), this.#n === 1 ? this.#p = void 0 : this.#f = void 0;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
pause() {
|
|
1355
|
+
this.debugLog("pause"), this.mediaElement && this.mediaElement.pause();
|
|
1356
|
+
}
|
|
1357
|
+
async play() {
|
|
1358
|
+
if (this.debugLog("play"), await this.maybeHardReload(), this.#y) {
|
|
1359
|
+
let e = this.#E()?.retryStreaming();
|
|
1360
|
+
if (this.#y = !e, !e) {
|
|
1361
|
+
this.playbackState = "NOT_PLAYING", this.finishCurrentMediaProduct("error");
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
if (this.playbackState === "IDLE") return this.debugLog("is IDLE, returning early"), Promise.resolve();
|
|
1366
|
+
let e = this.#T();
|
|
1367
|
+
e && "setSinkId" in e && await this.updateOutputDevice(), this.mediaProductStarted(this.currentStreamingSessionId), this.setStateToXIfNotYInZMs(1e3, "PLAYING", "STALLED"), await this.mediaElement?.play();
|
|
1368
|
+
let t = this.#E()?.getVariantTracks()?.find((e) => e.active);
|
|
1369
|
+
E(this.currentStreamingSessionId, t);
|
|
1370
|
+
}
|
|
1371
|
+
async playbackEngineEndedHandler(e) {
|
|
1372
|
+
if (this.isActivePlayer) {
|
|
1373
|
+
let { reason: t } = e.detail;
|
|
1374
|
+
t === "completed" && (this.debugLog("Track ended - checking for next item"), this.#h && this.#m && !this.#i ? (this.debugLog("Transition missed - swapping immediately"), await this.#R({ instant: !0 })) : this.#m && this.hasNextItem() ? (await this.skipToPreloadedMediaProduct(), await this.play()) : (a.preloadedStreamingSessionId ? this.debugLog(`Switching player from ${this.name} to ${a.preloadPlayer?.name}`) : this.debugLog("No next item queued."), this.playbackState = "NOT_PLAYING"));
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
get ready() {
|
|
1378
|
+
return this.#l;
|
|
1379
|
+
}
|
|
1380
|
+
async reset({ keepPreload: e } = { keepPreload: !1 }) {
|
|
1381
|
+
if (this.debugLog("reset"), this.#u.reset(), this.#c) return;
|
|
1382
|
+
let t = !e && !!this.preloadedStreamingSessionId;
|
|
1383
|
+
e || await this.unloadPreloadedMediaProduct({ initializeMediaSource: !0 }), this.playbackState !== "IDLE" && this.finishCurrentMediaProduct("skip"), this.playbackState = "IDLE", this.detachPlaybackEngineEndedHandler(), this.currentStreamingSessionId = void 0, e || (this.preloadedStreamingSessionId = void 0, this.#m = !1, this.#h = null), this.#i && (this.#b(), this.#i = !1, this.#s = void 0), this.#c = !0;
|
|
1384
|
+
let n = [], r = this.#E(), i = this.#O();
|
|
1385
|
+
r && n.push(r.unload(!0)), !e && !t && i && n.push(i.unload(!0)), e ? this.#n === 1 ? this.#f = void 0 : this.#p = void 0 : (u.volume = 1, l.volume = 0, this.#n = 1, this.#f = void 0, this.#p = void 0), await Promise.all(n);
|
|
1386
|
+
}
|
|
1387
|
+
seek(e) {
|
|
1388
|
+
this.debugLog("seek", e);
|
|
1389
|
+
let { mediaElement: t } = this;
|
|
1390
|
+
if (!t) {
|
|
1391
|
+
this.debugLog("No media element available for seeking");
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
this.seekStart(this.currentTime), this.currentTime = e;
|
|
1395
|
+
let n = e;
|
|
1396
|
+
return "fastSeek" in t ? t.fastSeek(n) : t.currentTime = n, new Promise((e) => {
|
|
1397
|
+
t.addEventListener("seeked", () => e(t.currentTime), { once: !0 });
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
async skipToPreloadedMediaProduct() {
|
|
1401
|
+
if (this.debugLog("skipToPreloadedMediaProduct", this.preloadedStreamingSessionId), !this.preloadedStreamingSessionId) return Promise.reject("Nothing preloaded.");
|
|
1402
|
+
let e = this.#h;
|
|
1403
|
+
if (!e) return Promise.reject("Preloaded payload not found.");
|
|
1404
|
+
let t = n.getMediaProductTransition(this.preloadedStreamingSessionId);
|
|
1405
|
+
t && (e.mediaProduct = t.mediaProduct);
|
|
1406
|
+
let r = this.#D(), i = this.#T();
|
|
1407
|
+
i.pause(), i.volume = 0, this.playbackState = "NOT_PLAYING", this.#b(), this.#m = !1, this.#h = null, this.#x(r, e);
|
|
1408
|
+
}
|
|
1409
|
+
togglePlayback() {
|
|
1410
|
+
this.debugLog("togglePlayback");
|
|
1411
|
+
let { mediaElement: e } = this;
|
|
1412
|
+
e && (e.paused ? e.play().catch(console.error) : e.pause());
|
|
1413
|
+
}
|
|
1414
|
+
async unloadPreloadedMediaProduct({ initializeMediaSource: e = !1 } = {}) {
|
|
1415
|
+
if (this.debugLog("unloadPreloadedMediaProduct", this.preloadedStreamingSessionId), !this.preloadedStreamingSessionId) return;
|
|
1416
|
+
this.cleanUpStoredPreloadInfo(), this.#b(), this.#h = null, this.#m = !1;
|
|
1417
|
+
let t = this.#O(), n = this.#D();
|
|
1418
|
+
if (t) {
|
|
1419
|
+
try {
|
|
1420
|
+
await t.unload(e);
|
|
1421
|
+
} catch (e) {
|
|
1422
|
+
this.debugLog("inactivePlayer.unload() rejected (ignored)", e);
|
|
1423
|
+
}
|
|
1424
|
+
n.volume = 0;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
async updateOutputDevice() {
|
|
1428
|
+
if (!z) return;
|
|
1429
|
+
if (z && !z.activeDevice || !o("outputDevicesEnabled")) return Promise.resolve();
|
|
1430
|
+
let t = z.activeDevice.webDeviceId;
|
|
1431
|
+
if (t && typeof u.setSinkId == "function") {
|
|
1432
|
+
this.outputDeviceType = z.activeDevice.type;
|
|
1433
|
+
try {
|
|
1434
|
+
await Promise.all([u.setSinkId(t), l.setSinkId(t)]), e.dispatchEvent(_(z.activeDevice.id));
|
|
1435
|
+
} catch (e) {
|
|
1436
|
+
console.error(e);
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
get volume() {
|
|
1441
|
+
return o("desiredVolumeLevel");
|
|
1442
|
+
}
|
|
1443
|
+
set volume(e) {
|
|
1444
|
+
this.debugLog("Setting volume to", e), this.mediaElement && (this.mediaElement.volume = e);
|
|
1445
|
+
}
|
|
1446
|
+
};
|
|
1447
|
+
//#endregion
|
|
1448
|
+
export { H as default };
|