@tidal-music/player-web-components 0.1.1 → 0.1.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/{basePlayer-a-avZASH-Ux-6s9Ex.js → basePlayer-BcooVl9P-WesO1_17.js} +188 -178
- package/dist/{browserPlayer-oNOpDVm6-UW0N6pFH.js → browserPlayer-B1V50MdI-D65N_aRN.js} +67 -74
- package/dist/{index-tM9JvbA8.js → index-DbGwqQeZ.js} +563 -498
- package/dist/index.js +4 -4
- package/dist/{nativePlayer-U375Dfm5-hUK7oXzY.js → nativePlayer-DdpXKE9r-B14o92dS.js} +7 -7
- package/dist/{output-devices-NXuo75MQ-_vYYuqUm.js → output-devices-BhcWYG6e-l4DCXneM.js} +16 -16
- package/dist/shakaPlayer-Brgd4rob-DJ5uJTjr.js +26243 -0
- package/dist/{worker-qh_9Fyf6-Li0uY2-a.js → worker-DrRlSx4a-BTanKBsS.js} +13 -13
- package/package.json +16 -19
- package/dist/shakaPlayer-izGFLVQr--XUsjgT2.js +0 -24740
- /package/dist/{_commonjsHelpers-f3sTPFkQ-YKQV-mq1.js → _commonjsHelpers-DaMA6jEr-DtILRGNx.js} +0 -0
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function L(
|
|
1
|
+
import { N as I, c as T, b as o, l as d, g as n, T as r, S as m, A as h, G as v, s as p, d as b, f as k, z as c, _ as f, V as A, p as g, h as P, D as y } from "./index-DbGwqQeZ.js";
|
|
2
|
+
function L(i) {
|
|
3
3
|
return g(
|
|
4
4
|
() => P(y, {
|
|
5
5
|
type: "play_log",
|
|
6
|
-
...
|
|
6
|
+
...i
|
|
7
7
|
})
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function x(i, e) {
|
|
11
11
|
return new CustomEvent(
|
|
12
12
|
"media-product-transition",
|
|
13
13
|
{
|
|
14
14
|
detail: {
|
|
15
|
-
mediaProduct:
|
|
16
|
-
playbackContext:
|
|
15
|
+
mediaProduct: i,
|
|
16
|
+
playbackContext: e
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
const G = ({
|
|
22
|
-
assetPosition:
|
|
23
|
-
duration:
|
|
24
|
-
playbackInfo:
|
|
22
|
+
assetPosition: i,
|
|
23
|
+
duration: e,
|
|
24
|
+
playbackInfo: t,
|
|
25
25
|
streamInfo: a
|
|
26
26
|
}) => ({
|
|
27
|
-
actualAssetPresentation:
|
|
28
|
-
actualAudioMode: "audioMode" in
|
|
29
|
-
actualAudioQuality: "audioQuality" in
|
|
30
|
-
actualDuration:
|
|
27
|
+
actualAssetPresentation: t.assetPresentation,
|
|
28
|
+
actualAudioMode: "audioMode" in t ? t.audioMode : null,
|
|
29
|
+
actualAudioQuality: "audioQuality" in t ? t.audioQuality : null,
|
|
30
|
+
actualDuration: e,
|
|
31
31
|
actualProductId: String(
|
|
32
|
-
"videoId" in
|
|
32
|
+
"videoId" in t ? t.videoId : t.trackId
|
|
33
33
|
),
|
|
34
|
-
actualStreamType: "streamType" in
|
|
35
|
-
actualVideoQuality: "videoQuality" in
|
|
36
|
-
assetPosition:
|
|
34
|
+
actualStreamType: "streamType" in t ? t.streamType : null,
|
|
35
|
+
actualVideoQuality: "videoQuality" in t ? t.videoQuality : null,
|
|
36
|
+
assetPosition: i,
|
|
37
37
|
bitDepth: a.bitDepth ?? null,
|
|
38
38
|
codec: a.codec ?? null,
|
|
39
39
|
playbackSessionId: a.streamingSessionId,
|
|
40
40
|
sampleRate: a.sampleRate ?? null
|
|
41
41
|
});
|
|
42
|
-
function M(
|
|
42
|
+
function M(i, e) {
|
|
43
43
|
return new CustomEvent("ended", {
|
|
44
44
|
detail: {
|
|
45
|
-
mediaProduct:
|
|
46
|
-
reason:
|
|
45
|
+
mediaProduct: e,
|
|
46
|
+
reason: i
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
function E(
|
|
50
|
+
function E(i) {
|
|
51
51
|
return new CustomEvent("playback-state-change", {
|
|
52
52
|
detail: {
|
|
53
|
-
state:
|
|
53
|
+
state: i
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function _() {
|
|
58
58
|
return new CustomEvent("preload-request");
|
|
59
59
|
}
|
|
60
|
-
const
|
|
60
|
+
const w = {
|
|
61
61
|
playback: {
|
|
62
62
|
durationMS: 0,
|
|
63
63
|
id: "",
|
|
@@ -68,26 +68,26 @@ const _ = {
|
|
|
68
68
|
},
|
|
69
69
|
type: "TRACK"
|
|
70
70
|
}
|
|
71
|
-
},
|
|
71
|
+
}, R = await I(
|
|
72
72
|
"progress",
|
|
73
|
-
|
|
73
|
+
w
|
|
74
74
|
);
|
|
75
|
-
function C(
|
|
76
|
-
return
|
|
75
|
+
function C(i) {
|
|
76
|
+
return R(i);
|
|
77
77
|
}
|
|
78
|
-
function D(
|
|
78
|
+
function D(i) {
|
|
79
79
|
return g(
|
|
80
80
|
() => P(y, {
|
|
81
|
-
...
|
|
81
|
+
...i,
|
|
82
82
|
type: "playback"
|
|
83
83
|
})
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
|
-
function S(
|
|
87
|
-
return Math.min(Math.pow(10, (4 +
|
|
86
|
+
function S(i) {
|
|
87
|
+
return Math.min(Math.pow(10, (4 + i) / 20), 1 / 1);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
switch (
|
|
89
|
+
function N(i) {
|
|
90
|
+
switch (i) {
|
|
91
91
|
case "completed":
|
|
92
92
|
return "COMPLETE";
|
|
93
93
|
case "error":
|
|
@@ -98,9 +98,9 @@ function x(s) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
class Y {
|
|
101
|
-
#t;
|
|
102
|
-
#i;
|
|
103
101
|
#e;
|
|
102
|
+
#i;
|
|
103
|
+
#t;
|
|
104
104
|
#r = void 0;
|
|
105
105
|
#n;
|
|
106
106
|
#s = "IDLE";
|
|
@@ -116,7 +116,7 @@ class Y {
|
|
|
116
116
|
// Implements
|
|
117
117
|
#c() {
|
|
118
118
|
this.duration && Math.abs(this.#i - this.duration) <= 30 && // A false check, rather than undefined, ensures a media product transition hs been made.
|
|
119
|
-
this.#r === !1 && (this.#r = !0,
|
|
119
|
+
this.#r === !1 && (this.#r = !0, o.dispatchEvent(_()));
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* This method should be call whenever a playback ends, for **whatever** reason.
|
|
@@ -124,37 +124,38 @@ class Y {
|
|
|
124
124
|
* ended, completed, skip, reset etc
|
|
125
125
|
*/
|
|
126
126
|
#u({
|
|
127
|
-
endAssetPosition:
|
|
128
|
-
endReason:
|
|
127
|
+
endAssetPosition: e,
|
|
128
|
+
endReason: t,
|
|
129
129
|
streamingSessionId: a
|
|
130
130
|
}) {
|
|
131
|
-
this.debugLog("mediaProductEnded"),
|
|
131
|
+
this.debugLog("mediaProductEnded"), d.preloadedStreamingSessionId && performance.mark(
|
|
132
132
|
"streaming_metrics:playback_statistics:idealStartTimestamp",
|
|
133
133
|
{
|
|
134
|
-
detail:
|
|
134
|
+
detail: d.preloadedStreamingSessionId,
|
|
135
|
+
startTime: n.now()
|
|
135
136
|
}
|
|
136
137
|
);
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
M(
|
|
138
|
+
const s = r.getMediaProductTransition(a);
|
|
139
|
+
s && o.dispatchEvent(
|
|
140
|
+
M(t, s.mediaProduct)
|
|
140
141
|
), this.eventTrackingStreamingEnded(a, {
|
|
141
|
-
endAssetPosition:
|
|
142
|
-
endReason:
|
|
142
|
+
endAssetPosition: e,
|
|
143
|
+
endReason: t
|
|
143
144
|
}), this.reportPlaybackProgress(a), r.deleteSession(a), this.#a.delete(a), this.currentStreamingSessionId === a && (this.currentStreamingSessionId = void 0), this.updateVolumeLevelForNextProduct();
|
|
144
145
|
}
|
|
145
|
-
adjustedVolume(
|
|
146
|
-
const
|
|
147
|
-
let
|
|
148
|
-
return a === "ALBUM" &&
|
|
146
|
+
adjustedVolume(e) {
|
|
147
|
+
const t = m("desiredVolumeLevel"), a = m("loudnessNormalizationMode");
|
|
148
|
+
let s = t;
|
|
149
|
+
return a === "ALBUM" && e.albumReplayGain && (s *= S(e.albumReplayGain)), a === "TRACK" && e.trackReplayGain && (s *= S(e.trackReplayGain)), this.debugLog(
|
|
149
150
|
"adjustedVolume",
|
|
150
|
-
`Volume adjusted from ${
|
|
151
|
-
), parseFloat(
|
|
151
|
+
`Volume adjusted from ${t} to ${s}`
|
|
152
|
+
), parseFloat(s.toFixed(2));
|
|
152
153
|
}
|
|
153
154
|
// Implements
|
|
154
155
|
attachPlaybackEngineEndedHandler() {
|
|
155
|
-
this.#
|
|
156
|
+
this.#t || (this.#t = this.playbackEngineEndedHandler.bind(this), o.addEventListener(
|
|
156
157
|
"ended",
|
|
157
|
-
this.#
|
|
158
|
+
this.#t
|
|
158
159
|
));
|
|
159
160
|
}
|
|
160
161
|
/**
|
|
@@ -166,72 +167,73 @@ class Y {
|
|
|
166
167
|
this.preloadedStreamingSessionId && this.preloadedStreamingSessionId !== this.currentStreamingSessionId && (r.deleteSession(this.preloadedStreamingSessionId), this.preloadedStreamingSessionId = void 0);
|
|
167
168
|
}
|
|
168
169
|
// Implements
|
|
169
|
-
debugLog(...
|
|
170
|
+
debugLog(...e) {
|
|
170
171
|
document.location.href.includes("localhost") && document.location.hash.includes("debug") && console.debug(
|
|
171
|
-
`[%cPlayerSDK${this.name ? `%c${
|
|
172
|
+
`[%cPlayerSDK${this.name ? `%c${d.activePlayer?.name === this.name ? "⚯" : "⚮"}%c` + this.name : ""}${this.#e ? "%c::%c" + this.#e?.split("-").pop() : ""}%c]`,
|
|
172
173
|
"color:#00d6ff",
|
|
173
174
|
...this.name ? [
|
|
174
175
|
"color:inherit",
|
|
175
176
|
"color:#b7fa34"
|
|
176
177
|
// green foreground
|
|
177
178
|
] : [],
|
|
178
|
-
...this.#
|
|
179
|
+
...this.#e ? [
|
|
179
180
|
"color:inherit",
|
|
180
181
|
"color:#d947ff"
|
|
181
182
|
// purple foreground
|
|
182
183
|
] : [],
|
|
183
184
|
"color:inherit",
|
|
184
|
-
...
|
|
185
|
+
...e
|
|
185
186
|
);
|
|
186
187
|
}
|
|
187
188
|
detachPlaybackEngineEndedHandler() {
|
|
188
|
-
this.#
|
|
189
|
+
this.#t && (o.removeEventListener(
|
|
189
190
|
"ended",
|
|
190
|
-
this.#
|
|
191
|
-
), this.#
|
|
191
|
+
this.#t
|
|
192
|
+
), this.#t = void 0);
|
|
192
193
|
}
|
|
193
194
|
/**
|
|
194
195
|
* Commits play_log playbackSession and streaming_metrics playbackStatistics.
|
|
195
196
|
*
|
|
196
197
|
* @param streamingSessionId
|
|
197
198
|
*/
|
|
198
|
-
eventTrackingStreamingEnded(
|
|
199
|
-
endAssetPosition:
|
|
199
|
+
eventTrackingStreamingEnded(e, {
|
|
200
|
+
endAssetPosition: t,
|
|
200
201
|
endReason: a
|
|
201
202
|
}) {
|
|
202
|
-
const
|
|
203
|
+
const s = n.now();
|
|
203
204
|
L({
|
|
204
205
|
events: [
|
|
205
206
|
h({
|
|
206
|
-
endAssetPosition:
|
|
207
|
-
endTimestamp:
|
|
208
|
-
streamingSessionId:
|
|
207
|
+
endAssetPosition: t,
|
|
208
|
+
endTimestamp: s,
|
|
209
|
+
streamingSessionId: e
|
|
209
210
|
})
|
|
210
211
|
]
|
|
211
212
|
}).catch(console.error), v({
|
|
212
213
|
events: [
|
|
213
214
|
p({
|
|
214
|
-
endReason:
|
|
215
|
-
endTimestamp:
|
|
216
|
-
streamingSessionId:
|
|
215
|
+
endReason: N(a),
|
|
216
|
+
endTimestamp: s,
|
|
217
|
+
streamingSessionId: e
|
|
217
218
|
}),
|
|
218
219
|
b({
|
|
219
|
-
streamingSessionId:
|
|
220
|
-
timestamp:
|
|
220
|
+
streamingSessionId: e,
|
|
221
|
+
timestamp: s
|
|
221
222
|
})
|
|
222
223
|
]
|
|
223
224
|
}).catch(console.error);
|
|
224
225
|
}
|
|
225
|
-
eventTrackingStreamingStarted(
|
|
226
|
-
if (!
|
|
226
|
+
eventTrackingStreamingStarted(e) {
|
|
227
|
+
if (!e)
|
|
227
228
|
return;
|
|
228
229
|
performance.mark(
|
|
229
230
|
"streaming_metrics:playback_statistics:actualStartTimestamp",
|
|
230
231
|
{
|
|
231
|
-
detail:
|
|
232
|
+
detail: e,
|
|
233
|
+
startTime: n.now()
|
|
232
234
|
}
|
|
233
235
|
), performance.measure("idealStartTimestamp -> actualStartTimestamp", {
|
|
234
|
-
detail:
|
|
236
|
+
detail: e,
|
|
235
237
|
end: "streaming_metrics:playback_statistics:actualStartTimestamp",
|
|
236
238
|
start: "streaming_metrics:playback_statistics:idealStartTimestamp"
|
|
237
239
|
});
|
|
@@ -239,14 +241,14 @@ class Y {
|
|
|
239
241
|
p({
|
|
240
242
|
actualStartTimestamp: n.timestamp(
|
|
241
243
|
"streaming_metrics:playback_statistics:actualStartTimestamp",
|
|
242
|
-
|
|
244
|
+
e
|
|
243
245
|
),
|
|
244
246
|
idealStartTimestamp: n.timestamp(
|
|
245
247
|
"streaming_metrics:playback_statistics:idealStartTimestamp",
|
|
246
|
-
|
|
248
|
+
e
|
|
247
249
|
),
|
|
248
250
|
outputDevice: this.#n,
|
|
249
|
-
streamingSessionId:
|
|
251
|
+
streamingSessionId: e
|
|
250
252
|
});
|
|
251
253
|
} catch (l) {
|
|
252
254
|
console.error(
|
|
@@ -260,38 +262,40 @@ class Y {
|
|
|
260
262
|
"streaming_metrics:playback_statistics:idealStartTimestamp"
|
|
261
263
|
);
|
|
262
264
|
}
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
265
|
-
this.#a.has(
|
|
266
|
-
`A media product transition for streaming session #${
|
|
267
|
-
) : (r.deleteStreamInfo(
|
|
268
|
-
`Streaming session #${
|
|
265
|
+
const t = r.getMediaProductTransition(e);
|
|
266
|
+
if (!t) {
|
|
267
|
+
this.#a.has(e) ? console.error(
|
|
268
|
+
`A media product transition for streaming session #${e} has not been saved and could thus not be found for play log reporting.`
|
|
269
|
+
) : (r.deleteStreamInfo(e), console.warn(
|
|
270
|
+
`Streaming session #${e} has been discarded due to a new load. This could mean you have a bug in your code where you call load on Player more than once time in a very short time frame.`
|
|
269
271
|
));
|
|
270
272
|
return;
|
|
271
273
|
}
|
|
272
|
-
const { mediaProduct: a, playbackContext:
|
|
274
|
+
const { mediaProduct: a, playbackContext: s } = t, u = n.now();
|
|
273
275
|
h({
|
|
274
|
-
actualAssetPresentation:
|
|
275
|
-
actualAudioMode: "actualAudioMode" in
|
|
276
|
-
actualProductId:
|
|
277
|
-
actualQuality:
|
|
278
|
-
isPostPaywall:
|
|
279
|
-
playbackSessionId:
|
|
276
|
+
actualAssetPresentation: s.actualAssetPresentation,
|
|
277
|
+
actualAudioMode: "actualAudioMode" in s ? s.actualAudioMode : null,
|
|
278
|
+
actualProductId: s.actualProductId,
|
|
279
|
+
actualQuality: s.actualAudioQuality || s.actualVideoQuality,
|
|
280
|
+
isPostPaywall: s.actualAssetPresentation === "FULL",
|
|
281
|
+
playbackSessionId: e,
|
|
280
282
|
productType: a.productType === "track" ? "TRACK" : "VIDEO",
|
|
281
283
|
requestedProductId: a.productId,
|
|
282
284
|
sourceId: a.sourceId,
|
|
283
285
|
sourceType: a.sourceType,
|
|
284
286
|
startAssetPosition: this.startAssetPosition,
|
|
285
287
|
startTimestamp: u,
|
|
286
|
-
streamingSessionId:
|
|
288
|
+
streamingSessionId: e
|
|
287
289
|
});
|
|
288
290
|
}
|
|
289
|
-
finishCurrentMediaProduct(
|
|
290
|
-
|
|
291
|
-
|
|
291
|
+
finishCurrentMediaProduct(e) {
|
|
292
|
+
if (!this.hasStarted())
|
|
293
|
+
return;
|
|
294
|
+
const t = this.#e, a = t ? r.hasStreamInfo(t) : !1;
|
|
295
|
+
this.preloadedStreamingSessionId || (this.playbackState = "IDLE"), t && a && this.#u({
|
|
292
296
|
endAssetPosition: this.currentTime,
|
|
293
|
-
endReason:
|
|
294
|
-
streamingSessionId:
|
|
297
|
+
endReason: e,
|
|
298
|
+
streamingSessionId: t
|
|
295
299
|
});
|
|
296
300
|
}
|
|
297
301
|
getPosition() {
|
|
@@ -300,8 +304,8 @@ class Y {
|
|
|
300
304
|
/**
|
|
301
305
|
* Refetches playbackinfo.
|
|
302
306
|
*/
|
|
303
|
-
async hardReload(
|
|
304
|
-
return k(
|
|
307
|
+
async hardReload(e, t) {
|
|
308
|
+
return this.currentStreamingSessionId && this.finishCurrentMediaProduct("skip"), k(e, t);
|
|
305
309
|
}
|
|
306
310
|
hasNextItem() {
|
|
307
311
|
return this.preloadedStreamingSessionId && r.hasMediaProductTransition(
|
|
@@ -312,7 +316,7 @@ class Y {
|
|
|
312
316
|
return this.currentStreamingSessionId && this.#a.has(this.currentStreamingSessionId);
|
|
313
317
|
}
|
|
314
318
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
315
|
-
load(
|
|
319
|
+
load(e, t) {
|
|
316
320
|
return Promise.resolve();
|
|
317
321
|
}
|
|
318
322
|
/**
|
|
@@ -321,8 +325,8 @@ class Y {
|
|
|
321
325
|
* @returns {boolean} True if hard reloaded, else false.
|
|
322
326
|
*/
|
|
323
327
|
async maybeHardReload() {
|
|
324
|
-
const
|
|
325
|
-
return this.currentMediaProduct &&
|
|
328
|
+
const e = this.prefetched || this.expired;
|
|
329
|
+
return this.currentMediaProduct && e ? (await this.hardReload(this.currentMediaProduct, 0), !0) : !1;
|
|
326
330
|
}
|
|
327
331
|
/**
|
|
328
332
|
* This method should be call whenever a playback starts, for **whatever** reason.
|
|
@@ -331,11 +335,11 @@ class Y {
|
|
|
331
335
|
*
|
|
332
336
|
* @param streamingSessionId
|
|
333
337
|
*/
|
|
334
|
-
mediaProductStarted(
|
|
335
|
-
!
|
|
338
|
+
mediaProductStarted(e) {
|
|
339
|
+
!e || this.#a.has(e) || (this.debugLog("mediaProductStarted"), this.eventTrackingStreamingStarted(e), this.#a.set(e, !0), this.updateVolumeLevel(), this.#r = !1, this.preloadedStreamingSessionId = void 0, this.unloadPreloadedMediaProduct().catch(console.error), this.attachPlaybackEngineEndedHandler());
|
|
336
340
|
}
|
|
337
341
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
338
|
-
next(
|
|
342
|
+
next(e) {
|
|
339
343
|
return Promise.resolve();
|
|
340
344
|
}
|
|
341
345
|
/**
|
|
@@ -346,22 +350,22 @@ class Y {
|
|
|
346
350
|
* @param streamingSessionId
|
|
347
351
|
* @param partialMediaProduct
|
|
348
352
|
*/
|
|
349
|
-
overwriteMediaProduct(
|
|
350
|
-
const a = r.getMediaProductTransition(
|
|
353
|
+
overwriteMediaProduct(e, t) {
|
|
354
|
+
const a = r.getMediaProductTransition(e);
|
|
351
355
|
if (a) {
|
|
352
|
-
r.deleteMediaProductTransition(
|
|
353
|
-
const
|
|
356
|
+
r.deleteMediaProductTransition(e);
|
|
357
|
+
const s = {
|
|
354
358
|
mediaProduct: {
|
|
355
359
|
...a.mediaProduct,
|
|
356
|
-
...
|
|
360
|
+
...t
|
|
357
361
|
},
|
|
358
362
|
playbackContext: {
|
|
359
363
|
...a.playbackContext
|
|
360
364
|
}
|
|
361
365
|
};
|
|
362
366
|
r.saveMediaProductTransition(
|
|
363
|
-
|
|
364
|
-
|
|
367
|
+
e,
|
|
368
|
+
s
|
|
365
369
|
);
|
|
366
370
|
}
|
|
367
371
|
}
|
|
@@ -371,19 +375,19 @@ class Y {
|
|
|
371
375
|
return Promise.resolve();
|
|
372
376
|
}
|
|
373
377
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
374
|
-
playbackEngineEndedHandler(
|
|
378
|
+
playbackEngineEndedHandler(e) {
|
|
375
379
|
return Promise.resolve();
|
|
376
380
|
}
|
|
377
|
-
reportPlaybackProgress(
|
|
378
|
-
const
|
|
379
|
-
if (!
|
|
381
|
+
reportPlaybackProgress(e) {
|
|
382
|
+
const t = r.getMediaProductTransition(e);
|
|
383
|
+
if (!t)
|
|
380
384
|
return;
|
|
381
|
-
const { mediaProduct: a, playbackContext:
|
|
382
|
-
this.#
|
|
385
|
+
const { mediaProduct: a, playbackContext: s } = t;
|
|
386
|
+
this.#e && D({
|
|
383
387
|
events: [
|
|
384
388
|
C({
|
|
385
389
|
playback: {
|
|
386
|
-
durationMS: Math.floor(
|
|
390
|
+
durationMS: Math.floor(s.actualDuration * 1e3),
|
|
387
391
|
id: a.productId,
|
|
388
392
|
playedMS: Math.floor(this.currentTime * 1e3),
|
|
389
393
|
source: {
|
|
@@ -392,42 +396,59 @@ class Y {
|
|
|
392
396
|
},
|
|
393
397
|
type: a.productType === "track" ? "TRACK" : "VIDEO"
|
|
394
398
|
},
|
|
395
|
-
streamingSessionId: this.#
|
|
399
|
+
streamingSessionId: this.#e
|
|
396
400
|
})
|
|
397
401
|
]
|
|
398
402
|
}).catch(console.error);
|
|
399
403
|
}
|
|
400
404
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
401
|
-
reset(
|
|
405
|
+
reset(e) {
|
|
402
406
|
return Promise.resolve();
|
|
403
407
|
}
|
|
404
408
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
405
|
-
seek(
|
|
409
|
+
seek(e) {
|
|
406
410
|
}
|
|
407
411
|
/**
|
|
408
412
|
* Handle play log reporting for seeking.
|
|
409
413
|
* Seek start should log a PLAYBACK_START action if playing post seek.
|
|
410
414
|
*/
|
|
411
|
-
seekEnd() {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
seekEnd(e) {
|
|
416
|
+
const t = this.currentStreamingSessionId;
|
|
417
|
+
if (t) {
|
|
418
|
+
const a = () => c(t, {
|
|
419
|
+
actionType: "PLAYBACK_START",
|
|
420
|
+
assetPosition: e,
|
|
421
|
+
timestamp: n.now()
|
|
422
|
+
});
|
|
423
|
+
if (this.playbackState === "PLAYING")
|
|
424
|
+
a().catch(console.error);
|
|
425
|
+
else {
|
|
426
|
+
const s = () => {
|
|
427
|
+
this.playbackState === "PLAYING" && (a().catch(console.error), o.removeEventListener(
|
|
428
|
+
"playback-state-change",
|
|
429
|
+
s
|
|
430
|
+
));
|
|
431
|
+
};
|
|
432
|
+
o.addEventListener(
|
|
433
|
+
"playback-state-change",
|
|
434
|
+
s
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
417
438
|
}
|
|
418
439
|
/**
|
|
419
440
|
* Handle play log reporting for seeking.
|
|
420
441
|
* Seek start should log a PLAYBACK_STOP action.
|
|
421
442
|
*/
|
|
422
|
-
seekStart() {
|
|
443
|
+
seekStart(e) {
|
|
423
444
|
this.currentStreamingSessionId && c(this.currentStreamingSessionId, {
|
|
424
445
|
actionType: "PLAYBACK_STOP",
|
|
425
|
-
assetPosition:
|
|
446
|
+
assetPosition: e,
|
|
426
447
|
timestamp: n.now()
|
|
427
448
|
});
|
|
428
449
|
}
|
|
429
|
-
async setStateToXIfNotYInZMs(
|
|
430
|
-
await f(
|
|
450
|
+
async setStateToXIfNotYInZMs(e, t, a) {
|
|
451
|
+
await f(e), this.playbackState !== t && (this.playbackState = a);
|
|
431
452
|
}
|
|
432
453
|
skipToPreloadedMediaProduct() {
|
|
433
454
|
return Promise.resolve();
|
|
@@ -444,52 +465,52 @@ class Y {
|
|
|
444
465
|
* enabled.
|
|
445
466
|
*/
|
|
446
467
|
updateVolumeLevel() {
|
|
447
|
-
const
|
|
468
|
+
const e = r.getStreamInfo(
|
|
448
469
|
this.currentStreamingSessionId
|
|
449
470
|
);
|
|
450
|
-
|
|
471
|
+
e && (this.volume = this.adjustedVolume(e));
|
|
451
472
|
}
|
|
452
473
|
/**
|
|
453
474
|
* Adjusts the volume for the next track.
|
|
454
475
|
* Can be called on product ended to have the level ready.
|
|
455
476
|
*/
|
|
456
477
|
updateVolumeLevelForNextProduct() {
|
|
457
|
-
const
|
|
478
|
+
const e = r.getStreamInfo(
|
|
458
479
|
this.preloadedStreamingSessionId
|
|
459
480
|
);
|
|
460
|
-
|
|
481
|
+
e && (this.volume = this.adjustedVolume(e));
|
|
461
482
|
}
|
|
462
483
|
get currentMediaProduct() {
|
|
463
484
|
return r.getMediaProductTransition(
|
|
464
485
|
this.currentStreamingSessionId
|
|
465
486
|
)?.mediaProduct ?? null;
|
|
466
487
|
}
|
|
467
|
-
set currentStreamingSessionId(
|
|
468
|
-
this.#
|
|
488
|
+
set currentStreamingSessionId(e) {
|
|
489
|
+
this.#e = e;
|
|
469
490
|
}
|
|
470
491
|
get currentStreamingSessionId() {
|
|
471
|
-
return this.#
|
|
492
|
+
return this.#e;
|
|
472
493
|
}
|
|
473
|
-
set currentTime(
|
|
474
|
-
this.#i =
|
|
494
|
+
set currentTime(e) {
|
|
495
|
+
this.#i = e, this.#c();
|
|
475
496
|
}
|
|
476
497
|
get currentTime() {
|
|
477
498
|
return this.#i;
|
|
478
499
|
}
|
|
479
500
|
get duration() {
|
|
480
|
-
const
|
|
501
|
+
const e = r.getMediaProductTransition(
|
|
481
502
|
this.currentStreamingSessionId
|
|
482
503
|
);
|
|
483
|
-
return
|
|
504
|
+
return e ? e.playbackContext.actualDuration : null;
|
|
484
505
|
}
|
|
485
506
|
get expired() {
|
|
486
|
-
const
|
|
507
|
+
const e = r.getStreamInfo(
|
|
487
508
|
this.currentStreamingSessionId
|
|
488
509
|
);
|
|
489
|
-
return
|
|
510
|
+
return e ? e.expires <= Date.now() : !1;
|
|
490
511
|
}
|
|
491
512
|
get isActivePlayer() {
|
|
492
|
-
return
|
|
513
|
+
return d.activePlayer && this.name === d.activePlayer.name;
|
|
493
514
|
}
|
|
494
515
|
get nextItem() {
|
|
495
516
|
if (this.preloadedStreamingSessionId)
|
|
@@ -498,32 +519,21 @@ class Y {
|
|
|
498
519
|
);
|
|
499
520
|
}
|
|
500
521
|
// eslint-disable-next-line accessor-pairs
|
|
501
|
-
set outputDeviceType(
|
|
502
|
-
this.#n =
|
|
522
|
+
set outputDeviceType(e) {
|
|
523
|
+
this.#n = e ? A(e) : void 0;
|
|
503
524
|
}
|
|
504
|
-
set playbackState(
|
|
505
|
-
const
|
|
506
|
-
if (
|
|
525
|
+
set playbackState(e) {
|
|
526
|
+
const t = this.#s;
|
|
527
|
+
if (t === e || !this.currentStreamingSessionId)
|
|
507
528
|
return;
|
|
508
|
-
const a = (u, l) =>
|
|
529
|
+
const a = (u, l) => t === u && l === e;
|
|
509
530
|
switch (!0) {
|
|
510
531
|
case a("NOT_PLAYING", "STALLED"):
|
|
511
532
|
case a("IDLE", "STALLED"):
|
|
512
533
|
return;
|
|
513
534
|
case a("PLAYING", "NOT_PLAYING"):
|
|
514
535
|
case a("PLAYING", "IDLE"): {
|
|
515
|
-
this.reportPlaybackProgress(this.currentStreamingSessionId),
|
|
516
|
-
"PS",
|
|
517
|
-
{
|
|
518
|
-
from: e,
|
|
519
|
-
to: t
|
|
520
|
-
},
|
|
521
|
-
{
|
|
522
|
-
currentTime: this.#i,
|
|
523
|
-
doIt: this.duration && this.currentTime < this.duration,
|
|
524
|
-
duration: this.duration
|
|
525
|
-
}
|
|
526
|
-
), this.duration && this.currentTime < this.duration && c(this.currentStreamingSessionId, {
|
|
536
|
+
this.reportPlaybackProgress(this.currentStreamingSessionId), this.duration && this.currentTime < this.duration && c(this.currentStreamingSessionId, {
|
|
527
537
|
actionType: "PLAYBACK_STOP",
|
|
528
538
|
assetPosition: this.currentTime,
|
|
529
539
|
timestamp: n.now()
|
|
@@ -540,21 +550,21 @@ class Y {
|
|
|
540
550
|
break;
|
|
541
551
|
}
|
|
542
552
|
}
|
|
543
|
-
this.#s =
|
|
544
|
-
const
|
|
545
|
-
(this.isActivePlayer ||
|
|
553
|
+
this.#s = e, this.debugLog(`playbackState: ${e}`);
|
|
554
|
+
const s = d.activePlayer === void 0;
|
|
555
|
+
(this.isActivePlayer || s) && o.dispatchEvent(E(this.#s));
|
|
546
556
|
}
|
|
547
557
|
get playbackState() {
|
|
548
558
|
return this.#s;
|
|
549
559
|
}
|
|
550
560
|
get prefetched() {
|
|
551
|
-
const
|
|
561
|
+
const e = r.getStreamInfo(
|
|
552
562
|
this.currentStreamingSessionId
|
|
553
563
|
);
|
|
554
|
-
return
|
|
564
|
+
return e && e.prefetched;
|
|
555
565
|
}
|
|
556
|
-
set preloadedStreamingSessionId(
|
|
557
|
-
this.#o =
|
|
566
|
+
set preloadedStreamingSessionId(e) {
|
|
567
|
+
this.#o = e;
|
|
558
568
|
}
|
|
559
569
|
get preloadedStreamingSessionId() {
|
|
560
570
|
return this.#o;
|
|
@@ -562,18 +572,18 @@ class Y {
|
|
|
562
572
|
get startAssetPosition() {
|
|
563
573
|
return this.#d;
|
|
564
574
|
}
|
|
565
|
-
set startAssetPosition(
|
|
566
|
-
this.#d =
|
|
575
|
+
set startAssetPosition(e) {
|
|
576
|
+
this.#d = e;
|
|
567
577
|
}
|
|
568
578
|
// eslint-disable-next-line @typescript-eslint/class-literal-property-style
|
|
569
579
|
get volume() {
|
|
570
580
|
return 1;
|
|
571
581
|
}
|
|
572
|
-
set volume(
|
|
582
|
+
set volume(e) {
|
|
573
583
|
}
|
|
574
584
|
}
|
|
575
585
|
export {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
Y
|
|
586
|
+
Y as G,
|
|
587
|
+
x as V,
|
|
588
|
+
G as Y
|
|
579
589
|
};
|