@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
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { C as I, R as g, w as p } from "./basePlayer-Rqi9yRuo-4eKn-Akv.js";
|
|
2
|
-
import { c as P, A as y, P as c, b as S, k as E, d as L } from "./index-DHnVYeec.js";
|
|
3
|
-
class f extends I {
|
|
4
|
-
#t;
|
|
5
|
-
#r;
|
|
6
|
-
#i = !0;
|
|
7
|
-
#d;
|
|
8
|
-
#e;
|
|
9
|
-
#a = document.createElement("video");
|
|
10
|
-
#s = !1;
|
|
11
|
-
name = "browserPlayer";
|
|
12
|
-
constructor() {
|
|
13
|
-
super(), this.playbackState = "IDLE";
|
|
14
|
-
const e = () => {
|
|
15
|
-
this.mediaElement && !this.mediaElement.paused && (this.playbackState = "PLAYING");
|
|
16
|
-
}, i = (a) => {
|
|
17
|
-
this.currentStreamingSessionId && a.target instanceof HTMLMediaElement && c.overwriteDuration(
|
|
18
|
-
this.currentStreamingSessionId,
|
|
19
|
-
a.target.duration
|
|
20
|
-
);
|
|
21
|
-
}, t = () => {
|
|
22
|
-
this.playbackState = "STALLED";
|
|
23
|
-
}, s = () => {
|
|
24
|
-
(async () => {
|
|
25
|
-
const a = this.#t;
|
|
26
|
-
if (a) {
|
|
27
|
-
if (this.preloadedStreamingSessionId && a.currentTime === a.duration && (await L(1e3), a.currentTime !== a.duration))
|
|
28
|
-
return;
|
|
29
|
-
this.playbackState = "NOT_PLAYING";
|
|
30
|
-
}
|
|
31
|
-
})().catch(console.error);
|
|
32
|
-
}, n = (a) => {
|
|
33
|
-
if (a instanceof Event) {
|
|
34
|
-
const l = a.target;
|
|
35
|
-
l.readyState > HTMLMediaElement.HAVE_NOTHING && (this.currentTime = l.currentTime);
|
|
36
|
-
}
|
|
37
|
-
}, d = (a) => {
|
|
38
|
-
n(a), this.finishCurrentMediaProduct("completed");
|
|
39
|
-
}, r = (a) => console.error("HTMLMediaElement errored", a), o = () => {
|
|
40
|
-
this.mediaElement && (this.currentTime = this.mediaElement.currentTime, this.seekEnd(this.currentTime));
|
|
41
|
-
};
|
|
42
|
-
this.#e = {
|
|
43
|
-
durationChangeHandler: i,
|
|
44
|
-
endedHandler: d,
|
|
45
|
-
errorHandler: r,
|
|
46
|
-
pauseHandler: s,
|
|
47
|
-
playHandler: e,
|
|
48
|
-
playingHandler: e,
|
|
49
|
-
seekedHandler: o,
|
|
50
|
-
stalledHandler: t,
|
|
51
|
-
timeUpdateHandler: n,
|
|
52
|
-
waitingHandler: t
|
|
53
|
-
}, P().then().catch(console.error), this.#r = y, this.currentPlayer = this.#r;
|
|
54
|
-
}
|
|
55
|
-
#n(e, i) {
|
|
56
|
-
this.debugLog(
|
|
57
|
-
"mediaElementEvents",
|
|
58
|
-
i ? "adding to" : "removing from",
|
|
59
|
-
e
|
|
60
|
-
);
|
|
61
|
-
const t = i ? "addEventListener" : "removeEventListener";
|
|
62
|
-
e[t](
|
|
63
|
-
"durationchange",
|
|
64
|
-
this.#e.durationChangeHandler,
|
|
65
|
-
{
|
|
66
|
-
passive: !0
|
|
67
|
-
}
|
|
68
|
-
), e[t]("play", this.#e.playHandler, {
|
|
69
|
-
passive: !0
|
|
70
|
-
}), e[t](
|
|
71
|
-
"playing",
|
|
72
|
-
this.#e.playingHandler,
|
|
73
|
-
{ passive: !0 }
|
|
74
|
-
), e[t](
|
|
75
|
-
"timeupdate",
|
|
76
|
-
this.#e.timeUpdateHandler,
|
|
77
|
-
{ passive: !0 }
|
|
78
|
-
), e[t](
|
|
79
|
-
"pause",
|
|
80
|
-
this.#e.pauseHandler,
|
|
81
|
-
{ passive: !0 }
|
|
82
|
-
), e[t](
|
|
83
|
-
"ended",
|
|
84
|
-
this.#e.endedHandler,
|
|
85
|
-
{ passive: !0 }
|
|
86
|
-
), e[t](
|
|
87
|
-
"error",
|
|
88
|
-
this.#e.errorHandler,
|
|
89
|
-
{ passive: !0 }
|
|
90
|
-
), e[t](
|
|
91
|
-
"waiting",
|
|
92
|
-
this.#e.waitingHandler,
|
|
93
|
-
{ passive: !0 }
|
|
94
|
-
), e[t](
|
|
95
|
-
"stalled",
|
|
96
|
-
this.#e.stalledHandler,
|
|
97
|
-
{ passive: !0 }
|
|
98
|
-
), e[t](
|
|
99
|
-
"seeked",
|
|
100
|
-
this.#e.seekedHandler,
|
|
101
|
-
{ passive: !0 }
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
getPosition() {
|
|
105
|
-
return this.debugLog("getPosition"), this.mediaElement && (this.mediaElement.ended ? this.currentTime = 0 : this.currentTime = this.mediaElement.currentTime), this.currentTime;
|
|
106
|
-
}
|
|
107
|
-
async load(e, i) {
|
|
108
|
-
this.debugLog("load", e), this.currentTime = e.assetPosition, this.startAssetPosition = e.assetPosition, await P(), await this.reset(), this.#i = !1, i === "explicit" && (this.playbackState = "NOT_PLAYING");
|
|
109
|
-
const { assetPosition: t, mediaProduct: s, playbackInfo: n, streamInfo: d } = e;
|
|
110
|
-
this.currentStreamingSessionId = d.streamingSessionId;
|
|
111
|
-
const { currentPlayer: r } = this;
|
|
112
|
-
if (!r)
|
|
113
|
-
return;
|
|
114
|
-
const o = new Promise(
|
|
115
|
-
(u) => r.addEventListener("canplay", () => u(), {
|
|
116
|
-
once: !0
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
r.src = d.streamUrl, r.currentTime = t, r.load();
|
|
120
|
-
const a = new Promise(
|
|
121
|
-
(u) => r.addEventListener(
|
|
122
|
-
"durationchange",
|
|
123
|
-
(m) => {
|
|
124
|
-
m.target instanceof HTMLMediaElement && u(m.target.duration);
|
|
125
|
-
},
|
|
126
|
-
{ once: !0 }
|
|
127
|
-
)
|
|
128
|
-
);
|
|
129
|
-
if (await o, this.currentStreamingSessionId !== d.streamingSessionId)
|
|
130
|
-
return;
|
|
131
|
-
const l = await a, h = g({
|
|
132
|
-
assetPosition: t,
|
|
133
|
-
duration: l,
|
|
134
|
-
playbackInfo: n,
|
|
135
|
-
streamInfo: d
|
|
136
|
-
});
|
|
137
|
-
return c.saveMediaProductTransition(
|
|
138
|
-
d.streamingSessionId,
|
|
139
|
-
{ mediaProduct: s, playbackContext: h }
|
|
140
|
-
), this.debugLog("dispatching mediaProductTransition"), S.dispatchEvent(
|
|
141
|
-
p(s, h)
|
|
142
|
-
), this.#s ? (this.#s = !1, this.play()) : Promise.resolve();
|
|
143
|
-
}
|
|
144
|
-
async next(e) {
|
|
145
|
-
this.debugLog("next", e), this.playbackState === "IDLE" && (this.playbackState = "NOT_PLAYING");
|
|
146
|
-
const { mediaProduct: i, playbackInfo: t, streamInfo: s } = e, n = this.#a;
|
|
147
|
-
if (this.preloadedStreamingSessionId = s.streamingSessionId, !n)
|
|
148
|
-
return;
|
|
149
|
-
n.src = s.streamUrl, n.load();
|
|
150
|
-
const d = await new Promise(
|
|
151
|
-
(o) => n.addEventListener(
|
|
152
|
-
"durationchange",
|
|
153
|
-
(a) => {
|
|
154
|
-
a.target instanceof HTMLMediaElement && o(a.target.duration);
|
|
155
|
-
},
|
|
156
|
-
{ once: !0 }
|
|
157
|
-
)
|
|
158
|
-
), r = g({
|
|
159
|
-
assetPosition: 0,
|
|
160
|
-
duration: d,
|
|
161
|
-
playbackInfo: t,
|
|
162
|
-
streamInfo: s
|
|
163
|
-
});
|
|
164
|
-
c.saveMediaProductTransition(
|
|
165
|
-
s.streamingSessionId,
|
|
166
|
-
{
|
|
167
|
-
mediaProduct: i,
|
|
168
|
-
playbackContext: r
|
|
169
|
-
}
|
|
170
|
-
), this.#i = !1;
|
|
171
|
-
}
|
|
172
|
-
pause() {
|
|
173
|
-
this.debugLog("pause"), this.mediaElement && this.mediaElement.pause();
|
|
174
|
-
}
|
|
175
|
-
async play() {
|
|
176
|
-
if (this.debugLog("play"), await this.maybeHardReload(), this.playbackState === "IDLE")
|
|
177
|
-
return this.debugLog("is IDLE, returning early"), this.#s = !0, Promise.resolve();
|
|
178
|
-
"setSinkId" in y && await this.updateOutputDevice(), this.currentStreamingSessionId && this.mediaProductStarted(this.currentStreamingSessionId), this.setStateToXIfNotYInZMs(1e3, "PLAYING", "STALLED"), this.currentPlayer && await this.currentPlayer.play().catch(console.error);
|
|
179
|
-
}
|
|
180
|
-
async playbackEngineEndedHandler(e) {
|
|
181
|
-
if (this.isActivePlayer) {
|
|
182
|
-
const { reason: i } = e.detail;
|
|
183
|
-
i === "completed" && (this.hasNextItem() ? (await this.skipToPreloadedMediaProduct(), await this.play()) : (console.warn("No item preloaded, not progressing."), this.playbackState = "NOT_PLAYING"));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async reset({ keepPreload: e } = { keepPreload: !1 }) {
|
|
187
|
-
if (this.#i)
|
|
188
|
-
return Promise.resolve();
|
|
189
|
-
this.debugLog("reset"), this.playbackState !== "IDLE" && this.finishCurrentMediaProduct("skip"), this.playbackState = "IDLE", this.detachPlaybackEngineEndedHandler(), this.currentStreamingSessionId = void 0, e || (this.preloadedStreamingSessionId = void 0);
|
|
190
|
-
const { currentPlayer: i } = this;
|
|
191
|
-
return i && i.readyState !== 0 && (i.load(), await new Promise(
|
|
192
|
-
(t) => i.addEventListener("emptied", () => t(), { passive: !0 })
|
|
193
|
-
)), this.#i = !0, Promise.resolve();
|
|
194
|
-
}
|
|
195
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
196
|
-
seek(e) {
|
|
197
|
-
this.debugLog("seek", e);
|
|
198
|
-
const { currentPlayer: i } = this, t = e;
|
|
199
|
-
if (i)
|
|
200
|
-
return this.seekStart(this.currentTime), "fastSeek" in i ? i.fastSeek(t) : i.currentTime = t, new Promise((s) => {
|
|
201
|
-
i.addEventListener("seeked", () => s(i.currentTime), {
|
|
202
|
-
once: !0
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
207
|
-
async skipToPreloadedMediaProduct() {
|
|
208
|
-
const e = c.getMediaProductTransition(
|
|
209
|
-
this.preloadedStreamingSessionId
|
|
210
|
-
);
|
|
211
|
-
if (!e) {
|
|
212
|
-
this.playbackState = "NOT_PLAYING";
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
if (this.debugLog(
|
|
216
|
-
"skipToPreloadedMediaProduct",
|
|
217
|
-
this.preloadedStreamingSessionId
|
|
218
|
-
), this.#a.src && this.currentPlayer) {
|
|
219
|
-
this.currentPlayer.src = this.#a.src, this.currentStreamingSessionId = String(this.preloadedStreamingSessionId), this.preloadedStreamingSessionId = void 0;
|
|
220
|
-
const { mediaProduct: i, playbackContext: t } = e;
|
|
221
|
-
S.dispatchEvent(
|
|
222
|
-
p(i, t)
|
|
223
|
-
), this.playbackState === "IDLE" && (this.playbackState = "NOT_PLAYING");
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
togglePlayback() {
|
|
227
|
-
this.debugLog("togglePlayback"), this.mediaElement && (this.mediaElement.paused ? this.mediaElement.play().catch(console.error) : this.mediaElement.pause());
|
|
228
|
-
}
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
230
|
-
async unloadPreloadedMediaProduct() {
|
|
231
|
-
this.debugLog(
|
|
232
|
-
"unloadPreloadedMediaProduct",
|
|
233
|
-
this.preloadedStreamingSessionId
|
|
234
|
-
), this.cleanUpStoredPreloadInfo();
|
|
235
|
-
const e = this.#a;
|
|
236
|
-
e && (e.src = "", e.load());
|
|
237
|
-
}
|
|
238
|
-
get currentPlayer() {
|
|
239
|
-
return this.#t;
|
|
240
|
-
}
|
|
241
|
-
set currentPlayer(e) {
|
|
242
|
-
this.debugLog("set currentPlayer", e), this.#t && (this.#n(this.#t, !1), this.#t.load()), e && (this.#t = e, this.#n(e, !0));
|
|
243
|
-
}
|
|
244
|
-
get mediaElement() {
|
|
245
|
-
return this.currentPlayer ?? null;
|
|
246
|
-
}
|
|
247
|
-
get ready() {
|
|
248
|
-
return this.#d;
|
|
249
|
-
}
|
|
250
|
-
get volume() {
|
|
251
|
-
return E("desiredVolumeLevel");
|
|
252
|
-
}
|
|
253
|
-
set volume(e) {
|
|
254
|
-
this.debugLog("Setting volume to", e), this.currentPlayer && (this.currentPlayer.volume = e);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
export {
|
|
258
|
-
f as default
|
|
259
|
-
};
|