@tidal-music/player-web-components 0.2.1 → 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-Rqi9yRuo-4eKn-Akv.js +0 -528
- package/dist/browserPlayer-CXURpXdL-DjOb2ySS.js +0 -259
- package/dist/index-DHnVYeec.js +0 -3391
- package/dist/index.d.ts +0 -24
- package/dist/nativePlayer-b92CavhC-CABrQPGS.js +0 -323
- package/dist/output-devices-CUurcKto-C_F_9nLk.js +0 -224
- package/dist/shakaPlayer-D0NCOzx8-Dd1YFBoR.js +0 -24403
package/dist/index.js
CHANGED
|
@@ -1,11 +1,364 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { a as e, d as t, i as n, r, t as i } from "./state-B888KJag-C7pa4Xs7.js";
|
|
2
|
+
import { t as a } from "./pushkin-BJAKy5lP-BDJR20nC.js";
|
|
3
|
+
import { r as o, t as s } from "./audio-context-store-Ccv6WKna-C-yxIXdl.js";
|
|
4
|
+
import { u as c } from "./load-D2Tka_Qx-BNIMgt7e.js";
|
|
5
|
+
//#region ../player/dist/index.js
|
|
6
|
+
function l() {
|
|
7
|
+
return i.activePlayer?.getPosition() ?? 0;
|
|
8
|
+
}
|
|
9
|
+
function u() {
|
|
10
|
+
return i.activePlayer?.currentMediaProduct ?? null;
|
|
11
|
+
}
|
|
12
|
+
function d() {
|
|
13
|
+
let e = i.activePlayer;
|
|
14
|
+
if (e) {
|
|
15
|
+
let t = n.getMediaProductTransition(e.currentStreamingSessionId);
|
|
16
|
+
if (t) return t.playbackContext;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function f() {
|
|
20
|
+
return i.activePlayer?.playbackState ?? "IDLE";
|
|
21
|
+
}
|
|
22
|
+
function p() {
|
|
23
|
+
return i.activePlayer?.pause();
|
|
24
|
+
}
|
|
25
|
+
async function m() {
|
|
26
|
+
await a.synchronize();
|
|
27
|
+
let { activePlayer: t } = i;
|
|
28
|
+
return t ? (e.dispatchEvent(new CustomEvent("user-action")), t.play()) : Promise.reject(/* @__PURE__ */ Error("No active player"));
|
|
29
|
+
}
|
|
30
|
+
async function h(e) {
|
|
31
|
+
let { activePlayer: t } = i;
|
|
32
|
+
return t?.seek(e);
|
|
33
|
+
}
|
|
34
|
+
function g(e) {
|
|
35
|
+
t.credentialsProvider = e;
|
|
36
|
+
}
|
|
37
|
+
function _(e) {
|
|
38
|
+
r.eventSender = e;
|
|
39
|
+
}
|
|
40
|
+
a.synchronize().then().catch(console.error);
|
|
41
|
+
function v() {
|
|
42
|
+
let { activePlayer: e } = i;
|
|
43
|
+
if (!e) return null;
|
|
44
|
+
switch (e.name) {
|
|
45
|
+
case "browserPlayer": return e.mediaElement;
|
|
46
|
+
case "shakaPlayer": return e.mediaElement;
|
|
47
|
+
default: return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function y() {
|
|
51
|
+
let e = localStorage.getItem("ssuid");
|
|
52
|
+
try {
|
|
53
|
+
e && indexedDB.deleteDatabase("streaming-sessions-" + e);
|
|
54
|
+
} catch (t) {
|
|
55
|
+
console.warn(`DB streaming-sessions-${e} could not be deleted`), console.error(t);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
o().then().catch(console.error), s().then().catch(console.error), y();
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/helpers.ts
|
|
61
|
+
var b = String.raw, x = String.raw;
|
|
62
|
+
function S(e) {
|
|
63
|
+
if (e === void 0) return "0:00";
|
|
64
|
+
let t = parseInt(String(e), 10), n = Math.floor(t / 3600), r = Math.floor((t - n * 3600) / 60), i = t - n * 3600 - r * 60, a;
|
|
65
|
+
return a = n === 0 ? `${r}:` : `${n}:${r < 10 ? `0${r}` : String(r)}:`, a += i < 10 ? `0${i}` : String(i), a;
|
|
66
|
+
}
|
|
67
|
+
function C(e = 0) {
|
|
68
|
+
let t = typeof e == "number" ? e : parseInt(e, 10);
|
|
69
|
+
return `P${[
|
|
70
|
+
Math.floor(t / 3600) % 24,
|
|
71
|
+
Math.floor(t / 60) % 60,
|
|
72
|
+
t % 60
|
|
73
|
+
].map((e, t) => {
|
|
74
|
+
if (e === 0 && t !== 1) return "";
|
|
75
|
+
let n;
|
|
76
|
+
switch (t) {
|
|
77
|
+
case 0:
|
|
78
|
+
n = "H";
|
|
79
|
+
break;
|
|
80
|
+
case 1:
|
|
81
|
+
n = "M";
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
n = "S";
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
return `${n}${e}`;
|
|
88
|
+
}).join("")}`;
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/tidal-current-time.ts
|
|
92
|
+
var w = "tidal-current-time", T = class extends HTMLElement {
|
|
93
|
+
#e = void 0;
|
|
94
|
+
#t = /* @__PURE__ */ new Set();
|
|
95
|
+
#n;
|
|
96
|
+
#r;
|
|
97
|
+
#i;
|
|
98
|
+
constructor() {
|
|
99
|
+
super(), this.#i = (e) => this.renderTime(e.target.currentTime), this.#r = () => this.renderTime(0), this.#n = this.#a.bind(this);
|
|
100
|
+
}
|
|
101
|
+
#a() {
|
|
102
|
+
let e = v();
|
|
103
|
+
e && this.#e && !this.#t.has(e) && (e.addEventListener("timeupdate", this.#i, !1), this.#t.add(e));
|
|
104
|
+
}
|
|
105
|
+
connectedCallback() {
|
|
106
|
+
let t = this.attachShadow({ mode: "open" });
|
|
107
|
+
t.innerHTML = "<time></time>";
|
|
108
|
+
let n = t.querySelector("time");
|
|
109
|
+
this.#e === void 0 && n !== null && (this.#e = n), this.renderTime(l()), e.addEventListener("media-product-transition", this.#n, !1), e.addEventListener("ended", this.#r, !1);
|
|
110
|
+
}
|
|
111
|
+
disconnectedCallback() {
|
|
112
|
+
for (let e of this.#t) e.removeEventListener("timeupdate", this.#i, !1);
|
|
113
|
+
e.removeEventListener("media-product-transition", this.#n, !1), e.removeEventListener("ended", this.#r, !1);
|
|
114
|
+
}
|
|
115
|
+
renderTime(e) {
|
|
116
|
+
let t = Math.floor(e);
|
|
117
|
+
this.#e && (this.#e.textContent = S(t), this.#e.setAttribute("datetime", C(t)));
|
|
118
|
+
}
|
|
11
119
|
};
|
|
120
|
+
customElements.define(w, T);
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/tidal-duration-time.ts
|
|
123
|
+
var E = "tidal-duration-time", D = class extends HTMLElement {
|
|
124
|
+
#e;
|
|
125
|
+
#t = !1;
|
|
126
|
+
#n;
|
|
127
|
+
constructor() {
|
|
128
|
+
super(), this.#n = (e) => {
|
|
129
|
+
let t = e;
|
|
130
|
+
this.renderTime(t.detail.playbackContext.actualDuration);
|
|
131
|
+
}, this.#r();
|
|
132
|
+
}
|
|
133
|
+
#r() {
|
|
134
|
+
this.#t ||= (e.addEventListener("media-product-transition", this.#n, !1), !0);
|
|
135
|
+
}
|
|
136
|
+
#i() {
|
|
137
|
+
let e = this.attachShadow({ mode: "open" });
|
|
138
|
+
this.#e = document.createElement("time"), e.appendChild(this.#e);
|
|
139
|
+
}
|
|
140
|
+
connectedCallback() {
|
|
141
|
+
this.#r(), this.#i();
|
|
142
|
+
let e = parseInt(String(this.textContent), 10), t = Number.isNaN(e) ? 0 : e;
|
|
143
|
+
this.renderTime(d()?.actualDuration ?? t);
|
|
144
|
+
}
|
|
145
|
+
disconnectedCallback() {
|
|
146
|
+
e.removeEventListener("media-product-transition", this.#n, !1), this.#t = !1;
|
|
147
|
+
}
|
|
148
|
+
renderTime(e) {
|
|
149
|
+
let t = parseInt(e.toFixed(0), 10);
|
|
150
|
+
this.#e && (this.#e.textContent = S(t), this.#e.setAttribute("datetime", C(t)));
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
customElements.define(E, D);
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/tidal-play-trigger.ts
|
|
156
|
+
var O = "tidal-play-trigger", k = class extends HTMLElement {
|
|
157
|
+
#e;
|
|
158
|
+
#t = !1;
|
|
159
|
+
constructor() {
|
|
160
|
+
super(), this.#e = () => {
|
|
161
|
+
this.#n().catch(console.error);
|
|
162
|
+
}, this.#i();
|
|
163
|
+
}
|
|
164
|
+
static get observedAttributes() {
|
|
165
|
+
return ["product-id", "product-type"];
|
|
166
|
+
}
|
|
167
|
+
async #n() {
|
|
168
|
+
await this.#r(), f() === "PLAYING" ? p() : await m();
|
|
169
|
+
}
|
|
170
|
+
#r() {
|
|
171
|
+
let e = u()?.productId ?? void 0;
|
|
172
|
+
if (this.mediaProduct && this.mediaProduct.productId !== e) return c(this.mediaProduct, 0);
|
|
173
|
+
}
|
|
174
|
+
#i() {
|
|
175
|
+
this.#t || this.addEventListener("click", this.#e, { passive: !0 });
|
|
176
|
+
}
|
|
177
|
+
#a() {
|
|
178
|
+
let e = this.attachShadow({ mode: "closed" }), t = document.createElement("style");
|
|
179
|
+
t.textContent = b`
|
|
180
|
+
:host {
|
|
181
|
+
display: contents;
|
|
182
|
+
}
|
|
183
|
+
`;
|
|
184
|
+
let n = document.createElement("slot");
|
|
185
|
+
e.appendChild(t), e.appendChild(n);
|
|
186
|
+
}
|
|
187
|
+
connectedCallback() {
|
|
188
|
+
this.#i(), this.#a();
|
|
189
|
+
}
|
|
190
|
+
disconnectedCallback() {
|
|
191
|
+
this.removeEventListener("click", this.#e, { passive: !0 }), this.#t = !1;
|
|
192
|
+
}
|
|
193
|
+
get mediaProduct() {
|
|
194
|
+
let e = this.getAttribute("product-id");
|
|
195
|
+
if (e) return {
|
|
196
|
+
productId: e,
|
|
197
|
+
productType: this.getAttribute("product-type") === "video" ? "video" : "track",
|
|
198
|
+
sourceId: "",
|
|
199
|
+
sourceType: ""
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
customElements.define(O, k);
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/tidal-progress-bar.ts
|
|
206
|
+
var A = b`
|
|
207
|
+
:host {
|
|
208
|
+
display: inline-block;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#wrapper {
|
|
212
|
+
width: 100%;
|
|
213
|
+
height: 100%;
|
|
214
|
+
contain: strict;
|
|
215
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
216
|
+
cursor: pointer;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
#indicator {
|
|
220
|
+
width: 100%;
|
|
221
|
+
height: 100%;
|
|
222
|
+
transform: none;
|
|
223
|
+
will-change: transform;
|
|
224
|
+
background-color: currentColor;
|
|
225
|
+
pointer-events: none;
|
|
226
|
+
}
|
|
227
|
+
`, j = { NO_DURATION: "You need to set duration before you can start/stop the progress bar." }, M = class extends HTMLElement {
|
|
228
|
+
#e;
|
|
229
|
+
#t = 1;
|
|
230
|
+
#n = null;
|
|
231
|
+
#r;
|
|
232
|
+
#i;
|
|
233
|
+
#a = /* @__PURE__ */ new Set();
|
|
234
|
+
#o = null;
|
|
235
|
+
#s;
|
|
236
|
+
constructor() {
|
|
237
|
+
super(), this.#r = (e) => {
|
|
238
|
+
let t = e;
|
|
239
|
+
if (this.duration = t.detail.playbackContext.actualDuration, f() === "PLAYING") try {
|
|
240
|
+
this.start();
|
|
241
|
+
} catch (e) {
|
|
242
|
+
console.warn(e);
|
|
243
|
+
}
|
|
244
|
+
}, this.#i = (e) => {
|
|
245
|
+
let t = e;
|
|
246
|
+
try {
|
|
247
|
+
t.detail.state === "PLAYING" ? this.start() : this.stop();
|
|
248
|
+
} catch (e) {
|
|
249
|
+
console.warn(e);
|
|
250
|
+
}
|
|
251
|
+
}, this.#s = (e) => {
|
|
252
|
+
(e instanceof MouseEvent || e instanceof PointerEvent) && this.handleClick(e);
|
|
253
|
+
}, this.#c();
|
|
254
|
+
}
|
|
255
|
+
#c() {
|
|
256
|
+
this.#a.has("media-product-transition") || (e.addEventListener("media-product-transition", this.#r, !1), this.#a.add("media-product-transition")), this.#a.has("playback-state-change") || (e.addEventListener("playback-state-change", this.#i), this.#a.add("playback-state-change")), this.#o && !this.#a.has("wrapper-click") && (this.#o.addEventListener("click", this.#s, !1), this.#a.add("wrapper-click"));
|
|
257
|
+
}
|
|
258
|
+
#l() {
|
|
259
|
+
let e = this.attachShadow({ mode: "closed" });
|
|
260
|
+
e.innerHTML = x`
|
|
261
|
+
<style>
|
|
262
|
+
${A}
|
|
263
|
+
</style>
|
|
264
|
+
<div id="wrapper">
|
|
265
|
+
<div id="indicator"></div>
|
|
266
|
+
</div>
|
|
267
|
+
`, this.#o = e.querySelector("#wrapper"), this.#n = e.querySelector("#indicator");
|
|
268
|
+
}
|
|
269
|
+
connectedCallback() {
|
|
270
|
+
this.#l(), this.#c();
|
|
271
|
+
}
|
|
272
|
+
set currentTime(e) {
|
|
273
|
+
this.#e && (this.#e.currentTime = e);
|
|
274
|
+
}
|
|
275
|
+
disconnectedCallback() {
|
|
276
|
+
e.removeEventListener("media-product-transition", this.#r, !1), e.removeEventListener("playback-state-change", this.#i), this.#o?.addEventListener("click", this.#s, !1), this.#a.clear();
|
|
277
|
+
}
|
|
278
|
+
set duration(e) {
|
|
279
|
+
this.#t = e * 1e3;
|
|
280
|
+
let t = [{ transform: "translateX(-100%)" }, { transform: "translateX(0%)" }];
|
|
281
|
+
this.#e = this.#n?.animate(t, {
|
|
282
|
+
duration: this.#t,
|
|
283
|
+
iterations: 1
|
|
284
|
+
}), this.#e?.pause();
|
|
285
|
+
}
|
|
286
|
+
getMousePositionAsPercent(e) {
|
|
287
|
+
if (this.#o) {
|
|
288
|
+
let t = this.#o.getBoundingClientRect(), n = {
|
|
289
|
+
left: Math.abs(t.left + window.pageXOffset - e.pageX),
|
|
290
|
+
width: Math.round(t.width)
|
|
291
|
+
};
|
|
292
|
+
return n.left / n.width;
|
|
293
|
+
}
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
296
|
+
handleClick(e) {
|
|
297
|
+
let t = this.getMousePositionAsPercent(e), n = this.#t * t;
|
|
298
|
+
this.currentTime = n, h(n / 1e3);
|
|
299
|
+
}
|
|
300
|
+
set playbackRate(e) {
|
|
301
|
+
this.stop(), this.#e && (this.#e.playbackRate = e), this.start();
|
|
302
|
+
}
|
|
303
|
+
start() {
|
|
304
|
+
if (!this.#e) throw Error(j.NO_DURATION);
|
|
305
|
+
this.#e.play();
|
|
306
|
+
}
|
|
307
|
+
stop() {
|
|
308
|
+
if (!this.#e) throw Error(j.NO_DURATION);
|
|
309
|
+
this.#e.pause();
|
|
310
|
+
}
|
|
311
|
+
}, N = "tidal-progress-bar";
|
|
312
|
+
customElements.define(N, M);
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/tidal-video-view.ts
|
|
315
|
+
var P = b`
|
|
316
|
+
:host {
|
|
317
|
+
position: relative;
|
|
318
|
+
display: block;
|
|
319
|
+
width: 100%;
|
|
320
|
+
aspect-ratio: 16/9;
|
|
321
|
+
background-color: black;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
::slotted(video) {
|
|
325
|
+
display: block;
|
|
326
|
+
width: 100%;
|
|
327
|
+
height: 100%;
|
|
328
|
+
z-index: 1;
|
|
329
|
+
position: relative;
|
|
330
|
+
background-color: black;
|
|
331
|
+
}
|
|
332
|
+
`, F = "tidal-video-view", I = class extends HTMLElement {
|
|
333
|
+
#e = !1;
|
|
334
|
+
#t;
|
|
335
|
+
#n;
|
|
336
|
+
constructor() {
|
|
337
|
+
super(), this.#t = (e) => {
|
|
338
|
+
e.detail.mediaProduct.productType === "video" && this.mountPlayer();
|
|
339
|
+
}, this.#n = (e) => {
|
|
340
|
+
let t = e;
|
|
341
|
+
this.setAttribute("playback-state", t.detail.state.toLocaleLowerCase());
|
|
342
|
+
}, this.#r();
|
|
343
|
+
}
|
|
344
|
+
#r() {
|
|
345
|
+
this.#e || (e.addEventListener("media-product-transition", this.#t, !1), e.addEventListener("playback-state-change", this.#n, !1));
|
|
346
|
+
}
|
|
347
|
+
connectedCallback() {
|
|
348
|
+
this.#r();
|
|
349
|
+
let e = this.attachShadow({ mode: "closed" }), t = document.createElement("style");
|
|
350
|
+
t.textContent = P;
|
|
351
|
+
let n = document.createElement("slot");
|
|
352
|
+
e.appendChild(t), e.appendChild(n);
|
|
353
|
+
}
|
|
354
|
+
disconnectedCallback() {
|
|
355
|
+
e.removeEventListener("media-product-transition", this.#t, !1), e.removeEventListener("playback-state-change", this.#n, !1), this.#e = !0;
|
|
356
|
+
}
|
|
357
|
+
mountPlayer() {
|
|
358
|
+
let e = v();
|
|
359
|
+
e && (this.innerHTML = "", this.appendChild(e));
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
customElements.define(F, I);
|
|
363
|
+
//#endregion
|
|
364
|
+
export { w as TidalCurrentTime, E as TidalDurationTime, O as TidalPlayButton, N as TidalProgressBar, F as TidalVideoView, e as events, g as setCredentialsProvider, _ as setEventSender };
|