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