@aigamo/nostalgic-diva 1.5.1 → 1.5.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/components/PlayerContainer.d.ts +4 -3
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +402 -382
- package/dist/index.es.js.map +1 -1
- package/dist/players/AudioPlayerApi.d.ts +0 -5
- package/dist/players/NiconicoPlayerApi.d.ts +0 -5
- package/dist/players/PlayerApi.d.ts +3 -5
- package/dist/players/PlayerApiImpl.d.ts +3 -4
- package/dist/players/SoundCloudPlayerApi.d.ts +1 -6
- package/dist/players/VimeoPlayerApi.d.ts +1 -6
- package/dist/players/YouTubePlayerApi.d.ts +1 -7
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
var
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var F = (r, e, t) => e in r ? R(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var v = (r, e, t) => (F(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import i, { useRef as V } from "react";
|
|
5
|
+
var c = /* @__PURE__ */ ((r) => (r[r.Trace = 0] = "Trace", r[r.Debug = 1] = "Debug", r[r.Information = 2] = "Information", r[r.Warning = 3] = "Warning", r[r.Error = 4] = "Error", r[r.Critical = 5] = "Critical", r[r.None = 6] = "None", r))(c || {});
|
|
6
6
|
class E {
|
|
7
|
-
constructor(
|
|
8
|
-
this.logger =
|
|
7
|
+
constructor(e, t, a) {
|
|
8
|
+
this.logger = e, this.player = t, this.options = a, this.logger.log(c.Debug, "ctor");
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
class
|
|
12
|
-
constructor(e, t, i) {
|
|
13
|
-
super(e, t, i);
|
|
14
|
-
y(this, "player");
|
|
15
|
-
this.player = t.current;
|
|
16
|
-
}
|
|
11
|
+
class Y extends E {
|
|
17
12
|
async attach() {
|
|
18
13
|
this.player.onerror = (e) => {
|
|
19
|
-
var t,
|
|
20
|
-
return (
|
|
14
|
+
var t, a;
|
|
15
|
+
return (a = (t = this.options) == null ? void 0 : t.onError) == null ? void 0 : a.call(t, e);
|
|
21
16
|
}, this.player.onloadeddata = () => {
|
|
22
17
|
var e, t;
|
|
23
18
|
return (t = (e = this.options) == null ? void 0 : e.onLoaded) == null ? void 0 : t.call(e, { id: this.player.src });
|
|
@@ -70,40 +65,39 @@ class j extends E {
|
|
|
70
65
|
return this.player.volume;
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
|
-
const
|
|
74
|
-
constructor(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.logger =
|
|
68
|
+
const N = class {
|
|
69
|
+
constructor(e, t, a, s, o) {
|
|
70
|
+
v(this, "id");
|
|
71
|
+
v(this, "impl");
|
|
72
|
+
this.logger = e, this.type = t, this.player = a, this.options = s, this.playerApiFactory = o, this.id = N.nextId++;
|
|
78
73
|
}
|
|
79
|
-
createMessage(
|
|
80
|
-
return `${this.type}#${this.id} ${
|
|
74
|
+
createMessage(e) {
|
|
75
|
+
return `${this.type}#${this.id} ${e}`;
|
|
81
76
|
}
|
|
82
|
-
debug(
|
|
77
|
+
debug(e, ...t) {
|
|
83
78
|
this.logger.log(
|
|
84
|
-
|
|
85
|
-
this.createMessage(
|
|
86
|
-
...
|
|
79
|
+
c.Debug,
|
|
80
|
+
this.createMessage(e),
|
|
81
|
+
...t
|
|
87
82
|
);
|
|
88
83
|
}
|
|
89
|
-
error(
|
|
84
|
+
error(e, ...t) {
|
|
90
85
|
this.logger.log(
|
|
91
|
-
|
|
92
|
-
this.createMessage(
|
|
93
|
-
...
|
|
86
|
+
c.Error,
|
|
87
|
+
this.createMessage(e),
|
|
88
|
+
...t
|
|
94
89
|
);
|
|
95
90
|
}
|
|
96
|
-
async attach(
|
|
97
|
-
|
|
98
|
-
if (this.debug("attach", a), this.impl) {
|
|
91
|
+
async attach(e) {
|
|
92
|
+
if (this.debug("attach", e), this.impl) {
|
|
99
93
|
this.debug("player is already attached");
|
|
100
94
|
return;
|
|
101
95
|
}
|
|
102
|
-
|
|
96
|
+
this.debug("Attaching player..."), this.impl = new this.playerApiFactory(
|
|
103
97
|
this.logger,
|
|
104
|
-
this.
|
|
98
|
+
this.player,
|
|
105
99
|
this.options
|
|
106
|
-
), await this.impl.attach(
|
|
100
|
+
), await this.impl.attach(e), this.debug("player attached");
|
|
107
101
|
}
|
|
108
102
|
createPlayerNotAttachedError() {
|
|
109
103
|
return new Error("player is not attached");
|
|
@@ -113,10 +107,10 @@ const S = class {
|
|
|
113
107
|
throw this.createPlayerNotAttachedError();
|
|
114
108
|
await this.impl.detach(), this.impl = void 0;
|
|
115
109
|
}
|
|
116
|
-
async loadVideo(
|
|
117
|
-
if (this.debug("loadVideo",
|
|
110
|
+
async loadVideo(e) {
|
|
111
|
+
if (this.debug("loadVideo", e), this.impl === void 0)
|
|
118
112
|
throw this.createPlayerNotAttachedError();
|
|
119
|
-
this.debug("Loading video..."), await this.impl.loadVideo(
|
|
113
|
+
this.debug("Loading video..."), await this.impl.loadVideo(e), this.debug("video loaded", e);
|
|
120
114
|
}
|
|
121
115
|
play() {
|
|
122
116
|
if (this.debug("play"), this.impl === void 0)
|
|
@@ -128,20 +122,20 @@ const S = class {
|
|
|
128
122
|
throw this.createPlayerNotAttachedError();
|
|
129
123
|
return this.impl.pause();
|
|
130
124
|
}
|
|
131
|
-
setCurrentTime(
|
|
132
|
-
if (this.debug("setCurrentTime",
|
|
125
|
+
setCurrentTime(e) {
|
|
126
|
+
if (this.debug("setCurrentTime", e), this.impl === void 0)
|
|
133
127
|
throw this.createPlayerNotAttachedError();
|
|
134
|
-
return this.impl.setCurrentTime(
|
|
128
|
+
return this.impl.setCurrentTime(e);
|
|
135
129
|
}
|
|
136
|
-
setVolume(
|
|
137
|
-
if (this.debug("setVolume",
|
|
130
|
+
setVolume(e) {
|
|
131
|
+
if (this.debug("setVolume", e), this.impl === void 0)
|
|
138
132
|
throw this.createPlayerNotAttachedError();
|
|
139
|
-
return this.impl.setVolume(
|
|
133
|
+
return this.impl.setVolume(e);
|
|
140
134
|
}
|
|
141
|
-
setMuted(
|
|
142
|
-
if (this.debug("setMuted",
|
|
135
|
+
setMuted(e) {
|
|
136
|
+
if (this.debug("setMuted", e), this.impl === void 0)
|
|
143
137
|
throw this.createPlayerNotAttachedError();
|
|
144
|
-
return this.impl.setMuted(
|
|
138
|
+
return this.impl.setMuted(e);
|
|
145
139
|
}
|
|
146
140
|
getDuration() {
|
|
147
141
|
if (this.debug("getDuration"), this.impl === void 0)
|
|
@@ -159,63 +153,85 @@ const S = class {
|
|
|
159
153
|
return this.impl.getVolume();
|
|
160
154
|
}
|
|
161
155
|
};
|
|
162
|
-
let
|
|
163
|
-
|
|
164
|
-
function
|
|
156
|
+
let C = N;
|
|
157
|
+
v(C, "nextId", 1);
|
|
158
|
+
function W() {
|
|
165
159
|
const r = V(!0);
|
|
166
160
|
return r.current ? (r.current = !1, !0) : r.current;
|
|
167
161
|
}
|
|
168
|
-
const
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
return
|
|
162
|
+
const j = (r, e) => r === e;
|
|
163
|
+
function $(r, e = j) {
|
|
164
|
+
const t = V(), a = V(r);
|
|
165
|
+
return !W() && !e(a.current, r) && (t.current = a.current, a.current = r), t.current;
|
|
172
166
|
}
|
|
173
|
-
const
|
|
167
|
+
const f = ({
|
|
174
168
|
logger: r,
|
|
175
|
-
type:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
169
|
+
type: e,
|
|
170
|
+
loadScript: t,
|
|
171
|
+
playerFactory: a,
|
|
172
|
+
playerApiRef: s,
|
|
173
|
+
videoId: o,
|
|
174
|
+
options: n,
|
|
180
175
|
playerApiFactory: u,
|
|
181
|
-
children:
|
|
176
|
+
children: d
|
|
182
177
|
}) => {
|
|
183
|
-
r.log(
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
r.log(c.Debug, "PlayerContainer");
|
|
179
|
+
const y = i.useRef(o), p = i.useRef(void 0), [g, m] = i.useState(), [l, h] = i.useState();
|
|
180
|
+
i.useEffect(() => {
|
|
181
|
+
((t == null ? void 0 : t()) ?? Promise.resolve()).then(() => {
|
|
182
|
+
a(p.current).then((b) => {
|
|
183
|
+
m(b);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}, [t, a]), i.useEffect(() => {
|
|
187
|
+
if (g === void 0)
|
|
188
|
+
return;
|
|
189
|
+
const b = new C(
|
|
187
190
|
r,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
c,
|
|
191
|
+
e,
|
|
192
|
+
g,
|
|
193
|
+
n,
|
|
192
194
|
u
|
|
193
195
|
);
|
|
194
|
-
return
|
|
195
|
-
if (
|
|
196
|
+
return s && (s.current = b), b.attach(y.current).then(() => h(b)), () => {
|
|
197
|
+
if (s && b !== s.current)
|
|
196
198
|
throw new Error("playerApi differs");
|
|
197
|
-
|
|
199
|
+
b.detach().finally(() => h(void 0));
|
|
198
200
|
};
|
|
199
|
-
}, [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
}, [
|
|
202
|
+
r,
|
|
203
|
+
e,
|
|
204
|
+
t,
|
|
205
|
+
g,
|
|
206
|
+
n,
|
|
207
|
+
u,
|
|
208
|
+
s
|
|
209
|
+
]);
|
|
210
|
+
const w = $(o);
|
|
211
|
+
return i.useEffect(() => {
|
|
212
|
+
w !== void 0 && (l == null || l.loadVideo(o));
|
|
213
|
+
}, [w, o, l]), /* @__PURE__ */ i.createElement(i.Fragment, null, d(p, y.current));
|
|
214
|
+
}, x = i.memo(
|
|
205
215
|
({ ...r }) => {
|
|
206
|
-
const { logger:
|
|
207
|
-
|
|
208
|
-
|
|
216
|
+
const { logger: e } = r;
|
|
217
|
+
e.log(c.Debug, "AudioPlayer");
|
|
218
|
+
const t = i.useCallback(
|
|
219
|
+
(a) => Promise.resolve(a),
|
|
220
|
+
[]
|
|
221
|
+
);
|
|
222
|
+
return /* @__PURE__ */ i.createElement(
|
|
223
|
+
f,
|
|
209
224
|
{
|
|
210
225
|
...r,
|
|
211
226
|
loadScript: void 0,
|
|
212
|
-
|
|
227
|
+
playerFactory: t,
|
|
228
|
+
playerApiFactory: Y
|
|
213
229
|
},
|
|
214
|
-
(
|
|
230
|
+
(a, s) => /* @__PURE__ */ i.createElement(
|
|
215
231
|
"audio",
|
|
216
232
|
{
|
|
217
|
-
ref:
|
|
218
|
-
src:
|
|
233
|
+
ref: a,
|
|
234
|
+
src: s,
|
|
219
235
|
style: { width: "100%", height: "100%" },
|
|
220
236
|
preload: "auto",
|
|
221
237
|
autoPlay: !0,
|
|
@@ -226,69 +242,67 @@ const b = ({
|
|
|
226
242
|
}
|
|
227
243
|
);
|
|
228
244
|
var I = /* @__PURE__ */ ((r) => (r[r.Play = 2] = "Play", r[r.Pause = 3] = "Pause", r[r.End = 4] = "End", r))(I || {});
|
|
229
|
-
const
|
|
230
|
-
constructor(
|
|
231
|
-
super(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (e.origin !== D.origin)
|
|
245
|
+
const P = class extends E {
|
|
246
|
+
constructor() {
|
|
247
|
+
super(...arguments);
|
|
248
|
+
v(this, "duration");
|
|
249
|
+
v(this, "currentTime");
|
|
250
|
+
v(this, "volume");
|
|
251
|
+
v(this, "handleMessage", (t) => {
|
|
252
|
+
var s, o, n, u, d, y, p, g, m, l, h, w, b, U;
|
|
253
|
+
if (t.origin !== P.origin)
|
|
239
254
|
return;
|
|
240
|
-
const
|
|
241
|
-
switch (
|
|
255
|
+
const a = t.data;
|
|
256
|
+
switch (a.eventName) {
|
|
242
257
|
case "playerStatusChange":
|
|
243
258
|
this.logger.log(
|
|
244
|
-
|
|
245
|
-
`player status changed: ${I[
|
|
259
|
+
c.Debug,
|
|
260
|
+
`player status changed: ${I[a.data.playerStatus] ?? a.data.playerStatus}`
|
|
246
261
|
);
|
|
247
262
|
break;
|
|
248
263
|
case "statusChange":
|
|
249
264
|
switch (this.logger.log(
|
|
250
|
-
|
|
251
|
-
`status changed: ${I[
|
|
252
|
-
),
|
|
265
|
+
c.Debug,
|
|
266
|
+
`status changed: ${I[a.data.playerStatus] ?? a.data.playerStatus}`
|
|
267
|
+
), a.data.playerStatus) {
|
|
253
268
|
case 2:
|
|
254
|
-
(
|
|
269
|
+
(o = (s = this.options) == null ? void 0 : s.onPlay) == null || o.call(s);
|
|
255
270
|
break;
|
|
256
271
|
case 3:
|
|
257
|
-
(
|
|
272
|
+
(u = (n = this.options) == null ? void 0 : n.onPause) == null || u.call(n);
|
|
258
273
|
break;
|
|
259
274
|
case 4:
|
|
260
|
-
(
|
|
275
|
+
(y = (d = this.options) == null ? void 0 : d.onEnded) == null || y.call(d);
|
|
261
276
|
break;
|
|
262
277
|
}
|
|
263
278
|
break;
|
|
264
279
|
case "playerMetadataChange":
|
|
265
|
-
|
|
280
|
+
a.data.duration !== void 0 && (this.duration = a.data.duration / 1e3), this.currentTime = a.data.currentTime === void 0 ? void 0 : a.data.currentTime / 1e3, this.volume = a.data.volume, (g = (p = this.options) == null ? void 0 : p.onTimeUpdate) == null || g.call(p, {
|
|
266
281
|
duration: this.duration,
|
|
267
282
|
percent: this.currentTime !== void 0 && this.duration !== void 0 ? this.currentTime / this.duration : void 0,
|
|
268
283
|
seconds: this.currentTime
|
|
269
284
|
});
|
|
270
285
|
break;
|
|
271
286
|
case "loadComplete":
|
|
272
|
-
this.logger.log(
|
|
287
|
+
this.logger.log(c.Debug, "load completed"), this.duration = a.data.videoInfo.lengthInSeconds, (l = (m = this.options) == null ? void 0 : m.onLoaded) == null || l.call(m, { id: a.data.videoInfo.watchId });
|
|
273
288
|
break;
|
|
274
289
|
case "error":
|
|
275
|
-
(
|
|
290
|
+
(w = (h = this.options) == null ? void 0 : h.onError) == null || w.call(h, a);
|
|
276
291
|
break;
|
|
277
292
|
case "player-error:video:play":
|
|
278
293
|
case "player-error:video:seek":
|
|
279
|
-
(
|
|
294
|
+
(U = (b = this.options) == null ? void 0 : b.onError) == null || U.call(b, a);
|
|
280
295
|
break;
|
|
281
296
|
default:
|
|
282
297
|
this.logger.log(
|
|
283
|
-
|
|
298
|
+
c.Debug,
|
|
284
299
|
"message",
|
|
285
|
-
|
|
286
|
-
|
|
300
|
+
a.eventName,
|
|
301
|
+
a.data
|
|
287
302
|
);
|
|
288
303
|
break;
|
|
289
304
|
}
|
|
290
305
|
});
|
|
291
|
-
this.player = t.current;
|
|
292
306
|
}
|
|
293
307
|
async attach() {
|
|
294
308
|
window.addEventListener("message", this.handleMessage);
|
|
@@ -296,23 +310,23 @@ const D = class extends E {
|
|
|
296
310
|
async detach() {
|
|
297
311
|
window.removeEventListener("message", this.handleMessage);
|
|
298
312
|
}
|
|
299
|
-
async loadVideo(
|
|
300
|
-
return new Promise((
|
|
313
|
+
async loadVideo(t) {
|
|
314
|
+
return new Promise((a, s) => {
|
|
301
315
|
this.duration = void 0, this.currentTime = void 0, this.player.onload = () => {
|
|
302
|
-
this.player.onload = null,
|
|
303
|
-
}, this.player.src = `https://embed.nicovideo.jp/watch/${
|
|
316
|
+
this.player.onload = null, a();
|
|
317
|
+
}, this.player.src = `https://embed.nicovideo.jp/watch/${t}?jsapi=1&playerId=1`;
|
|
304
318
|
});
|
|
305
319
|
}
|
|
306
320
|
// https://blog.hayu.io/web/create/nicovideo-embed-player-api/.
|
|
307
|
-
postMessage(
|
|
308
|
-
var
|
|
309
|
-
(
|
|
321
|
+
postMessage(t) {
|
|
322
|
+
var a;
|
|
323
|
+
(a = this.player.contentWindow) == null || a.postMessage(
|
|
310
324
|
{
|
|
311
|
-
...
|
|
325
|
+
...t,
|
|
312
326
|
playerId: "1",
|
|
313
327
|
sourceConnectorType: 1
|
|
314
328
|
},
|
|
315
|
-
|
|
329
|
+
P.origin
|
|
316
330
|
);
|
|
317
331
|
}
|
|
318
332
|
async play() {
|
|
@@ -321,19 +335,19 @@ const D = class extends E {
|
|
|
321
335
|
async pause() {
|
|
322
336
|
this.postMessage({ eventName: "pause" });
|
|
323
337
|
}
|
|
324
|
-
async setCurrentTime(
|
|
325
|
-
this.postMessage({ eventName: "seek", data: { time:
|
|
338
|
+
async setCurrentTime(t) {
|
|
339
|
+
this.postMessage({ eventName: "seek", data: { time: t * 1e3 } });
|
|
326
340
|
}
|
|
327
|
-
async setVolume(
|
|
341
|
+
async setVolume(t) {
|
|
328
342
|
this.postMessage({
|
|
329
343
|
eventName: "volumeChange",
|
|
330
|
-
data: { volume:
|
|
344
|
+
data: { volume: t }
|
|
331
345
|
});
|
|
332
346
|
}
|
|
333
|
-
async setMuted(
|
|
347
|
+
async setMuted(t) {
|
|
334
348
|
this.postMessage({
|
|
335
349
|
eventName: "mute",
|
|
336
|
-
data: { mute:
|
|
350
|
+
data: { mute: t }
|
|
337
351
|
});
|
|
338
352
|
}
|
|
339
353
|
async getDuration() {
|
|
@@ -346,23 +360,29 @@ const D = class extends E {
|
|
|
346
360
|
return this.volume;
|
|
347
361
|
}
|
|
348
362
|
};
|
|
349
|
-
let
|
|
350
|
-
|
|
351
|
-
const
|
|
363
|
+
let T = P;
|
|
364
|
+
v(T, "origin", "https://embed.nicovideo.jp");
|
|
365
|
+
const G = i.memo(
|
|
352
366
|
({ ...r }) => {
|
|
353
|
-
const { logger:
|
|
354
|
-
|
|
355
|
-
|
|
367
|
+
const { logger: e } = r;
|
|
368
|
+
e.log(c.Debug, "NiconicoPlayer");
|
|
369
|
+
const t = i.useCallback(
|
|
370
|
+
(a) => Promise.resolve(a),
|
|
371
|
+
[]
|
|
372
|
+
);
|
|
373
|
+
return /* @__PURE__ */ i.createElement(
|
|
374
|
+
f,
|
|
356
375
|
{
|
|
357
376
|
...r,
|
|
358
377
|
loadScript: void 0,
|
|
359
|
-
|
|
378
|
+
playerFactory: t,
|
|
379
|
+
playerApiFactory: T
|
|
360
380
|
},
|
|
361
|
-
(
|
|
381
|
+
(a, s) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement(
|
|
362
382
|
"iframe",
|
|
363
383
|
{
|
|
364
|
-
ref:
|
|
365
|
-
src: `https://embed.nicovideo.jp/watch/${
|
|
384
|
+
ref: a,
|
|
385
|
+
src: `https://embed.nicovideo.jp/watch/${s}?jsapi=1&playerId=1`,
|
|
366
386
|
width: "100%",
|
|
367
387
|
height: "100%",
|
|
368
388
|
allowFullScreen: !0,
|
|
@@ -372,168 +392,163 @@ const O = s.memo(
|
|
|
372
392
|
))
|
|
373
393
|
);
|
|
374
394
|
}
|
|
375
|
-
),
|
|
395
|
+
), M = i.createContext(
|
|
376
396
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
377
397
|
void 0
|
|
378
|
-
),
|
|
398
|
+
), B = new class {
|
|
379
399
|
constructor() {
|
|
380
|
-
|
|
400
|
+
v(this, "title", "nostalgic-diva");
|
|
381
401
|
}
|
|
382
402
|
createMessage(r) {
|
|
383
403
|
return `[${this.title}] ${r}`;
|
|
384
404
|
}
|
|
385
|
-
debug(r, ...
|
|
386
|
-
console.debug(this.createMessage(r), ...
|
|
405
|
+
debug(r, ...e) {
|
|
406
|
+
console.debug(this.createMessage(r), ...e);
|
|
387
407
|
}
|
|
388
|
-
error(r, ...
|
|
389
|
-
console.error(this.createMessage(r), ...
|
|
408
|
+
error(r, ...e) {
|
|
409
|
+
console.error(this.createMessage(r), ...e);
|
|
390
410
|
}
|
|
391
|
-
warn(r, ...
|
|
392
|
-
console.warn(this.createMessage(r), ...
|
|
411
|
+
warn(r, ...e) {
|
|
412
|
+
console.warn(this.createMessage(r), ...e);
|
|
393
413
|
}
|
|
394
414
|
isEnabled() {
|
|
395
415
|
return !0;
|
|
396
416
|
}
|
|
397
|
-
log(r,
|
|
417
|
+
log(r, e, ...t) {
|
|
398
418
|
switch (r) {
|
|
399
|
-
case
|
|
400
|
-
this.debug(
|
|
419
|
+
case c.Debug:
|
|
420
|
+
this.debug(e, ...t);
|
|
401
421
|
break;
|
|
402
|
-
case
|
|
403
|
-
this.warn(
|
|
422
|
+
case c.Warning:
|
|
423
|
+
this.warn(e, ...t);
|
|
404
424
|
break;
|
|
405
|
-
case
|
|
406
|
-
this.error(
|
|
425
|
+
case c.Error:
|
|
426
|
+
this.error(e, ...t);
|
|
407
427
|
break;
|
|
408
428
|
}
|
|
409
429
|
}
|
|
410
430
|
}(), ee = ({
|
|
411
|
-
logger: r =
|
|
412
|
-
children:
|
|
431
|
+
logger: r = B,
|
|
432
|
+
children: e
|
|
413
433
|
}) => {
|
|
414
|
-
const
|
|
415
|
-
var
|
|
416
|
-
await ((
|
|
417
|
-
}, []),
|
|
418
|
-
var
|
|
419
|
-
await ((
|
|
420
|
-
}, []),
|
|
421
|
-
var
|
|
422
|
-
await ((
|
|
423
|
-
}, []),
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
}, []),
|
|
427
|
-
var
|
|
428
|
-
await ((
|
|
429
|
-
}, []),
|
|
430
|
-
var
|
|
431
|
-
await ((
|
|
432
|
-
}, []),
|
|
433
|
-
var
|
|
434
|
-
return await ((
|
|
435
|
-
}, []),
|
|
436
|
-
var
|
|
437
|
-
return await ((
|
|
438
|
-
}, []),
|
|
439
|
-
var
|
|
440
|
-
return await ((
|
|
441
|
-
}, []),
|
|
434
|
+
const t = i.useRef(), a = i.useCallback(async (l) => {
|
|
435
|
+
var h;
|
|
436
|
+
await ((h = t.current) == null ? void 0 : h.loadVideo(l));
|
|
437
|
+
}, []), s = i.useCallback(async () => {
|
|
438
|
+
var l;
|
|
439
|
+
await ((l = t.current) == null ? void 0 : l.play());
|
|
440
|
+
}, []), o = i.useCallback(async () => {
|
|
441
|
+
var l;
|
|
442
|
+
await ((l = t.current) == null ? void 0 : l.pause());
|
|
443
|
+
}, []), n = i.useCallback(async (l) => {
|
|
444
|
+
const h = t.current;
|
|
445
|
+
h && (await h.setCurrentTime(l), await h.play());
|
|
446
|
+
}, []), u = i.useCallback(async (l) => {
|
|
447
|
+
var h;
|
|
448
|
+
await ((h = t.current) == null ? void 0 : h.setVolume(l));
|
|
449
|
+
}, []), d = i.useCallback(async (l) => {
|
|
450
|
+
var h;
|
|
451
|
+
await ((h = t.current) == null ? void 0 : h.setMuted(l));
|
|
452
|
+
}, []), y = i.useCallback(async () => {
|
|
453
|
+
var l;
|
|
454
|
+
return await ((l = t.current) == null ? void 0 : l.getDuration());
|
|
455
|
+
}, []), p = i.useCallback(async () => {
|
|
456
|
+
var l;
|
|
457
|
+
return await ((l = t.current) == null ? void 0 : l.getCurrentTime());
|
|
458
|
+
}, []), g = i.useCallback(async () => {
|
|
459
|
+
var l;
|
|
460
|
+
return await ((l = t.current) == null ? void 0 : l.getVolume());
|
|
461
|
+
}, []), m = i.useMemo(
|
|
442
462
|
() => ({
|
|
443
463
|
logger: r,
|
|
444
|
-
playerApiRef:
|
|
445
|
-
loadVideo:
|
|
446
|
-
play:
|
|
447
|
-
pause:
|
|
448
|
-
setCurrentTime:
|
|
449
|
-
setVolume:
|
|
450
|
-
setMuted:
|
|
451
|
-
getDuration:
|
|
452
|
-
getCurrentTime:
|
|
453
|
-
getVolume:
|
|
464
|
+
playerApiRef: t,
|
|
465
|
+
loadVideo: a,
|
|
466
|
+
play: s,
|
|
467
|
+
pause: o,
|
|
468
|
+
setCurrentTime: n,
|
|
469
|
+
setVolume: u,
|
|
470
|
+
setMuted: d,
|
|
471
|
+
getDuration: y,
|
|
472
|
+
getCurrentTime: p,
|
|
473
|
+
getVolume: g
|
|
454
474
|
}),
|
|
455
475
|
[
|
|
456
476
|
r,
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
c,
|
|
460
|
-
u,
|
|
477
|
+
a,
|
|
478
|
+
s,
|
|
461
479
|
o,
|
|
462
|
-
|
|
480
|
+
n,
|
|
481
|
+
u,
|
|
482
|
+
d,
|
|
483
|
+
y,
|
|
463
484
|
p,
|
|
464
|
-
|
|
465
|
-
w
|
|
485
|
+
g
|
|
466
486
|
]
|
|
467
487
|
);
|
|
468
|
-
return /* @__PURE__ */
|
|
469
|
-
},
|
|
470
|
-
class
|
|
471
|
-
constructor(e, t, i) {
|
|
472
|
-
super(e, t, i);
|
|
473
|
-
y(this, "player");
|
|
474
|
-
this.player = SC.Widget(this.playerElementRef.current);
|
|
475
|
-
}
|
|
488
|
+
return /* @__PURE__ */ i.createElement(M.Provider, { value: m }, e);
|
|
489
|
+
}, O = () => i.useContext(M);
|
|
490
|
+
class k extends E {
|
|
476
491
|
getDurationCore() {
|
|
477
492
|
return new Promise((e, t) => {
|
|
478
493
|
this.player.getDuration(e);
|
|
479
494
|
});
|
|
480
495
|
}
|
|
481
496
|
attach(e) {
|
|
482
|
-
return new Promise((t,
|
|
497
|
+
return new Promise((t, a) => {
|
|
483
498
|
this.player.bind(SC.Widget.Events.READY, () => {
|
|
484
|
-
var
|
|
499
|
+
var s, o;
|
|
485
500
|
this.player.bind(
|
|
486
501
|
SC.Widget.Events.PLAY_PROGRESS,
|
|
487
|
-
async (
|
|
488
|
-
var
|
|
489
|
-
const
|
|
490
|
-
(
|
|
491
|
-
duration:
|
|
492
|
-
percent:
|
|
493
|
-
seconds:
|
|
502
|
+
async (n) => {
|
|
503
|
+
var d, y;
|
|
504
|
+
const u = await this.getDurationCore();
|
|
505
|
+
(y = (d = this.options) == null ? void 0 : d.onTimeUpdate) == null || y.call(d, {
|
|
506
|
+
duration: u / 1e3,
|
|
507
|
+
percent: n.currentPosition / u,
|
|
508
|
+
seconds: n.currentPosition / 1e3
|
|
494
509
|
});
|
|
495
510
|
}
|
|
496
511
|
), this.player.bind(
|
|
497
512
|
SC.Widget.Events.ERROR,
|
|
498
|
-
(
|
|
499
|
-
var
|
|
500
|
-
return (
|
|
513
|
+
(n) => {
|
|
514
|
+
var u, d;
|
|
515
|
+
return (d = (u = this.options) == null ? void 0 : u.onError) == null ? void 0 : d.call(u, n);
|
|
501
516
|
}
|
|
502
517
|
), this.player.bind(
|
|
503
518
|
SC.Widget.Events.PLAY,
|
|
504
519
|
() => {
|
|
505
|
-
var
|
|
506
|
-
return (
|
|
520
|
+
var n, u;
|
|
521
|
+
return (u = (n = this.options) == null ? void 0 : n.onPlay) == null ? void 0 : u.call(n);
|
|
507
522
|
}
|
|
508
523
|
), this.player.bind(
|
|
509
524
|
SC.Widget.Events.PAUSE,
|
|
510
525
|
() => {
|
|
511
|
-
var
|
|
512
|
-
return (
|
|
526
|
+
var n, u;
|
|
527
|
+
return (u = (n = this.options) == null ? void 0 : n.onPause) == null ? void 0 : u.call(n);
|
|
513
528
|
}
|
|
514
529
|
), this.player.bind(
|
|
515
530
|
SC.Widget.Events.FINISH,
|
|
516
531
|
() => {
|
|
517
|
-
var
|
|
518
|
-
return (
|
|
532
|
+
var n, u;
|
|
533
|
+
return (u = (n = this.options) == null ? void 0 : n.onEnded) == null ? void 0 : u.call(n);
|
|
519
534
|
}
|
|
520
|
-
), (
|
|
535
|
+
), (o = (s = this.options) == null ? void 0 : s.onLoaded) == null || o.call(s, { id: e }), t();
|
|
521
536
|
});
|
|
522
537
|
});
|
|
523
538
|
}
|
|
524
539
|
async detach() {
|
|
525
540
|
this.player.unbind(SC.Widget.Events.READY), this.player.unbind(SC.Widget.Events.PLAY_PROGRESS), this.player.unbind(SC.Widget.Events.ERROR), this.player.unbind(SC.Widget.Events.PLAY), this.player.unbind(SC.Widget.Events.PAUSE), this.player.unbind(SC.Widget.Events.FINISH);
|
|
526
541
|
}
|
|
527
|
-
static playerLoadAsync(e, t,
|
|
528
|
-
return new Promise((
|
|
529
|
-
e.load(t, { ...
|
|
542
|
+
static playerLoadAsync(e, t, a) {
|
|
543
|
+
return new Promise((s, o) => {
|
|
544
|
+
e.load(t, { ...a, callback: s });
|
|
530
545
|
});
|
|
531
546
|
}
|
|
532
547
|
async loadVideo(e) {
|
|
533
|
-
var t,
|
|
534
|
-
await
|
|
548
|
+
var t, a;
|
|
549
|
+
await k.playerLoadAsync(this.player, e, {
|
|
535
550
|
auto_play: !0
|
|
536
|
-
}), (
|
|
551
|
+
}), (a = (t = this.options) == null ? void 0 : t.onLoaded) == null || a.call(t, { id: e });
|
|
537
552
|
}
|
|
538
553
|
async play() {
|
|
539
554
|
this.player.play();
|
|
@@ -573,49 +588,53 @@ class A extends E {
|
|
|
573
588
|
return await this.getVolumeCore() / 100;
|
|
574
589
|
}
|
|
575
590
|
}
|
|
576
|
-
function
|
|
577
|
-
return new Promise((
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
}, document.head.appendChild(
|
|
591
|
+
function H(r) {
|
|
592
|
+
return new Promise((e, t) => {
|
|
593
|
+
const a = document.createElement("script");
|
|
594
|
+
a.src = r, a.async = !0, a.onerror = t, a.onload = a.onreadystatechange = function() {
|
|
595
|
+
const s = this.readyState;
|
|
596
|
+
s && s !== "loaded" && s !== "complete" || (a.onload = a.onreadystatechange = null, e());
|
|
597
|
+
}, document.head.appendChild(a);
|
|
583
598
|
});
|
|
584
599
|
}
|
|
585
|
-
const
|
|
586
|
-
async function
|
|
587
|
-
if (
|
|
588
|
-
return
|
|
600
|
+
const D = [];
|
|
601
|
+
async function A(r, e) {
|
|
602
|
+
if (D.includes(r))
|
|
603
|
+
return e.log(c.Debug, r, "script is already loaded"), !1;
|
|
589
604
|
try {
|
|
590
|
-
return
|
|
591
|
-
} catch (
|
|
592
|
-
throw
|
|
605
|
+
return e.log(c.Debug, r, "Loading script..."), await H(r), D.includes(r) ? (e.log(c.Debug, r, "script is already loaded"), !1) : (D.push(r), e.log(c.Debug, r, "script loaded"), !0);
|
|
606
|
+
} catch (t) {
|
|
607
|
+
throw e.log(c.Error, r, "Failed to load script"), t;
|
|
593
608
|
}
|
|
594
609
|
}
|
|
595
|
-
const
|
|
610
|
+
const q = i.memo(
|
|
596
611
|
({ ...r }) => {
|
|
597
|
-
const { logger:
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
await
|
|
612
|
+
const { logger: e } = r;
|
|
613
|
+
e.log(c.Debug, "SoundCloudPlayer");
|
|
614
|
+
const t = i.useCallback(async () => {
|
|
615
|
+
await A(
|
|
601
616
|
"https://w.soundcloud.com/player/api.js",
|
|
602
|
-
|
|
617
|
+
e
|
|
603
618
|
);
|
|
604
|
-
}, [
|
|
605
|
-
|
|
606
|
-
|
|
619
|
+
}, [e]), a = i.useCallback(
|
|
620
|
+
(s) => Promise.resolve(SC.Widget(s)),
|
|
621
|
+
[]
|
|
622
|
+
);
|
|
623
|
+
return /* @__PURE__ */ i.createElement(
|
|
624
|
+
f,
|
|
607
625
|
{
|
|
608
626
|
...r,
|
|
609
|
-
loadScript:
|
|
610
|
-
|
|
627
|
+
loadScript: t,
|
|
628
|
+
playerFactory: a,
|
|
629
|
+
playerApiFactory: k
|
|
611
630
|
},
|
|
612
|
-
(
|
|
631
|
+
(s, o) => (
|
|
613
632
|
// eslint-disable-next-line jsx-a11y/iframe-has-title
|
|
614
|
-
/* @__PURE__ */
|
|
633
|
+
/* @__PURE__ */ i.createElement(
|
|
615
634
|
"iframe",
|
|
616
635
|
{
|
|
617
|
-
ref:
|
|
618
|
-
src: `https://w.soundcloud.com/player/?url=${
|
|
636
|
+
ref: s,
|
|
637
|
+
src: `https://w.soundcloud.com/player/?url=${o}`,
|
|
619
638
|
frameBorder: 0,
|
|
620
639
|
allow: "autoplay",
|
|
621
640
|
style: { width: "100%", height: "100%" }
|
|
@@ -625,21 +644,16 @@ const J = s.memo(
|
|
|
625
644
|
);
|
|
626
645
|
}
|
|
627
646
|
);
|
|
628
|
-
class
|
|
629
|
-
constructor(e, t, i) {
|
|
630
|
-
super(e, t, i);
|
|
631
|
-
y(this, "player");
|
|
632
|
-
this.player = new Vimeo.Player(this.playerElementRef.current);
|
|
633
|
-
}
|
|
647
|
+
class z extends E {
|
|
634
648
|
async attach() {
|
|
635
649
|
await this.player.ready(), this.player.on("error", (e) => {
|
|
636
|
-
var t,
|
|
637
|
-
return (
|
|
650
|
+
var t, a;
|
|
651
|
+
return (a = (t = this.options) == null ? void 0 : t.onError) == null ? void 0 : a.call(t, e);
|
|
638
652
|
}), this.player.on(
|
|
639
653
|
"loaded",
|
|
640
654
|
(e) => {
|
|
641
|
-
var t,
|
|
642
|
-
return (
|
|
655
|
+
var t, a;
|
|
656
|
+
return (a = (t = this.options) == null ? void 0 : t.onLoaded) == null ? void 0 : a.call(t, { id: e.id.toString() });
|
|
643
657
|
}
|
|
644
658
|
), this.player.on("play", () => {
|
|
645
659
|
var e, t;
|
|
@@ -651,8 +665,8 @@ class K extends E {
|
|
|
651
665
|
var e, t;
|
|
652
666
|
return (t = (e = this.options) == null ? void 0 : e.onEnded) == null ? void 0 : t.call(e);
|
|
653
667
|
}), this.player.on("timeupdate", (e) => {
|
|
654
|
-
var t,
|
|
655
|
-
(
|
|
668
|
+
var t, a;
|
|
669
|
+
(a = (t = this.options) == null ? void 0 : t.onTimeUpdate) == null || a.call(t, {
|
|
656
670
|
duration: e.duration,
|
|
657
671
|
percent: e.percent,
|
|
658
672
|
seconds: e.seconds
|
|
@@ -690,30 +704,34 @@ class K extends E {
|
|
|
690
704
|
return await this.player.getVolume();
|
|
691
705
|
}
|
|
692
706
|
}
|
|
693
|
-
const
|
|
707
|
+
const J = i.memo(
|
|
694
708
|
({ ...r }) => {
|
|
695
|
-
const { logger:
|
|
696
|
-
|
|
697
|
-
const
|
|
698
|
-
await
|
|
709
|
+
const { logger: e } = r;
|
|
710
|
+
e.log(c.Debug, "VimeoPlayer");
|
|
711
|
+
const t = i.useCallback(async () => {
|
|
712
|
+
await A(
|
|
699
713
|
"https://player.vimeo.com/api/player.js",
|
|
700
|
-
|
|
714
|
+
e
|
|
701
715
|
);
|
|
702
|
-
}, [
|
|
703
|
-
|
|
704
|
-
|
|
716
|
+
}, [e]), a = i.useCallback(
|
|
717
|
+
(s) => Promise.resolve(new Vimeo.Player(s)),
|
|
718
|
+
[]
|
|
719
|
+
);
|
|
720
|
+
return /* @__PURE__ */ i.createElement(
|
|
721
|
+
f,
|
|
705
722
|
{
|
|
706
723
|
...r,
|
|
707
|
-
loadScript:
|
|
708
|
-
|
|
724
|
+
loadScript: t,
|
|
725
|
+
playerFactory: a,
|
|
726
|
+
playerApiFactory: z
|
|
709
727
|
},
|
|
710
|
-
(
|
|
728
|
+
(s, o) => (
|
|
711
729
|
// eslint-disable-next-line jsx-a11y/iframe-has-title
|
|
712
|
-
/* @__PURE__ */
|
|
730
|
+
/* @__PURE__ */ i.createElement(
|
|
713
731
|
"iframe",
|
|
714
732
|
{
|
|
715
|
-
ref:
|
|
716
|
-
src: `https://player.vimeo.com/video/${
|
|
733
|
+
ref: s,
|
|
734
|
+
src: `https://player.vimeo.com/video/${o}`,
|
|
717
735
|
frameBorder: 0,
|
|
718
736
|
allow: "autoplay",
|
|
719
737
|
style: { width: "100%", height: "100%" }
|
|
@@ -723,88 +741,82 @@ const Q = s.memo(
|
|
|
723
741
|
);
|
|
724
742
|
}
|
|
725
743
|
);
|
|
726
|
-
var
|
|
727
|
-
|
|
728
|
-
constructor(
|
|
729
|
-
super(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
y(this, "timeUpdateIntervalId");
|
|
733
|
-
this.player = new YT.Player(this.playerElementRef.current, {
|
|
734
|
-
host: N.origin,
|
|
735
|
-
width: "100%",
|
|
736
|
-
height: "100%"
|
|
737
|
-
});
|
|
744
|
+
var S = /* @__PURE__ */ ((r) => (r[r.UNSTARTED = -1] = "UNSTARTED", r[r.ENDED = 0] = "ENDED", r[r.PLAYING = 1] = "PLAYING", r[r.PAUSED = 2] = "PAUSED", r[r.BUFFERING = 3] = "BUFFERING", r[r.CUED = 5] = "CUED", r))(S || {});
|
|
745
|
+
class K extends E {
|
|
746
|
+
constructor() {
|
|
747
|
+
super(...arguments);
|
|
748
|
+
v(this, "previousTime");
|
|
749
|
+
v(this, "timeUpdateIntervalId");
|
|
738
750
|
}
|
|
739
751
|
clearTimeUpdateInterval() {
|
|
740
752
|
this.logger.log(
|
|
741
|
-
|
|
753
|
+
c.Debug,
|
|
742
754
|
"clearTimeUpdateInterval",
|
|
743
755
|
this.timeUpdateIntervalId
|
|
744
756
|
), window.clearInterval(this.timeUpdateIntervalId), this.timeUpdateIntervalId = void 0;
|
|
745
757
|
}
|
|
746
|
-
invokeTimeUpdate(
|
|
747
|
-
var
|
|
748
|
-
const
|
|
749
|
-
if (
|
|
758
|
+
invokeTimeUpdate(t) {
|
|
759
|
+
var o, n;
|
|
760
|
+
const a = t.getCurrentTime();
|
|
761
|
+
if (a === this.previousTime)
|
|
750
762
|
return;
|
|
751
|
-
const
|
|
752
|
-
(
|
|
753
|
-
duration:
|
|
754
|
-
percent:
|
|
755
|
-
seconds:
|
|
756
|
-
}), this.previousTime =
|
|
763
|
+
const s = t.getDuration();
|
|
764
|
+
(n = (o = this.options) == null ? void 0 : o.onTimeUpdate) == null || n.call(o, {
|
|
765
|
+
duration: s,
|
|
766
|
+
percent: a / s,
|
|
767
|
+
seconds: a
|
|
768
|
+
}), this.previousTime = a;
|
|
757
769
|
}
|
|
758
770
|
setTimeUpdateInterval() {
|
|
759
|
-
this.logger.log(
|
|
771
|
+
this.logger.log(c.Debug, "setTimeUpdateInterval"), this.clearTimeUpdateInterval(), this.timeUpdateIntervalId = window.setInterval(
|
|
760
772
|
() => this.invokeTimeUpdate(this.player),
|
|
761
773
|
250
|
|
762
774
|
), this.logger.log(
|
|
763
|
-
|
|
775
|
+
c.Debug,
|
|
764
776
|
"timeUpdateIntervalId",
|
|
765
777
|
this.timeUpdateIntervalId
|
|
766
778
|
), this.invokeTimeUpdate(this.player);
|
|
767
779
|
}
|
|
768
|
-
attach(
|
|
769
|
-
return new Promise((
|
|
780
|
+
attach(t) {
|
|
781
|
+
return new Promise((a, s) => {
|
|
770
782
|
this.player.addEventListener("onReady", async () => {
|
|
771
783
|
this.player.addEventListener(
|
|
772
784
|
"onError",
|
|
773
|
-
(
|
|
774
|
-
var
|
|
775
|
-
return (
|
|
785
|
+
(o) => {
|
|
786
|
+
var n, u;
|
|
787
|
+
return (u = (n = this.options) == null ? void 0 : n.onError) == null ? void 0 : u.call(n, o.data);
|
|
776
788
|
}
|
|
777
789
|
), this.player.addEventListener(
|
|
778
790
|
"onStateChange",
|
|
779
|
-
(
|
|
780
|
-
var u,
|
|
791
|
+
(o) => {
|
|
792
|
+
var n, u, d, y, p, g, m, l;
|
|
781
793
|
switch (this.logger.log(
|
|
782
|
-
|
|
783
|
-
`state changed: ${
|
|
784
|
-
),
|
|
794
|
+
c.Debug,
|
|
795
|
+
`state changed: ${S[o.data]}`
|
|
796
|
+
), o.data) {
|
|
785
797
|
case YT.PlayerState.CUED:
|
|
786
|
-
(
|
|
798
|
+
(u = (n = this.options) == null ? void 0 : n.onLoaded) == null || u.call(n, { id: t });
|
|
787
799
|
break;
|
|
788
800
|
case YT.PlayerState.PLAYING:
|
|
789
|
-
(
|
|
801
|
+
(y = (d = this.options) == null ? void 0 : d.onPlay) == null || y.call(d), this.setTimeUpdateInterval();
|
|
790
802
|
break;
|
|
791
803
|
case YT.PlayerState.PAUSED:
|
|
792
|
-
(
|
|
804
|
+
(g = (p = this.options) == null ? void 0 : p.onPause) == null || g.call(p), this.clearTimeUpdateInterval();
|
|
793
805
|
break;
|
|
794
806
|
case YT.PlayerState.ENDED:
|
|
795
|
-
(
|
|
807
|
+
(l = (m = this.options) == null ? void 0 : m.onEnded) == null || l.call(m), this.clearTimeUpdateInterval();
|
|
796
808
|
break;
|
|
797
809
|
}
|
|
798
810
|
}
|
|
799
|
-
), await this.loadVideo(
|
|
811
|
+
), await this.loadVideo(t), a();
|
|
800
812
|
});
|
|
801
813
|
});
|
|
802
814
|
}
|
|
803
815
|
async detach() {
|
|
804
816
|
this.clearTimeUpdateInterval();
|
|
805
817
|
}
|
|
806
|
-
async loadVideo(
|
|
807
|
-
this.previousTime = void 0, this.player.cueVideoById(
|
|
818
|
+
async loadVideo(t) {
|
|
819
|
+
this.previousTime = void 0, this.player.cueVideoById(t);
|
|
808
820
|
}
|
|
809
821
|
async play() {
|
|
810
822
|
this.player.playVideo();
|
|
@@ -812,14 +824,14 @@ const N = class extends E {
|
|
|
812
824
|
async pause() {
|
|
813
825
|
this.player.pauseVideo();
|
|
814
826
|
}
|
|
815
|
-
async setCurrentTime(
|
|
816
|
-
this.player.seekTo(
|
|
827
|
+
async setCurrentTime(t) {
|
|
828
|
+
this.player.seekTo(t), this.invokeTimeUpdate(this.player);
|
|
817
829
|
}
|
|
818
|
-
async setVolume(
|
|
819
|
-
this.player.setVolume(
|
|
830
|
+
async setVolume(t) {
|
|
831
|
+
this.player.setVolume(t * 100);
|
|
820
832
|
}
|
|
821
|
-
async setMuted(
|
|
822
|
-
|
|
833
|
+
async setMuted(t) {
|
|
834
|
+
t ? this.player.mute() : this.player.unMute();
|
|
823
835
|
}
|
|
824
836
|
async getDuration() {
|
|
825
837
|
return this.player.getDuration();
|
|
@@ -830,68 +842,76 @@ const N = class extends E {
|
|
|
830
842
|
async getVolume() {
|
|
831
843
|
return this.player.getVolume() / 100;
|
|
832
844
|
}
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
y(T, "origin", "https://www.youtube-nocookie.com");
|
|
836
|
-
const X = s.memo(
|
|
845
|
+
}
|
|
846
|
+
const Q = "https://www.youtube-nocookie.com", X = i.memo(
|
|
837
847
|
({ ...r }) => {
|
|
838
|
-
const { logger:
|
|
839
|
-
|
|
840
|
-
const
|
|
841
|
-
await
|
|
848
|
+
const { logger: e } = r;
|
|
849
|
+
e.log(c.Debug, "YouTubePlayer");
|
|
850
|
+
const t = i.useCallback(() => new Promise(async (s, o) => {
|
|
851
|
+
await A(
|
|
842
852
|
"https://www.youtube.com/iframe_api",
|
|
843
|
-
|
|
853
|
+
e
|
|
844
854
|
) ? window.onYouTubeIframeAPIReady = () => {
|
|
845
|
-
|
|
846
|
-
} :
|
|
847
|
-
}), [
|
|
848
|
-
|
|
849
|
-
|
|
855
|
+
e.log(c.Debug, "YouTube iframe API ready"), s();
|
|
856
|
+
} : s();
|
|
857
|
+
}), [e]), a = i.useCallback(
|
|
858
|
+
(s) => Promise.resolve(
|
|
859
|
+
new YT.Player(s, {
|
|
860
|
+
host: Q,
|
|
861
|
+
width: "100%",
|
|
862
|
+
height: "100%"
|
|
863
|
+
})
|
|
864
|
+
),
|
|
865
|
+
[]
|
|
866
|
+
);
|
|
867
|
+
return /* @__PURE__ */ i.createElement(
|
|
868
|
+
f,
|
|
850
869
|
{
|
|
851
870
|
...r,
|
|
852
|
-
loadScript:
|
|
853
|
-
|
|
871
|
+
loadScript: t,
|
|
872
|
+
playerFactory: a,
|
|
873
|
+
playerApiFactory: K
|
|
854
874
|
},
|
|
855
|
-
(
|
|
875
|
+
(s) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement("div", { ref: s }))
|
|
856
876
|
);
|
|
857
877
|
}
|
|
858
878
|
), Z = {
|
|
859
|
-
Audio:
|
|
860
|
-
Niconico:
|
|
861
|
-
SoundCloud:
|
|
862
|
-
Vimeo:
|
|
879
|
+
Audio: x,
|
|
880
|
+
Niconico: G,
|
|
881
|
+
SoundCloud: q,
|
|
882
|
+
Vimeo: J,
|
|
863
883
|
YouTube: X
|
|
864
|
-
}, te =
|
|
865
|
-
({ type: r, videoId:
|
|
866
|
-
const { logger:
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
return /* @__PURE__ */
|
|
870
|
-
|
|
884
|
+
}, te = i.memo(
|
|
885
|
+
({ type: r, videoId: e, options: t }) => {
|
|
886
|
+
const { logger: a, playerApiRef: s } = O();
|
|
887
|
+
a.log(c.Debug, "NostalgicDiva");
|
|
888
|
+
const o = Z[r];
|
|
889
|
+
return /* @__PURE__ */ i.createElement(
|
|
890
|
+
o,
|
|
871
891
|
{
|
|
872
|
-
logger:
|
|
892
|
+
logger: a,
|
|
873
893
|
type: r,
|
|
874
|
-
playerApiRef:
|
|
875
|
-
videoId:
|
|
876
|
-
options:
|
|
894
|
+
playerApiRef: s,
|
|
895
|
+
videoId: e,
|
|
896
|
+
options: t
|
|
877
897
|
}
|
|
878
898
|
);
|
|
879
899
|
}
|
|
880
900
|
);
|
|
881
901
|
export {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
902
|
+
x as AudioPlayer,
|
|
903
|
+
Y as AudioPlayerApi,
|
|
904
|
+
G as NiconicoPlayer,
|
|
905
|
+
T as NiconicoPlayerApi,
|
|
886
906
|
te as NostalgicDiva,
|
|
887
907
|
ee as NostalgicDivaProvider,
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
908
|
+
C as PlayerApi,
|
|
909
|
+
q as SoundCloudPlayer,
|
|
910
|
+
k as SoundCloudPlayerApi,
|
|
911
|
+
J as VimeoPlayer,
|
|
912
|
+
z as VimeoPlayerApi,
|
|
893
913
|
X as YouTubePlayer,
|
|
894
|
-
|
|
895
|
-
|
|
914
|
+
K as YouTubePlayerApi,
|
|
915
|
+
O as useNostalgicDiva
|
|
896
916
|
};
|
|
897
917
|
//# sourceMappingURL=index.es.js.map
|