@tidal-music/player-web-components 0.1.2 → 0.2.0
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-BcooVl9P-WesO1_17.js → basePlayer-C5QIyqfj-Dxhlf4BZ.js} +100 -161
- package/dist/{browserPlayer-B1V50MdI-D65N_aRN.js → browserPlayer-HE2uqs17-DJrIq6Jp.js} +61 -65
- package/dist/{index-DbGwqQeZ.js → index-vp_MoGvy.js} +1138 -1053
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -8
- package/dist/{nativePlayer-DdpXKE9r-B14o92dS.js → nativePlayer-B3eHKegV-DdXsvi0F.js} +65 -104
- package/dist/output-devices-Jno8Kp5B-CAnEAv_Z.js +224 -0
- package/dist/shakaPlayer-CCJQsypf-DHT2kwDp.js +24411 -0
- package/package.json +14 -13
- package/dist/output-devices-BhcWYG6e-l4DCXneM.js +0 -236
- package/dist/shakaPlayer-Brgd4rob-DJ5uJTjr.js +0 -26243
- package/dist/worker-DrRlSx4a-BTanKBsS.js +0 -89
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { C as I, R as g, w as p } from "./basePlayer-C5QIyqfj-Dxhlf4BZ.js";
|
|
2
|
+
import { a as P, I as y, P as c, b as S, k as E, c as L } from "./index-vp_MoGvy.js";
|
|
3
3
|
class f extends I {
|
|
4
4
|
#t;
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#o;
|
|
5
|
+
#r;
|
|
6
|
+
#i = !0;
|
|
7
|
+
#d;
|
|
9
8
|
#e;
|
|
9
|
+
#a = document.createElement("video");
|
|
10
10
|
#s = !1;
|
|
11
11
|
name = "browserPlayer";
|
|
12
12
|
constructor() {
|
|
13
13
|
super(), this.playbackState = "IDLE";
|
|
14
14
|
const e = () => {
|
|
15
15
|
this.mediaElement && !this.mediaElement.paused && (this.playbackState = "PLAYING");
|
|
16
|
-
},
|
|
16
|
+
}, i = (a) => {
|
|
17
17
|
this.currentStreamingSessionId && a.target instanceof HTMLMediaElement && c.overwriteDuration(
|
|
18
18
|
this.currentStreamingSessionId,
|
|
19
19
|
a.target.duration
|
|
20
20
|
);
|
|
21
|
-
},
|
|
21
|
+
}, t = () => {
|
|
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 L(1e3), a.currentTime !== a.duration))
|
|
28
28
|
return;
|
|
29
29
|
this.playbackState = "NOT_PLAYING";
|
|
30
30
|
}
|
|
@@ -40,65 +40,62 @@ class f extends I {
|
|
|
40
40
|
this.mediaElement && (this.currentTime = this.mediaElement.currentTime, this.seekEnd(this.currentTime));
|
|
41
41
|
};
|
|
42
42
|
this.#e = {
|
|
43
|
-
durationChangeHandler:
|
|
43
|
+
durationChangeHandler: i,
|
|
44
44
|
endedHandler: d,
|
|
45
45
|
errorHandler: r,
|
|
46
46
|
pauseHandler: s,
|
|
47
47
|
playHandler: e,
|
|
48
48
|
playingHandler: e,
|
|
49
49
|
seekedHandler: o,
|
|
50
|
-
stalledHandler:
|
|
50
|
+
stalledHandler: t,
|
|
51
51
|
timeUpdateHandler: n,
|
|
52
|
-
waitingHandler:
|
|
53
|
-
}, P().then().catch(console.error), this.#
|
|
52
|
+
waitingHandler: t
|
|
53
|
+
}, P().then().catch(console.error), this.#r = y, this.currentPlayer = this.#r;
|
|
54
54
|
}
|
|
55
|
-
#
|
|
56
|
-
return [this.#i, this.#n].filter((e) => e !== this.#t).pop();
|
|
57
|
-
}
|
|
58
|
-
#d(e, t) {
|
|
55
|
+
#n(e, i) {
|
|
59
56
|
this.debugLog(
|
|
60
57
|
"mediaElementEvents",
|
|
61
|
-
|
|
58
|
+
i ? "adding to" : "removing from",
|
|
62
59
|
e
|
|
63
60
|
);
|
|
64
|
-
const
|
|
65
|
-
e[
|
|
61
|
+
const t = i ? "addEventListener" : "removeEventListener";
|
|
62
|
+
e[t](
|
|
66
63
|
"durationchange",
|
|
67
64
|
this.#e.durationChangeHandler,
|
|
68
65
|
{
|
|
69
66
|
passive: !0
|
|
70
67
|
}
|
|
71
|
-
), e[
|
|
68
|
+
), e[t]("play", this.#e.playHandler, {
|
|
72
69
|
passive: !0
|
|
73
|
-
}), e[
|
|
70
|
+
}), e[t](
|
|
74
71
|
"playing",
|
|
75
72
|
this.#e.playingHandler,
|
|
76
73
|
{ passive: !0 }
|
|
77
|
-
), e[
|
|
74
|
+
), e[t](
|
|
78
75
|
"timeupdate",
|
|
79
76
|
this.#e.timeUpdateHandler,
|
|
80
77
|
{ passive: !0 }
|
|
81
|
-
), e[
|
|
78
|
+
), e[t](
|
|
82
79
|
"pause",
|
|
83
80
|
this.#e.pauseHandler,
|
|
84
81
|
{ passive: !0 }
|
|
85
|
-
), e[
|
|
82
|
+
), e[t](
|
|
86
83
|
"ended",
|
|
87
84
|
this.#e.endedHandler,
|
|
88
85
|
{ passive: !0 }
|
|
89
|
-
), e[
|
|
86
|
+
), e[t](
|
|
90
87
|
"error",
|
|
91
88
|
this.#e.errorHandler,
|
|
92
89
|
{ passive: !0 }
|
|
93
|
-
), e[
|
|
90
|
+
), e[t](
|
|
94
91
|
"waiting",
|
|
95
92
|
this.#e.waitingHandler,
|
|
96
93
|
{ passive: !0 }
|
|
97
|
-
), e[
|
|
94
|
+
), e[t](
|
|
98
95
|
"stalled",
|
|
99
96
|
this.#e.stalledHandler,
|
|
100
97
|
{ passive: !0 }
|
|
101
|
-
), e[
|
|
98
|
+
), e[t](
|
|
102
99
|
"seeked",
|
|
103
100
|
this.#e.seekedHandler,
|
|
104
101
|
{ passive: !0 }
|
|
@@ -107,46 +104,46 @@ class f extends I {
|
|
|
107
104
|
getPosition() {
|
|
108
105
|
return this.debugLog("getPosition"), this.mediaElement && (this.mediaElement.ended ? this.currentTime = 0 : this.currentTime = this.mediaElement.currentTime), this.currentTime;
|
|
109
106
|
}
|
|
110
|
-
async load(e,
|
|
111
|
-
this.debugLog("load", e), this.currentTime = e.assetPosition, this.startAssetPosition = e.assetPosition, await P(), await this.reset(), this.#
|
|
112
|
-
const { assetPosition:
|
|
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;
|
|
113
110
|
this.currentStreamingSessionId = d.streamingSessionId;
|
|
114
111
|
const { currentPlayer: r } = this;
|
|
115
112
|
if (!r)
|
|
116
113
|
return;
|
|
117
114
|
const o = new Promise(
|
|
118
|
-
(
|
|
115
|
+
(u) => r.addEventListener("canplay", () => u(), {
|
|
119
116
|
once: !0
|
|
120
117
|
})
|
|
121
118
|
);
|
|
122
|
-
r.src = d.streamUrl, r.currentTime =
|
|
119
|
+
r.src = d.streamUrl, r.currentTime = t, r.load();
|
|
123
120
|
const a = new Promise(
|
|
124
|
-
(
|
|
121
|
+
(u) => r.addEventListener(
|
|
125
122
|
"durationchange",
|
|
126
123
|
(m) => {
|
|
127
|
-
m.target instanceof HTMLMediaElement &&
|
|
124
|
+
m.target instanceof HTMLMediaElement && u(m.target.duration);
|
|
128
125
|
},
|
|
129
126
|
{ once: !0 }
|
|
130
127
|
)
|
|
131
128
|
);
|
|
132
129
|
if (await o, this.currentStreamingSessionId !== d.streamingSessionId)
|
|
133
130
|
return;
|
|
134
|
-
const l = await a,
|
|
135
|
-
assetPosition:
|
|
131
|
+
const l = await a, h = g({
|
|
132
|
+
assetPosition: t,
|
|
136
133
|
duration: l,
|
|
137
134
|
playbackInfo: n,
|
|
138
135
|
streamInfo: d
|
|
139
136
|
});
|
|
140
137
|
return c.saveMediaProductTransition(
|
|
141
138
|
d.streamingSessionId,
|
|
142
|
-
{ mediaProduct: s, playbackContext:
|
|
139
|
+
{ mediaProduct: s, playbackContext: h }
|
|
143
140
|
), this.debugLog("dispatching mediaProductTransition"), S.dispatchEvent(
|
|
144
|
-
p(s,
|
|
141
|
+
p(s, h)
|
|
145
142
|
), this.#s ? (this.#s = !1, this.play()) : Promise.resolve();
|
|
146
143
|
}
|
|
147
144
|
async next(e) {
|
|
148
145
|
this.debugLog("next", e), this.playbackState === "IDLE" && (this.playbackState = "NOT_PLAYING");
|
|
149
|
-
const { mediaProduct:
|
|
146
|
+
const { mediaProduct: i, playbackInfo: t, streamInfo: s } = e, n = this.#a;
|
|
150
147
|
if (this.preloadedStreamingSessionId = s.streamingSessionId, !n)
|
|
151
148
|
return;
|
|
152
149
|
n.src = s.streamUrl, n.load();
|
|
@@ -161,16 +158,16 @@ class f extends I {
|
|
|
161
158
|
), r = g({
|
|
162
159
|
assetPosition: 0,
|
|
163
160
|
duration: d,
|
|
164
|
-
playbackInfo:
|
|
161
|
+
playbackInfo: t,
|
|
165
162
|
streamInfo: s
|
|
166
163
|
});
|
|
167
164
|
c.saveMediaProductTransition(
|
|
168
165
|
s.streamingSessionId,
|
|
169
166
|
{
|
|
170
|
-
mediaProduct:
|
|
167
|
+
mediaProduct: i,
|
|
171
168
|
playbackContext: r
|
|
172
169
|
}
|
|
173
|
-
);
|
|
170
|
+
), this.#i = !1;
|
|
174
171
|
}
|
|
175
172
|
pause() {
|
|
176
173
|
this.debugLog("pause"), this.mediaElement && this.mediaElement.pause();
|
|
@@ -182,25 +179,26 @@ class f extends I {
|
|
|
182
179
|
}
|
|
183
180
|
async playbackEngineEndedHandler(e) {
|
|
184
181
|
if (this.isActivePlayer) {
|
|
185
|
-
const { reason:
|
|
186
|
-
|
|
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"));
|
|
187
184
|
}
|
|
188
185
|
}
|
|
189
186
|
async reset({ keepPreload: e } = { keepPreload: !1 }) {
|
|
190
|
-
if (this.#
|
|
187
|
+
if (this.#i)
|
|
191
188
|
return Promise.resolve();
|
|
192
189
|
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:
|
|
194
|
-
return
|
|
195
|
-
(
|
|
196
|
-
)), this.#
|
|
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();
|
|
197
194
|
}
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
198
196
|
seek(e) {
|
|
199
197
|
this.debugLog("seek", e);
|
|
200
|
-
const { currentPlayer:
|
|
201
|
-
if (
|
|
202
|
-
return this.seekStart(this.currentTime), "fastSeek" in
|
|
203
|
-
|
|
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), {
|
|
204
202
|
once: !0
|
|
205
203
|
});
|
|
206
204
|
});
|
|
@@ -214,16 +212,14 @@ class f extends I {
|
|
|
214
212
|
this.playbackState = "NOT_PLAYING";
|
|
215
213
|
return;
|
|
216
214
|
}
|
|
217
|
-
this.debugLog(
|
|
215
|
+
if (this.debugLog(
|
|
218
216
|
"skipToPreloadedMediaProduct",
|
|
219
217
|
this.preloadedStreamingSessionId
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
this.currentPlayer = t, this.currentStreamingSessionId = String(this.preloadedStreamingSessionId), this.preloadedStreamingSessionId = void 0;
|
|
224
|
-
const { mediaProduct: i, playbackContext: s } = e;
|
|
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;
|
|
225
221
|
S.dispatchEvent(
|
|
226
|
-
p(i,
|
|
222
|
+
p(i, t)
|
|
227
223
|
), this.playbackState === "IDLE" && (this.playbackState = "NOT_PLAYING");
|
|
228
224
|
}
|
|
229
225
|
}
|
|
@@ -236,20 +232,20 @@ class f extends I {
|
|
|
236
232
|
"unloadPreloadedMediaProduct",
|
|
237
233
|
this.preloadedStreamingSessionId
|
|
238
234
|
), this.cleanUpStoredPreloadInfo();
|
|
239
|
-
const e = this.#
|
|
235
|
+
const e = this.#a;
|
|
240
236
|
e && (e.src = "", e.load());
|
|
241
237
|
}
|
|
242
238
|
get currentPlayer() {
|
|
243
239
|
return this.#t;
|
|
244
240
|
}
|
|
245
241
|
set currentPlayer(e) {
|
|
246
|
-
this.debugLog("set currentPlayer", e), this.#t && (this.#
|
|
242
|
+
this.debugLog("set currentPlayer", e), this.#t && (this.#n(this.#t, !1), this.#t.load()), e && (this.#t = e, this.#n(e, !0));
|
|
247
243
|
}
|
|
248
244
|
get mediaElement() {
|
|
249
245
|
return this.currentPlayer ?? null;
|
|
250
246
|
}
|
|
251
247
|
get ready() {
|
|
252
|
-
return this.#
|
|
248
|
+
return this.#d;
|
|
253
249
|
}
|
|
254
250
|
get volume() {
|
|
255
251
|
return E("desiredVolumeLevel");
|