@aigamo/nostalgic-diva 1.6.0 → 1.7.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/README.md +2 -1
- package/dist/components/TwitchPlayer.d.ts +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +449 -348
- package/dist/index.es.js.map +1 -1
- package/dist/players/PlayerApi.d.ts +1 -1
- package/dist/players/TwitchPlayerApi.d.ts +19 -0
- package/dist/players/index.d.ts +1 -0
- package/package.json +3 -1
package/dist/index.es.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Y = (a,
|
|
3
|
-
var
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var Y = (a, t, e) => t in a ? F(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var m = (a, t, e) => (Y(a, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
4
|
import i, { useRef as V } from "react";
|
|
5
|
-
var
|
|
6
|
-
class
|
|
7
|
-
constructor(
|
|
8
|
-
this.logger =
|
|
5
|
+
var d = /* @__PURE__ */ ((a) => (a[a.Trace = 0] = "Trace", a[a.Debug = 1] = "Debug", a[a.Information = 2] = "Information", a[a.Warning = 3] = "Warning", a[a.Error = 4] = "Error", a[a.Critical = 5] = "Critical", a[a.None = 6] = "None", a))(d || {});
|
|
6
|
+
class w {
|
|
7
|
+
constructor(t, e, r) {
|
|
8
|
+
this.logger = t, this.player = e, this.options = r, this.logger.log(d.Debug, "ctor");
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
class
|
|
11
|
+
class j extends w {
|
|
12
12
|
async attach() {
|
|
13
|
-
this.player.onerror = (
|
|
14
|
-
var
|
|
15
|
-
return (r = (
|
|
13
|
+
this.player.onerror = (t) => {
|
|
14
|
+
var e, r;
|
|
15
|
+
return (r = (e = this.options) == null ? void 0 : e.onError) == null ? void 0 : r.call(e, t);
|
|
16
16
|
}, this.player.onloadeddata = () => {
|
|
17
|
-
var
|
|
18
|
-
return (
|
|
17
|
+
var t, e;
|
|
18
|
+
return (e = (t = this.options) == null ? void 0 : t.onLoaded) == null ? void 0 : e.call(t, { id: this.player.src });
|
|
19
19
|
}, this.player.onplay = () => {
|
|
20
|
-
var
|
|
21
|
-
return (
|
|
20
|
+
var t, e;
|
|
21
|
+
return (e = (t = this.options) == null ? void 0 : t.onPlay) == null ? void 0 : e.call(t);
|
|
22
22
|
}, this.player.onpause = () => {
|
|
23
|
-
var
|
|
24
|
-
return (
|
|
23
|
+
var t, e;
|
|
24
|
+
return (e = (t = this.options) == null ? void 0 : t.onPause) == null ? void 0 : e.call(t);
|
|
25
25
|
}, this.player.onended = () => {
|
|
26
|
-
var
|
|
27
|
-
return (
|
|
26
|
+
var t, e;
|
|
27
|
+
return (e = (t = this.options) == null ? void 0 : t.onEnded) == null ? void 0 : e.call(t);
|
|
28
28
|
}, this.player.ontimeupdate = () => {
|
|
29
|
-
var
|
|
30
|
-
(
|
|
29
|
+
var t, e;
|
|
30
|
+
(e = (t = this.options) == null ? void 0 : t.onTimeUpdate) == null || e.call(t, {
|
|
31
31
|
duration: this.player.duration,
|
|
32
32
|
percent: this.player.currentTime / this.player.duration,
|
|
33
33
|
seconds: this.player.currentTime
|
|
@@ -37,8 +37,8 @@ class W extends E {
|
|
|
37
37
|
async detach() {
|
|
38
38
|
this.player.onerror = null, this.player.onloadeddata = null, this.player.onplay = null, this.player.onpause = null, this.player.onended = null, this.player.ontimeupdate = null;
|
|
39
39
|
}
|
|
40
|
-
async loadVideo(
|
|
41
|
-
this.player.src =
|
|
40
|
+
async loadVideo(t) {
|
|
41
|
+
this.player.src = t;
|
|
42
42
|
}
|
|
43
43
|
async play() {
|
|
44
44
|
this.player.play();
|
|
@@ -46,14 +46,14 @@ class W extends E {
|
|
|
46
46
|
async pause() {
|
|
47
47
|
this.player.pause();
|
|
48
48
|
}
|
|
49
|
-
async setCurrentTime(
|
|
50
|
-
this.player.currentTime =
|
|
49
|
+
async setCurrentTime(t) {
|
|
50
|
+
this.player.currentTime = t;
|
|
51
51
|
}
|
|
52
|
-
async setVolume(
|
|
53
|
-
this.player.volume =
|
|
52
|
+
async setVolume(t) {
|
|
53
|
+
this.player.volume = t;
|
|
54
54
|
}
|
|
55
|
-
async setMuted(
|
|
56
|
-
this.player.muted =
|
|
55
|
+
async setMuted(t) {
|
|
56
|
+
this.player.muted = t;
|
|
57
57
|
}
|
|
58
58
|
async getDuration() {
|
|
59
59
|
return this.player.duration;
|
|
@@ -66,30 +66,30 @@ class W extends E {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
const U = class {
|
|
69
|
-
constructor(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.logger =
|
|
69
|
+
constructor(t, e, r, s, l) {
|
|
70
|
+
m(this, "id");
|
|
71
|
+
m(this, "impl");
|
|
72
|
+
this.logger = t, this.type = e, this.player = r, this.options = s, this.playerApiFactory = l, this.id = U.nextId++;
|
|
73
73
|
}
|
|
74
|
-
createMessage(
|
|
75
|
-
return `${this.type}#${this.id} ${
|
|
74
|
+
createMessage(t) {
|
|
75
|
+
return `${this.type}#${this.id} ${t}`;
|
|
76
76
|
}
|
|
77
|
-
debug(
|
|
77
|
+
debug(t, ...e) {
|
|
78
78
|
this.logger.log(
|
|
79
|
-
|
|
80
|
-
this.createMessage(
|
|
81
|
-
...
|
|
79
|
+
d.Debug,
|
|
80
|
+
this.createMessage(t),
|
|
81
|
+
...e
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
|
-
error(
|
|
84
|
+
error(t, ...e) {
|
|
85
85
|
this.logger.log(
|
|
86
|
-
|
|
87
|
-
this.createMessage(
|
|
88
|
-
...
|
|
86
|
+
d.Error,
|
|
87
|
+
this.createMessage(t),
|
|
88
|
+
...e
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
|
-
async attach(
|
|
92
|
-
if (this.debug("attach",
|
|
91
|
+
async attach(t) {
|
|
92
|
+
if (this.debug("attach", t), this.impl) {
|
|
93
93
|
this.debug("player is already attached");
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
@@ -97,7 +97,7 @@ const U = class {
|
|
|
97
97
|
this.logger,
|
|
98
98
|
this.player,
|
|
99
99
|
this.options
|
|
100
|
-
), await this.impl.attach(
|
|
100
|
+
), await this.impl.attach(t), this.debug("player attached");
|
|
101
101
|
}
|
|
102
102
|
createPlayerNotAttachedError() {
|
|
103
103
|
return new Error("player is not attached");
|
|
@@ -107,10 +107,10 @@ const U = class {
|
|
|
107
107
|
throw this.createPlayerNotAttachedError();
|
|
108
108
|
await this.impl.detach(), this.impl = void 0;
|
|
109
109
|
}
|
|
110
|
-
async loadVideo(
|
|
111
|
-
if (this.debug("loadVideo",
|
|
110
|
+
async loadVideo(t) {
|
|
111
|
+
if (this.debug("loadVideo", t), this.impl === void 0)
|
|
112
112
|
throw this.createPlayerNotAttachedError();
|
|
113
|
-
this.debug("Loading video..."), await this.impl.loadVideo(
|
|
113
|
+
this.debug("Loading video..."), await this.impl.loadVideo(t), this.debug("video loaded", t);
|
|
114
114
|
}
|
|
115
115
|
play() {
|
|
116
116
|
if (this.debug("play"), this.impl === void 0)
|
|
@@ -122,20 +122,20 @@ const U = class {
|
|
|
122
122
|
throw this.createPlayerNotAttachedError();
|
|
123
123
|
return this.impl.pause();
|
|
124
124
|
}
|
|
125
|
-
setCurrentTime(
|
|
126
|
-
if (this.debug("setCurrentTime",
|
|
125
|
+
setCurrentTime(t) {
|
|
126
|
+
if (this.debug("setCurrentTime", t), this.impl === void 0)
|
|
127
127
|
throw this.createPlayerNotAttachedError();
|
|
128
|
-
return this.impl.setCurrentTime(
|
|
128
|
+
return this.impl.setCurrentTime(t);
|
|
129
129
|
}
|
|
130
|
-
setVolume(
|
|
131
|
-
if (this.debug("setVolume",
|
|
130
|
+
setVolume(t) {
|
|
131
|
+
if (this.debug("setVolume", t), this.impl === void 0)
|
|
132
132
|
throw this.createPlayerNotAttachedError();
|
|
133
|
-
return this.impl.setVolume(
|
|
133
|
+
return this.impl.setVolume(t);
|
|
134
134
|
}
|
|
135
|
-
setMuted(
|
|
136
|
-
if (this.debug("setMuted",
|
|
135
|
+
setMuted(t) {
|
|
136
|
+
if (this.debug("setMuted", t), this.impl === void 0)
|
|
137
137
|
throw this.createPlayerNotAttachedError();
|
|
138
|
-
return this.impl.setMuted(
|
|
138
|
+
return this.impl.setMuted(t);
|
|
139
139
|
}
|
|
140
140
|
getDuration() {
|
|
141
141
|
if (this.debug("getDuration"), this.impl === void 0)
|
|
@@ -153,81 +153,81 @@ const U = class {
|
|
|
153
153
|
return this.impl.getVolume();
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
function
|
|
156
|
+
let C = U;
|
|
157
|
+
m(C, "nextId", 1);
|
|
158
|
+
function W() {
|
|
159
159
|
const a = V(!0);
|
|
160
160
|
return a.current ? (a.current = !1, !0) : a.current;
|
|
161
161
|
}
|
|
162
|
-
const x = (a,
|
|
163
|
-
function $(a,
|
|
164
|
-
const
|
|
165
|
-
return !
|
|
162
|
+
const x = (a, t) => a === t;
|
|
163
|
+
function $(a, t = x) {
|
|
164
|
+
const e = V(), r = V(a);
|
|
165
|
+
return !W() && !t(r.current, a) && (e.current = r.current, r.current = a), e.current;
|
|
166
166
|
}
|
|
167
|
-
const
|
|
167
|
+
const b = ({
|
|
168
168
|
logger: a,
|
|
169
|
-
type:
|
|
170
|
-
loadScript:
|
|
169
|
+
type: t,
|
|
170
|
+
loadScript: e,
|
|
171
171
|
playerFactory: r,
|
|
172
172
|
playerApiRef: s,
|
|
173
173
|
videoId: l,
|
|
174
174
|
options: o,
|
|
175
175
|
playerApiFactory: n,
|
|
176
|
-
children:
|
|
176
|
+
children: u
|
|
177
177
|
}) => {
|
|
178
|
-
a.log(
|
|
179
|
-
const y = i.useRef(l), p = i.useRef(void 0), [
|
|
178
|
+
a.log(d.Debug, "PlayerContainer");
|
|
179
|
+
const y = i.useRef(l), p = i.useRef(void 0), [g, v] = i.useState(), [c, h] = i.useState();
|
|
180
180
|
i.useEffect(() => {
|
|
181
|
-
((
|
|
181
|
+
((e == null ? void 0 : e()) ?? Promise.resolve()).then(() => {
|
|
182
182
|
r(p.current, y.current).then(
|
|
183
|
-
(
|
|
184
|
-
|
|
183
|
+
(E) => {
|
|
184
|
+
v(E);
|
|
185
185
|
}
|
|
186
186
|
);
|
|
187
187
|
});
|
|
188
|
-
}, [
|
|
189
|
-
if (
|
|
188
|
+
}, [e, r]), i.useEffect(() => {
|
|
189
|
+
if (g === void 0)
|
|
190
190
|
return;
|
|
191
|
-
const
|
|
191
|
+
const E = new C(
|
|
192
192
|
a,
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
t,
|
|
194
|
+
g,
|
|
195
195
|
o,
|
|
196
196
|
n
|
|
197
197
|
);
|
|
198
|
-
return s && (s.current =
|
|
199
|
-
if (s &&
|
|
198
|
+
return s && (s.current = E), E.attach(y.current).then(() => h(E)), () => {
|
|
199
|
+
if (s && E !== s.current)
|
|
200
200
|
throw new Error("playerApi differs");
|
|
201
|
-
|
|
201
|
+
E.detach().finally(() => h(void 0));
|
|
202
202
|
};
|
|
203
203
|
}, [
|
|
204
204
|
a,
|
|
205
|
-
e,
|
|
206
205
|
t,
|
|
207
|
-
|
|
206
|
+
e,
|
|
207
|
+
g,
|
|
208
208
|
o,
|
|
209
209
|
n,
|
|
210
210
|
s
|
|
211
211
|
]);
|
|
212
|
-
const
|
|
212
|
+
const T = $(l);
|
|
213
213
|
return i.useEffect(() => {
|
|
214
|
-
|
|
215
|
-
}, [
|
|
216
|
-
},
|
|
214
|
+
T !== void 0 && (c == null || c.loadVideo(l));
|
|
215
|
+
}, [T, l, c]), /* @__PURE__ */ i.createElement(i.Fragment, null, u(p, y.current));
|
|
216
|
+
}, L = i.memo(
|
|
217
217
|
({ ...a }) => {
|
|
218
|
-
const { logger:
|
|
219
|
-
|
|
220
|
-
const
|
|
218
|
+
const { logger: t } = a;
|
|
219
|
+
t.log(d.Debug, "AudioPlayer");
|
|
220
|
+
const e = i.useCallback(
|
|
221
221
|
(r) => Promise.resolve(r),
|
|
222
222
|
[]
|
|
223
223
|
);
|
|
224
224
|
return /* @__PURE__ */ i.createElement(
|
|
225
|
-
|
|
225
|
+
b,
|
|
226
226
|
{
|
|
227
227
|
...a,
|
|
228
228
|
loadScript: void 0,
|
|
229
|
-
playerFactory:
|
|
230
|
-
playerApiFactory:
|
|
229
|
+
playerFactory: e,
|
|
230
|
+
playerApiFactory: j
|
|
231
231
|
},
|
|
232
232
|
(r, s) => /* @__PURE__ */ i.createElement(
|
|
233
233
|
"audio",
|
|
@@ -251,12 +251,12 @@ const w = ({
|
|
|
251
251
|
"playing",
|
|
252
252
|
"error"
|
|
253
253
|
];
|
|
254
|
-
class
|
|
254
|
+
class G extends w {
|
|
255
255
|
constructor() {
|
|
256
256
|
super(...arguments);
|
|
257
|
-
|
|
258
|
-
var r, s, l, o, n,
|
|
259
|
-
switch (
|
|
257
|
+
m(this, "handlePlayerEvents", (e) => {
|
|
258
|
+
var r, s, l, o, n, u, y, p, g, v, c, h;
|
|
259
|
+
switch (e.type) {
|
|
260
260
|
case "apiready":
|
|
261
261
|
(s = (r = this.options) == null ? void 0 : r.onLoaded) == null || s.call(r, { id: this.player.video.videoId });
|
|
262
262
|
break;
|
|
@@ -268,7 +268,7 @@ class B extends E {
|
|
|
268
268
|
});
|
|
269
269
|
break;
|
|
270
270
|
case "video_end":
|
|
271
|
-
(
|
|
271
|
+
(u = (n = this.options) == null ? void 0 : n.onEnded) == null || u.call(n);
|
|
272
272
|
break;
|
|
273
273
|
case "durationchange":
|
|
274
274
|
break;
|
|
@@ -276,24 +276,24 @@ class B extends E {
|
|
|
276
276
|
(p = (y = this.options) == null ? void 0 : y.onPause) == null || p.call(y);
|
|
277
277
|
break;
|
|
278
278
|
case "playing":
|
|
279
|
-
(
|
|
279
|
+
(v = (g = this.options) == null ? void 0 : g.onPlay) == null || v.call(g);
|
|
280
280
|
break;
|
|
281
281
|
case "error":
|
|
282
|
-
(h = (c = this.options) == null ? void 0 : c.onError) == null || h.call(c,
|
|
282
|
+
(h = (c = this.options) == null ? void 0 : c.onError) == null || h.call(c, e);
|
|
283
283
|
break;
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
286
|
}
|
|
287
|
-
async attach(
|
|
287
|
+
async attach(e) {
|
|
288
288
|
for (const r of M)
|
|
289
289
|
this.player.addEventListener(r, this.handlePlayerEvents);
|
|
290
290
|
}
|
|
291
291
|
async detach() {
|
|
292
|
-
for (const
|
|
293
|
-
this.player.removeEventListener(
|
|
292
|
+
for (const e of M)
|
|
293
|
+
this.player.removeEventListener(e, this.handlePlayerEvents);
|
|
294
294
|
}
|
|
295
|
-
async loadVideo(
|
|
296
|
-
this.player.load(
|
|
295
|
+
async loadVideo(e) {
|
|
296
|
+
this.player.load(e);
|
|
297
297
|
}
|
|
298
298
|
async play() {
|
|
299
299
|
this.player.play();
|
|
@@ -301,14 +301,14 @@ class B extends E {
|
|
|
301
301
|
async pause() {
|
|
302
302
|
this.player.pause();
|
|
303
303
|
}
|
|
304
|
-
async setCurrentTime(
|
|
305
|
-
this.player.seek(
|
|
304
|
+
async setCurrentTime(e) {
|
|
305
|
+
this.player.seek(e);
|
|
306
306
|
}
|
|
307
|
-
async setVolume(
|
|
308
|
-
this.player.setVolume(
|
|
307
|
+
async setVolume(e) {
|
|
308
|
+
this.player.setVolume(e);
|
|
309
309
|
}
|
|
310
|
-
async setMuted(
|
|
311
|
-
this.player.setMuted(
|
|
310
|
+
async setMuted(e) {
|
|
311
|
+
this.player.setMuted(e);
|
|
312
312
|
}
|
|
313
313
|
async getDuration() {
|
|
314
314
|
return this.player.duration;
|
|
@@ -320,32 +320,32 @@ class B extends E {
|
|
|
320
320
|
return this.player.volume;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
function
|
|
324
|
-
return new Promise((
|
|
323
|
+
function B(a) {
|
|
324
|
+
return new Promise((t, e) => {
|
|
325
325
|
const r = document.createElement("script");
|
|
326
|
-
r.src = a, r.async = !0, r.onerror =
|
|
326
|
+
r.src = a, r.async = !0, r.onerror = e, r.onload = r.onreadystatechange = function() {
|
|
327
327
|
const s = this.readyState;
|
|
328
|
-
s && s !== "loaded" && s !== "complete" || (r.onload = r.onreadystatechange = null,
|
|
328
|
+
s && s !== "loaded" && s !== "complete" || (r.onload = r.onreadystatechange = null, t());
|
|
329
329
|
}, document.head.appendChild(r);
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
const k = [];
|
|
333
|
-
async function
|
|
333
|
+
async function P(a, t) {
|
|
334
334
|
if (k.includes(a))
|
|
335
|
-
return
|
|
335
|
+
return t.log(d.Debug, a, "script is already loaded"), !1;
|
|
336
336
|
try {
|
|
337
|
-
return
|
|
338
|
-
} catch (
|
|
339
|
-
throw
|
|
337
|
+
return t.log(d.Debug, a, "Loading script..."), await B(a), k.includes(a) ? (t.log(d.Debug, a, "script is already loaded"), !1) : (k.push(a), t.log(d.Debug, a, "script loaded"), !0);
|
|
338
|
+
} catch (e) {
|
|
339
|
+
throw t.log(d.Error, a, "Failed to load script"), e;
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
-
const
|
|
343
|
-
({ options: a, ...
|
|
344
|
-
const { logger:
|
|
345
|
-
|
|
342
|
+
const O = i.memo(
|
|
343
|
+
({ options: a, ...t }) => {
|
|
344
|
+
const { logger: e } = t;
|
|
345
|
+
e.log(d.Debug, "DailymotionPlayer");
|
|
346
346
|
const r = i.useCallback(async () => {
|
|
347
|
-
await
|
|
348
|
-
}, [
|
|
347
|
+
await P("https://api.dmcdn.net/all.js", e);
|
|
348
|
+
}, [e]), s = i.useCallback(
|
|
349
349
|
(l, o) => Promise.resolve(
|
|
350
350
|
new DM.player(l, {
|
|
351
351
|
video: o,
|
|
@@ -381,8 +381,8 @@ const _ = i.memo(
|
|
|
381
381
|
waiting: () => {
|
|
382
382
|
},
|
|
383
383
|
error: (n) => {
|
|
384
|
-
var
|
|
385
|
-
(
|
|
384
|
+
var u;
|
|
385
|
+
(u = a == null ? void 0 : a.onError) == null || u.call(a, n);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
})
|
|
@@ -390,41 +390,41 @@ const _ = i.memo(
|
|
|
390
390
|
[a]
|
|
391
391
|
);
|
|
392
392
|
return /* @__PURE__ */ i.createElement(
|
|
393
|
-
|
|
393
|
+
b,
|
|
394
394
|
{
|
|
395
|
-
...
|
|
395
|
+
...t,
|
|
396
396
|
options: a,
|
|
397
397
|
loadScript: r,
|
|
398
398
|
playerFactory: s,
|
|
399
|
-
playerApiFactory:
|
|
399
|
+
playerApiFactory: G
|
|
400
400
|
},
|
|
401
401
|
(l) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement("div", { ref: l }))
|
|
402
402
|
);
|
|
403
403
|
}
|
|
404
404
|
);
|
|
405
|
-
var
|
|
406
|
-
const
|
|
405
|
+
var A = /* @__PURE__ */ ((a) => (a[a.Play = 2] = "Play", a[a.Pause = 3] = "Pause", a[a.End = 4] = "End", a))(A || {});
|
|
406
|
+
const D = class extends w {
|
|
407
407
|
constructor() {
|
|
408
408
|
super(...arguments);
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
var s, l, o, n,
|
|
414
|
-
if (
|
|
409
|
+
m(this, "duration");
|
|
410
|
+
m(this, "currentTime");
|
|
411
|
+
m(this, "volume");
|
|
412
|
+
m(this, "handleMessage", (e) => {
|
|
413
|
+
var s, l, o, n, u, y, p, g, v, c, h, T, E, N;
|
|
414
|
+
if (e.origin !== D.origin)
|
|
415
415
|
return;
|
|
416
|
-
const r =
|
|
416
|
+
const r = e.data;
|
|
417
417
|
switch (r.eventName) {
|
|
418
418
|
case "playerStatusChange":
|
|
419
419
|
this.logger.log(
|
|
420
|
-
|
|
421
|
-
`player status changed: ${
|
|
420
|
+
d.Debug,
|
|
421
|
+
`player status changed: ${A[r.data.playerStatus] ?? r.data.playerStatus}`
|
|
422
422
|
);
|
|
423
423
|
break;
|
|
424
424
|
case "statusChange":
|
|
425
425
|
switch (this.logger.log(
|
|
426
|
-
|
|
427
|
-
`status changed: ${
|
|
426
|
+
d.Debug,
|
|
427
|
+
`status changed: ${A[r.data.playerStatus] ?? r.data.playerStatus}`
|
|
428
428
|
), r.data.playerStatus) {
|
|
429
429
|
case 2:
|
|
430
430
|
(l = (s = this.options) == null ? void 0 : s.onPlay) == null || l.call(s);
|
|
@@ -433,30 +433,30 @@ const P = class extends E {
|
|
|
433
433
|
(n = (o = this.options) == null ? void 0 : o.onPause) == null || n.call(o);
|
|
434
434
|
break;
|
|
435
435
|
case 4:
|
|
436
|
-
(y = (
|
|
436
|
+
(y = (u = this.options) == null ? void 0 : u.onEnded) == null || y.call(u);
|
|
437
437
|
break;
|
|
438
438
|
}
|
|
439
439
|
break;
|
|
440
440
|
case "playerMetadataChange":
|
|
441
|
-
r.data.duration !== void 0 && (this.duration = r.data.duration / 1e3), this.currentTime = r.data.currentTime === void 0 ? void 0 : r.data.currentTime / 1e3, this.volume = r.data.volume, (
|
|
441
|
+
r.data.duration !== void 0 && (this.duration = r.data.duration / 1e3), this.currentTime = r.data.currentTime === void 0 ? void 0 : r.data.currentTime / 1e3, this.volume = r.data.volume, (g = (p = this.options) == null ? void 0 : p.onTimeUpdate) == null || g.call(p, {
|
|
442
442
|
duration: this.duration,
|
|
443
443
|
percent: this.currentTime !== void 0 && this.duration !== void 0 ? this.currentTime / this.duration : void 0,
|
|
444
444
|
seconds: this.currentTime
|
|
445
445
|
});
|
|
446
446
|
break;
|
|
447
447
|
case "loadComplete":
|
|
448
|
-
this.logger.log(
|
|
448
|
+
this.logger.log(d.Debug, "load completed"), this.duration = r.data.videoInfo.lengthInSeconds, (c = (v = this.options) == null ? void 0 : v.onLoaded) == null || c.call(v, { id: r.data.videoInfo.watchId });
|
|
449
449
|
break;
|
|
450
450
|
case "error":
|
|
451
|
-
(
|
|
451
|
+
(T = (h = this.options) == null ? void 0 : h.onError) == null || T.call(h, r);
|
|
452
452
|
break;
|
|
453
453
|
case "player-error:video:play":
|
|
454
454
|
case "player-error:video:seek":
|
|
455
|
-
(N = (
|
|
455
|
+
(N = (E = this.options) == null ? void 0 : E.onError) == null || N.call(E, r);
|
|
456
456
|
break;
|
|
457
457
|
default:
|
|
458
458
|
this.logger.log(
|
|
459
|
-
|
|
459
|
+
d.Debug,
|
|
460
460
|
"message",
|
|
461
461
|
r.eventName,
|
|
462
462
|
r.data
|
|
@@ -471,23 +471,23 @@ const P = class extends E {
|
|
|
471
471
|
async detach() {
|
|
472
472
|
window.removeEventListener("message", this.handleMessage);
|
|
473
473
|
}
|
|
474
|
-
async loadVideo(
|
|
474
|
+
async loadVideo(e) {
|
|
475
475
|
return new Promise((r, s) => {
|
|
476
476
|
this.duration = void 0, this.currentTime = void 0, this.player.onload = () => {
|
|
477
477
|
this.player.onload = null, r();
|
|
478
|
-
}, this.player.src = `https://embed.nicovideo.jp/watch/${
|
|
478
|
+
}, this.player.src = `https://embed.nicovideo.jp/watch/${e}?jsapi=1&playerId=1`;
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
481
|
// https://blog.hayu.io/web/create/nicovideo-embed-player-api/.
|
|
482
|
-
postMessage(
|
|
482
|
+
postMessage(e) {
|
|
483
483
|
var r;
|
|
484
484
|
(r = this.player.contentWindow) == null || r.postMessage(
|
|
485
485
|
{
|
|
486
|
-
...
|
|
486
|
+
...e,
|
|
487
487
|
playerId: "1",
|
|
488
488
|
sourceConnectorType: 1
|
|
489
489
|
},
|
|
490
|
-
|
|
490
|
+
D.origin
|
|
491
491
|
);
|
|
492
492
|
}
|
|
493
493
|
async play() {
|
|
@@ -496,19 +496,19 @@ const P = class extends E {
|
|
|
496
496
|
async pause() {
|
|
497
497
|
this.postMessage({ eventName: "pause" });
|
|
498
498
|
}
|
|
499
|
-
async setCurrentTime(
|
|
500
|
-
this.postMessage({ eventName: "seek", data: { time:
|
|
499
|
+
async setCurrentTime(e) {
|
|
500
|
+
this.postMessage({ eventName: "seek", data: { time: e * 1e3 } });
|
|
501
501
|
}
|
|
502
|
-
async setVolume(
|
|
502
|
+
async setVolume(e) {
|
|
503
503
|
this.postMessage({
|
|
504
504
|
eventName: "volumeChange",
|
|
505
|
-
data: { volume:
|
|
505
|
+
data: { volume: e }
|
|
506
506
|
});
|
|
507
507
|
}
|
|
508
|
-
async setMuted(
|
|
508
|
+
async setMuted(e) {
|
|
509
509
|
this.postMessage({
|
|
510
510
|
eventName: "mute",
|
|
511
|
-
data: { mute:
|
|
511
|
+
data: { mute: e }
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
514
|
async getDuration() {
|
|
@@ -521,23 +521,23 @@ const P = class extends E {
|
|
|
521
521
|
return this.volume;
|
|
522
522
|
}
|
|
523
523
|
};
|
|
524
|
-
let
|
|
525
|
-
|
|
526
|
-
const
|
|
524
|
+
let f = D;
|
|
525
|
+
m(f, "origin", "https://embed.nicovideo.jp");
|
|
526
|
+
const _ = i.memo(
|
|
527
527
|
({ ...a }) => {
|
|
528
|
-
const { logger:
|
|
529
|
-
|
|
530
|
-
const
|
|
528
|
+
const { logger: t } = a;
|
|
529
|
+
t.log(d.Debug, "NiconicoPlayer");
|
|
530
|
+
const e = i.useCallback(
|
|
531
531
|
(r) => Promise.resolve(r),
|
|
532
532
|
[]
|
|
533
533
|
);
|
|
534
534
|
return /* @__PURE__ */ i.createElement(
|
|
535
|
-
|
|
535
|
+
b,
|
|
536
536
|
{
|
|
537
537
|
...a,
|
|
538
538
|
loadScript: void 0,
|
|
539
|
-
playerFactory:
|
|
540
|
-
playerApiFactory:
|
|
539
|
+
playerFactory: e,
|
|
540
|
+
playerApiFactory: f
|
|
541
541
|
},
|
|
542
542
|
(r, s) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement(
|
|
543
543
|
"iframe",
|
|
@@ -556,82 +556,82 @@ const H = i.memo(
|
|
|
556
556
|
), S = i.createContext(
|
|
557
557
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
558
558
|
void 0
|
|
559
|
-
),
|
|
559
|
+
), H = new class {
|
|
560
560
|
constructor() {
|
|
561
|
-
|
|
561
|
+
m(this, "title", "nostalgic-diva");
|
|
562
562
|
}
|
|
563
563
|
createMessage(a) {
|
|
564
564
|
return `[${this.title}] ${a}`;
|
|
565
565
|
}
|
|
566
|
-
debug(a, ...
|
|
567
|
-
console.debug(this.createMessage(a), ...
|
|
566
|
+
debug(a, ...t) {
|
|
567
|
+
console.debug(this.createMessage(a), ...t);
|
|
568
568
|
}
|
|
569
|
-
error(a, ...
|
|
570
|
-
console.error(this.createMessage(a), ...
|
|
569
|
+
error(a, ...t) {
|
|
570
|
+
console.error(this.createMessage(a), ...t);
|
|
571
571
|
}
|
|
572
|
-
warn(a, ...
|
|
573
|
-
console.warn(this.createMessage(a), ...
|
|
572
|
+
warn(a, ...t) {
|
|
573
|
+
console.warn(this.createMessage(a), ...t);
|
|
574
574
|
}
|
|
575
575
|
isEnabled() {
|
|
576
576
|
return !0;
|
|
577
577
|
}
|
|
578
|
-
log(a,
|
|
578
|
+
log(a, t, ...e) {
|
|
579
579
|
switch (a) {
|
|
580
|
-
case
|
|
581
|
-
this.debug(
|
|
580
|
+
case d.Debug:
|
|
581
|
+
this.debug(t, ...e);
|
|
582
582
|
break;
|
|
583
|
-
case
|
|
584
|
-
this.warn(
|
|
583
|
+
case d.Warning:
|
|
584
|
+
this.warn(t, ...e);
|
|
585
585
|
break;
|
|
586
|
-
case
|
|
587
|
-
this.error(
|
|
586
|
+
case d.Error:
|
|
587
|
+
this.error(t, ...e);
|
|
588
588
|
break;
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
|
-
}(),
|
|
592
|
-
logger: a =
|
|
593
|
-
children:
|
|
591
|
+
}(), ie = ({
|
|
592
|
+
logger: a = H,
|
|
593
|
+
children: t
|
|
594
594
|
}) => {
|
|
595
|
-
const
|
|
595
|
+
const e = i.useRef(), r = i.useCallback(async (c) => {
|
|
596
596
|
var h;
|
|
597
|
-
await ((h =
|
|
597
|
+
await ((h = e.current) == null ? void 0 : h.loadVideo(c));
|
|
598
598
|
}, []), s = i.useCallback(async () => {
|
|
599
599
|
var c;
|
|
600
|
-
await ((c =
|
|
600
|
+
await ((c = e.current) == null ? void 0 : c.play());
|
|
601
601
|
}, []), l = i.useCallback(async () => {
|
|
602
602
|
var c;
|
|
603
|
-
await ((c =
|
|
603
|
+
await ((c = e.current) == null ? void 0 : c.pause());
|
|
604
604
|
}, []), o = i.useCallback(async (c) => {
|
|
605
|
-
const h =
|
|
605
|
+
const h = e.current;
|
|
606
606
|
h && (await h.setCurrentTime(c), await h.play());
|
|
607
607
|
}, []), n = i.useCallback(async (c) => {
|
|
608
608
|
var h;
|
|
609
|
-
await ((h =
|
|
610
|
-
}, []),
|
|
609
|
+
await ((h = e.current) == null ? void 0 : h.setVolume(c));
|
|
610
|
+
}, []), u = i.useCallback(async (c) => {
|
|
611
611
|
var h;
|
|
612
|
-
await ((h =
|
|
612
|
+
await ((h = e.current) == null ? void 0 : h.setMuted(c));
|
|
613
613
|
}, []), y = i.useCallback(async () => {
|
|
614
614
|
var c;
|
|
615
|
-
return await ((c =
|
|
615
|
+
return await ((c = e.current) == null ? void 0 : c.getDuration());
|
|
616
616
|
}, []), p = i.useCallback(async () => {
|
|
617
617
|
var c;
|
|
618
|
-
return await ((c =
|
|
619
|
-
}, []),
|
|
618
|
+
return await ((c = e.current) == null ? void 0 : c.getCurrentTime());
|
|
619
|
+
}, []), g = i.useCallback(async () => {
|
|
620
620
|
var c;
|
|
621
|
-
return await ((c =
|
|
622
|
-
}, []),
|
|
621
|
+
return await ((c = e.current) == null ? void 0 : c.getVolume());
|
|
622
|
+
}, []), v = i.useMemo(
|
|
623
623
|
() => ({
|
|
624
624
|
logger: a,
|
|
625
|
-
playerApiRef:
|
|
625
|
+
playerApiRef: e,
|
|
626
626
|
loadVideo: r,
|
|
627
627
|
play: s,
|
|
628
628
|
pause: l,
|
|
629
629
|
setCurrentTime: o,
|
|
630
630
|
setVolume: n,
|
|
631
|
-
setMuted:
|
|
631
|
+
setMuted: u,
|
|
632
632
|
getDuration: y,
|
|
633
633
|
getCurrentTime: p,
|
|
634
|
-
getVolume:
|
|
634
|
+
getVolume: g
|
|
635
635
|
}),
|
|
636
636
|
[
|
|
637
637
|
a,
|
|
@@ -640,30 +640,30 @@ const H = i.memo(
|
|
|
640
640
|
l,
|
|
641
641
|
o,
|
|
642
642
|
n,
|
|
643
|
-
|
|
643
|
+
u,
|
|
644
644
|
y,
|
|
645
645
|
p,
|
|
646
|
-
|
|
646
|
+
g
|
|
647
647
|
]
|
|
648
648
|
);
|
|
649
|
-
return /* @__PURE__ */ i.createElement(S.Provider, { value:
|
|
649
|
+
return /* @__PURE__ */ i.createElement(S.Provider, { value: v }, t);
|
|
650
650
|
}, q = () => i.useContext(S);
|
|
651
|
-
class
|
|
651
|
+
class I extends w {
|
|
652
652
|
getDurationCore() {
|
|
653
|
-
return new Promise((
|
|
654
|
-
this.player.getDuration(
|
|
653
|
+
return new Promise((t, e) => {
|
|
654
|
+
this.player.getDuration(t);
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
|
-
attach(
|
|
658
|
-
return new Promise((
|
|
657
|
+
attach(t) {
|
|
658
|
+
return new Promise((e, r) => {
|
|
659
659
|
this.player.bind(SC.Widget.Events.READY, () => {
|
|
660
660
|
var s, l;
|
|
661
661
|
this.player.bind(
|
|
662
662
|
SC.Widget.Events.PLAY_PROGRESS,
|
|
663
663
|
async (o) => {
|
|
664
|
-
var
|
|
664
|
+
var u, y;
|
|
665
665
|
const n = await this.getDurationCore();
|
|
666
|
-
(y = (
|
|
666
|
+
(y = (u = this.options) == null ? void 0 : u.onTimeUpdate) == null || y.call(u, {
|
|
667
667
|
duration: n / 1e3,
|
|
668
668
|
percent: o.currentPosition / n,
|
|
669
669
|
seconds: o.currentPosition / 1e3
|
|
@@ -672,8 +672,8 @@ class A extends E {
|
|
|
672
672
|
), this.player.bind(
|
|
673
673
|
SC.Widget.Events.ERROR,
|
|
674
674
|
(o) => {
|
|
675
|
-
var n,
|
|
676
|
-
return (
|
|
675
|
+
var n, u;
|
|
676
|
+
return (u = (n = this.options) == null ? void 0 : n.onError) == null ? void 0 : u.call(n, o);
|
|
677
677
|
}
|
|
678
678
|
), this.player.bind(
|
|
679
679
|
SC.Widget.Events.PLAY,
|
|
@@ -693,23 +693,23 @@ class A extends E {
|
|
|
693
693
|
var o, n;
|
|
694
694
|
return (n = (o = this.options) == null ? void 0 : o.onEnded) == null ? void 0 : n.call(o);
|
|
695
695
|
}
|
|
696
|
-
), (l = (s = this.options) == null ? void 0 : s.onLoaded) == null || l.call(s, { id:
|
|
696
|
+
), (l = (s = this.options) == null ? void 0 : s.onLoaded) == null || l.call(s, { id: t }), e();
|
|
697
697
|
});
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
700
|
async detach() {
|
|
701
701
|
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);
|
|
702
702
|
}
|
|
703
|
-
static playerLoadAsync(
|
|
703
|
+
static playerLoadAsync(t, e, r) {
|
|
704
704
|
return new Promise((s, l) => {
|
|
705
|
-
|
|
705
|
+
t.load(e, { ...r, callback: s });
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
|
-
async loadVideo(
|
|
709
|
-
var
|
|
710
|
-
await
|
|
708
|
+
async loadVideo(t) {
|
|
709
|
+
var e, r;
|
|
710
|
+
await I.playerLoadAsync(this.player, t, {
|
|
711
711
|
auto_play: !0
|
|
712
|
-
}), (r = (
|
|
712
|
+
}), (r = (e = this.options) == null ? void 0 : e.onLoaded) == null || r.call(e, { id: t });
|
|
713
713
|
}
|
|
714
714
|
async play() {
|
|
715
715
|
this.player.play();
|
|
@@ -717,15 +717,15 @@ class A extends E {
|
|
|
717
717
|
async pause() {
|
|
718
718
|
this.player.pause();
|
|
719
719
|
}
|
|
720
|
-
async setCurrentTime(
|
|
721
|
-
this.player.seekTo(
|
|
720
|
+
async setCurrentTime(t) {
|
|
721
|
+
this.player.seekTo(t * 1e3);
|
|
722
722
|
}
|
|
723
|
-
async setVolume(
|
|
724
|
-
this.player.setVolume(
|
|
723
|
+
async setVolume(t) {
|
|
724
|
+
this.player.setVolume(t * 100);
|
|
725
725
|
}
|
|
726
|
-
async setMuted(
|
|
726
|
+
async setMuted(t) {
|
|
727
727
|
this.setVolume(
|
|
728
|
-
|
|
728
|
+
t ? 0 : 1
|
|
729
729
|
/* TODO */
|
|
730
730
|
);
|
|
731
731
|
}
|
|
@@ -733,42 +733,42 @@ class A extends E {
|
|
|
733
733
|
return await this.getDurationCore() / 1e3;
|
|
734
734
|
}
|
|
735
735
|
getCurrentTimeCore() {
|
|
736
|
-
return new Promise((
|
|
737
|
-
this.player.getPosition(
|
|
736
|
+
return new Promise((t, e) => {
|
|
737
|
+
this.player.getPosition(t);
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
740
|
async getCurrentTime() {
|
|
741
741
|
return await this.getCurrentTimeCore() / 1e3;
|
|
742
742
|
}
|
|
743
743
|
getVolumeCore() {
|
|
744
|
-
return new Promise((
|
|
745
|
-
this.player.getVolume(
|
|
744
|
+
return new Promise((t, e) => {
|
|
745
|
+
this.player.getVolume(t);
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
748
|
async getVolume() {
|
|
749
749
|
return await this.getVolumeCore() / 100;
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
|
-
const
|
|
752
|
+
const K = i.memo(
|
|
753
753
|
({ ...a }) => {
|
|
754
|
-
const { logger:
|
|
755
|
-
|
|
756
|
-
const
|
|
757
|
-
await
|
|
754
|
+
const { logger: t } = a;
|
|
755
|
+
t.log(d.Debug, "SoundCloudPlayer");
|
|
756
|
+
const e = i.useCallback(async () => {
|
|
757
|
+
await P(
|
|
758
758
|
"https://w.soundcloud.com/player/api.js",
|
|
759
|
-
|
|
759
|
+
t
|
|
760
760
|
);
|
|
761
|
-
}, [
|
|
761
|
+
}, [t]), r = i.useCallback(
|
|
762
762
|
(s) => Promise.resolve(SC.Widget(s)),
|
|
763
763
|
[]
|
|
764
764
|
);
|
|
765
765
|
return /* @__PURE__ */ i.createElement(
|
|
766
|
-
|
|
766
|
+
b,
|
|
767
767
|
{
|
|
768
768
|
...a,
|
|
769
|
-
loadScript:
|
|
769
|
+
loadScript: e,
|
|
770
770
|
playerFactory: r,
|
|
771
|
-
playerApiFactory:
|
|
771
|
+
playerApiFactory: I
|
|
772
772
|
},
|
|
773
773
|
(s, l) => (
|
|
774
774
|
// eslint-disable-next-line jsx-a11y/iframe-has-title
|
|
@@ -786,40 +786,138 @@ const z = i.memo(
|
|
|
786
786
|
);
|
|
787
787
|
}
|
|
788
788
|
);
|
|
789
|
-
class
|
|
789
|
+
class z extends w {
|
|
790
|
+
constructor() {
|
|
791
|
+
super(...arguments);
|
|
792
|
+
m(this, "handleReady", () => {
|
|
793
|
+
var e, r;
|
|
794
|
+
(r = (e = this.options) == null ? void 0 : e.onLoaded) == null || r.call(e, { id: this.player.getVideo() });
|
|
795
|
+
});
|
|
796
|
+
m(this, "handlePlay", () => {
|
|
797
|
+
var e, r;
|
|
798
|
+
(r = (e = this.options) == null ? void 0 : e.onPlay) == null || r.call(e);
|
|
799
|
+
});
|
|
800
|
+
m(this, "handlePause", () => {
|
|
801
|
+
var e, r;
|
|
802
|
+
(r = (e = this.options) == null ? void 0 : e.onPause) == null || r.call(e);
|
|
803
|
+
});
|
|
804
|
+
m(this, "handleEnded", () => {
|
|
805
|
+
var e, r;
|
|
806
|
+
(r = (e = this.options) == null ? void 0 : e.onEnded) == null || r.call(e);
|
|
807
|
+
});
|
|
808
|
+
m(this, "handleSeek", () => {
|
|
809
|
+
var e, r;
|
|
810
|
+
(r = (e = this.options) == null ? void 0 : e.onTimeUpdate) == null || r.call(e, {
|
|
811
|
+
duration: 0,
|
|
812
|
+
percent: 0,
|
|
813
|
+
seconds: 0
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
async attach(e) {
|
|
818
|
+
this.player.addEventListener(Twitch.Player.READY, this.handleReady), this.player.addEventListener(Twitch.Player.PLAYING, this.handlePlay), this.player.addEventListener(Twitch.Player.PAUSE, this.handlePause), this.player.addEventListener(Twitch.Player.ENDED, this.handleEnded), this.player.addEventListener(Twitch.Player.SEEK, this.handleSeek);
|
|
819
|
+
}
|
|
820
|
+
async detach() {
|
|
821
|
+
}
|
|
822
|
+
async loadVideo(e) {
|
|
823
|
+
this.player.setVideo(e, 0);
|
|
824
|
+
}
|
|
825
|
+
async play() {
|
|
826
|
+
this.player.play();
|
|
827
|
+
}
|
|
828
|
+
async pause() {
|
|
829
|
+
this.player.pause();
|
|
830
|
+
}
|
|
831
|
+
async setCurrentTime(e) {
|
|
832
|
+
this.player.seek(e);
|
|
833
|
+
}
|
|
834
|
+
async setVolume(e) {
|
|
835
|
+
this.player.setVolume(e);
|
|
836
|
+
}
|
|
837
|
+
async setMuted(e) {
|
|
838
|
+
this.player.setMuted(e);
|
|
839
|
+
}
|
|
840
|
+
async getDuration() {
|
|
841
|
+
return this.player.getDuration();
|
|
842
|
+
}
|
|
843
|
+
async getCurrentTime() {
|
|
844
|
+
return this.player.getCurrentTime();
|
|
845
|
+
}
|
|
846
|
+
async getVolume() {
|
|
847
|
+
return this.player.getVolume();
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
const J = i.memo(
|
|
851
|
+
({ ...a }) => {
|
|
852
|
+
const { logger: t } = a;
|
|
853
|
+
t.log(d.Debug, "TwitchPlayer");
|
|
854
|
+
const e = i.useCallback(async () => {
|
|
855
|
+
await P(
|
|
856
|
+
"https://embed.twitch.tv/embed/v1.js",
|
|
857
|
+
t
|
|
858
|
+
);
|
|
859
|
+
}, [t]), r = i.useCallback(
|
|
860
|
+
async (s, l) => Promise.resolve(
|
|
861
|
+
new Twitch.Player(s, {
|
|
862
|
+
video: l,
|
|
863
|
+
width: "100%",
|
|
864
|
+
height: "100%"
|
|
865
|
+
})
|
|
866
|
+
),
|
|
867
|
+
[]
|
|
868
|
+
);
|
|
869
|
+
return /* @__PURE__ */ i.createElement(
|
|
870
|
+
b,
|
|
871
|
+
{
|
|
872
|
+
...a,
|
|
873
|
+
loadScript: e,
|
|
874
|
+
playerFactory: r,
|
|
875
|
+
playerApiFactory: z
|
|
876
|
+
},
|
|
877
|
+
(s) => /* @__PURE__ */ i.createElement(
|
|
878
|
+
"div",
|
|
879
|
+
{
|
|
880
|
+
ref: s,
|
|
881
|
+
style: { width: "100%", height: "100%" }
|
|
882
|
+
}
|
|
883
|
+
)
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
);
|
|
887
|
+
class Q extends w {
|
|
790
888
|
async attach() {
|
|
791
|
-
await this.player.ready(), this.player.on("error", (
|
|
792
|
-
var
|
|
793
|
-
return (r = (
|
|
889
|
+
await this.player.ready(), this.player.on("error", (t) => {
|
|
890
|
+
var e, r;
|
|
891
|
+
return (r = (e = this.options) == null ? void 0 : e.onError) == null ? void 0 : r.call(e, t);
|
|
794
892
|
}), this.player.on(
|
|
795
893
|
"loaded",
|
|
796
|
-
(
|
|
797
|
-
var
|
|
798
|
-
return (r = (
|
|
894
|
+
(t) => {
|
|
895
|
+
var e, r;
|
|
896
|
+
return (r = (e = this.options) == null ? void 0 : e.onLoaded) == null ? void 0 : r.call(e, { id: t.id.toString() });
|
|
799
897
|
}
|
|
800
898
|
), this.player.on("play", () => {
|
|
801
|
-
var
|
|
802
|
-
return (
|
|
899
|
+
var t, e;
|
|
900
|
+
return (e = (t = this.options) == null ? void 0 : t.onPlay) == null ? void 0 : e.call(t);
|
|
803
901
|
}), this.player.on("pause", () => {
|
|
804
|
-
var
|
|
805
|
-
return (
|
|
902
|
+
var t, e;
|
|
903
|
+
return (e = (t = this.options) == null ? void 0 : t.onPause) == null ? void 0 : e.call(t);
|
|
806
904
|
}), this.player.on("ended", () => {
|
|
807
|
-
var
|
|
808
|
-
return (
|
|
809
|
-
}), this.player.on("timeupdate", (
|
|
810
|
-
var
|
|
811
|
-
(r = (
|
|
812
|
-
duration:
|
|
813
|
-
percent:
|
|
814
|
-
seconds:
|
|
905
|
+
var t, e;
|
|
906
|
+
return (e = (t = this.options) == null ? void 0 : t.onEnded) == null ? void 0 : e.call(t);
|
|
907
|
+
}), this.player.on("timeupdate", (t) => {
|
|
908
|
+
var e, r;
|
|
909
|
+
(r = (e = this.options) == null ? void 0 : e.onTimeUpdate) == null || r.call(e, {
|
|
910
|
+
duration: t.duration,
|
|
911
|
+
percent: t.percent,
|
|
912
|
+
seconds: t.seconds
|
|
815
913
|
});
|
|
816
914
|
});
|
|
817
915
|
}
|
|
818
916
|
async detach() {
|
|
819
917
|
this.player.off("error"), this.player.off("loaded"), this.player.off("play"), this.player.off("pause"), this.player.off("ended"), this.player.off("timeupdate");
|
|
820
918
|
}
|
|
821
|
-
async loadVideo(
|
|
822
|
-
await this.player.loadVideo(
|
|
919
|
+
async loadVideo(t) {
|
|
920
|
+
await this.player.loadVideo(t);
|
|
823
921
|
}
|
|
824
922
|
async play() {
|
|
825
923
|
await this.player.play();
|
|
@@ -827,14 +925,14 @@ class J extends E {
|
|
|
827
925
|
async pause() {
|
|
828
926
|
await this.player.pause();
|
|
829
927
|
}
|
|
830
|
-
async setCurrentTime(
|
|
831
|
-
await this.player.setCurrentTime(
|
|
928
|
+
async setCurrentTime(t) {
|
|
929
|
+
await this.player.setCurrentTime(t);
|
|
832
930
|
}
|
|
833
|
-
async setVolume(
|
|
834
|
-
await this.player.setVolume(
|
|
931
|
+
async setVolume(t) {
|
|
932
|
+
await this.player.setVolume(t);
|
|
835
933
|
}
|
|
836
|
-
async setMuted(
|
|
837
|
-
await this.player.setMuted(
|
|
934
|
+
async setMuted(t) {
|
|
935
|
+
await this.player.setMuted(t);
|
|
838
936
|
}
|
|
839
937
|
async getDuration() {
|
|
840
938
|
return this.player.getDuration();
|
|
@@ -846,26 +944,26 @@ class J extends E {
|
|
|
846
944
|
return await this.player.getVolume();
|
|
847
945
|
}
|
|
848
946
|
}
|
|
849
|
-
const
|
|
947
|
+
const X = i.memo(
|
|
850
948
|
({ ...a }) => {
|
|
851
|
-
const { logger:
|
|
852
|
-
|
|
853
|
-
const
|
|
854
|
-
await
|
|
949
|
+
const { logger: t } = a;
|
|
950
|
+
t.log(d.Debug, "VimeoPlayer");
|
|
951
|
+
const e = i.useCallback(async () => {
|
|
952
|
+
await P(
|
|
855
953
|
"https://player.vimeo.com/api/player.js",
|
|
856
|
-
|
|
954
|
+
t
|
|
857
955
|
);
|
|
858
|
-
}, [
|
|
956
|
+
}, [t]), r = i.useCallback(
|
|
859
957
|
(s) => Promise.resolve(new Vimeo.Player(s)),
|
|
860
958
|
[]
|
|
861
959
|
);
|
|
862
960
|
return /* @__PURE__ */ i.createElement(
|
|
863
|
-
|
|
961
|
+
b,
|
|
864
962
|
{
|
|
865
963
|
...a,
|
|
866
|
-
loadScript:
|
|
964
|
+
loadScript: e,
|
|
867
965
|
playerFactory: r,
|
|
868
|
-
playerApiFactory:
|
|
966
|
+
playerApiFactory: Q
|
|
869
967
|
},
|
|
870
968
|
(s, l) => (
|
|
871
969
|
// eslint-disable-next-line jsx-a11y/iframe-has-title
|
|
@@ -883,26 +981,26 @@ const K = i.memo(
|
|
|
883
981
|
);
|
|
884
982
|
}
|
|
885
983
|
);
|
|
886
|
-
var
|
|
887
|
-
class
|
|
984
|
+
var R = /* @__PURE__ */ ((a) => (a[a.UNSTARTED = -1] = "UNSTARTED", a[a.ENDED = 0] = "ENDED", a[a.PLAYING = 1] = "PLAYING", a[a.PAUSED = 2] = "PAUSED", a[a.BUFFERING = 3] = "BUFFERING", a[a.CUED = 5] = "CUED", a))(R || {});
|
|
985
|
+
class Z extends w {
|
|
888
986
|
constructor() {
|
|
889
987
|
super(...arguments);
|
|
890
|
-
|
|
891
|
-
|
|
988
|
+
m(this, "previousTime");
|
|
989
|
+
m(this, "timeUpdateIntervalId");
|
|
892
990
|
}
|
|
893
991
|
clearTimeUpdateInterval() {
|
|
894
992
|
this.logger.log(
|
|
895
|
-
|
|
993
|
+
d.Debug,
|
|
896
994
|
"clearTimeUpdateInterval",
|
|
897
995
|
this.timeUpdateIntervalId
|
|
898
996
|
), window.clearInterval(this.timeUpdateIntervalId), this.timeUpdateIntervalId = void 0;
|
|
899
997
|
}
|
|
900
|
-
invokeTimeUpdate(
|
|
998
|
+
invokeTimeUpdate(e) {
|
|
901
999
|
var l, o;
|
|
902
|
-
const r =
|
|
1000
|
+
const r = e.getCurrentTime();
|
|
903
1001
|
if (r === this.previousTime)
|
|
904
1002
|
return;
|
|
905
|
-
const s =
|
|
1003
|
+
const s = e.getDuration();
|
|
906
1004
|
(o = (l = this.options) == null ? void 0 : l.onTimeUpdate) == null || o.call(l, {
|
|
907
1005
|
duration: s,
|
|
908
1006
|
percent: r / s,
|
|
@@ -910,16 +1008,16 @@ class Q extends E {
|
|
|
910
1008
|
}), this.previousTime = r;
|
|
911
1009
|
}
|
|
912
1010
|
setTimeUpdateInterval() {
|
|
913
|
-
this.logger.log(
|
|
1011
|
+
this.logger.log(d.Debug, "setTimeUpdateInterval"), this.clearTimeUpdateInterval(), this.timeUpdateIntervalId = window.setInterval(
|
|
914
1012
|
() => this.invokeTimeUpdate(this.player),
|
|
915
1013
|
250
|
|
916
1014
|
), this.logger.log(
|
|
917
|
-
|
|
1015
|
+
d.Debug,
|
|
918
1016
|
"timeUpdateIntervalId",
|
|
919
1017
|
this.timeUpdateIntervalId
|
|
920
1018
|
), this.invokeTimeUpdate(this.player);
|
|
921
1019
|
}
|
|
922
|
-
attach(
|
|
1020
|
+
attach(e) {
|
|
923
1021
|
return new Promise((r, s) => {
|
|
924
1022
|
this.player.addEventListener("onReady", async () => {
|
|
925
1023
|
this.player.addEventListener(
|
|
@@ -931,34 +1029,34 @@ class Q extends E {
|
|
|
931
1029
|
), this.player.addEventListener(
|
|
932
1030
|
"onStateChange",
|
|
933
1031
|
(l) => {
|
|
934
|
-
var o, n,
|
|
1032
|
+
var o, n, u, y, p, g, v, c;
|
|
935
1033
|
switch (this.logger.log(
|
|
936
|
-
|
|
937
|
-
`state changed: ${
|
|
1034
|
+
d.Debug,
|
|
1035
|
+
`state changed: ${R[l.data]}`
|
|
938
1036
|
), l.data) {
|
|
939
1037
|
case YT.PlayerState.CUED:
|
|
940
|
-
(n = (o = this.options) == null ? void 0 : o.onLoaded) == null || n.call(o, { id:
|
|
1038
|
+
(n = (o = this.options) == null ? void 0 : o.onLoaded) == null || n.call(o, { id: e });
|
|
941
1039
|
break;
|
|
942
1040
|
case YT.PlayerState.PLAYING:
|
|
943
|
-
(y = (
|
|
1041
|
+
(y = (u = this.options) == null ? void 0 : u.onPlay) == null || y.call(u), this.setTimeUpdateInterval();
|
|
944
1042
|
break;
|
|
945
1043
|
case YT.PlayerState.PAUSED:
|
|
946
|
-
(
|
|
1044
|
+
(g = (p = this.options) == null ? void 0 : p.onPause) == null || g.call(p), this.clearTimeUpdateInterval();
|
|
947
1045
|
break;
|
|
948
1046
|
case YT.PlayerState.ENDED:
|
|
949
|
-
(c = (
|
|
1047
|
+
(c = (v = this.options) == null ? void 0 : v.onEnded) == null || c.call(v), this.clearTimeUpdateInterval();
|
|
950
1048
|
break;
|
|
951
1049
|
}
|
|
952
1050
|
}
|
|
953
|
-
), await this.loadVideo(
|
|
1051
|
+
), await this.loadVideo(e), r();
|
|
954
1052
|
});
|
|
955
1053
|
});
|
|
956
1054
|
}
|
|
957
1055
|
async detach() {
|
|
958
1056
|
this.clearTimeUpdateInterval();
|
|
959
1057
|
}
|
|
960
|
-
async loadVideo(
|
|
961
|
-
this.previousTime = void 0, this.player.cueVideoById(
|
|
1058
|
+
async loadVideo(e) {
|
|
1059
|
+
this.previousTime = void 0, this.player.cueVideoById(e);
|
|
962
1060
|
}
|
|
963
1061
|
async play() {
|
|
964
1062
|
this.player.playVideo();
|
|
@@ -966,14 +1064,14 @@ class Q extends E {
|
|
|
966
1064
|
async pause() {
|
|
967
1065
|
this.player.pauseVideo();
|
|
968
1066
|
}
|
|
969
|
-
async setCurrentTime(
|
|
970
|
-
this.player.seekTo(
|
|
1067
|
+
async setCurrentTime(e) {
|
|
1068
|
+
this.player.seekTo(e), this.invokeTimeUpdate(this.player);
|
|
971
1069
|
}
|
|
972
|
-
async setVolume(
|
|
973
|
-
this.player.setVolume(
|
|
1070
|
+
async setVolume(e) {
|
|
1071
|
+
this.player.setVolume(e * 100);
|
|
974
1072
|
}
|
|
975
|
-
async setMuted(
|
|
976
|
-
|
|
1073
|
+
async setMuted(e) {
|
|
1074
|
+
e ? this.player.mute() : this.player.unMute();
|
|
977
1075
|
}
|
|
978
1076
|
async getDuration() {
|
|
979
1077
|
return this.player.getDuration();
|
|
@@ -985,21 +1083,21 @@ class Q extends E {
|
|
|
985
1083
|
return this.player.getVolume() / 100;
|
|
986
1084
|
}
|
|
987
1085
|
}
|
|
988
|
-
const
|
|
1086
|
+
const ee = "https://www.youtube-nocookie.com", te = i.memo(
|
|
989
1087
|
({ ...a }) => {
|
|
990
|
-
const { logger:
|
|
991
|
-
|
|
992
|
-
const
|
|
993
|
-
await
|
|
1088
|
+
const { logger: t } = a;
|
|
1089
|
+
t.log(d.Debug, "YouTubePlayer");
|
|
1090
|
+
const e = i.useCallback(() => new Promise(async (s, l) => {
|
|
1091
|
+
await P(
|
|
994
1092
|
"https://www.youtube.com/iframe_api",
|
|
995
|
-
|
|
1093
|
+
t
|
|
996
1094
|
) ? window.onYouTubeIframeAPIReady = () => {
|
|
997
|
-
|
|
1095
|
+
t.log(d.Debug, "YouTube iframe API ready"), s();
|
|
998
1096
|
} : s();
|
|
999
|
-
}), [
|
|
1097
|
+
}), [t]), r = i.useCallback(
|
|
1000
1098
|
(s) => Promise.resolve(
|
|
1001
1099
|
new YT.Player(s, {
|
|
1002
|
-
host:
|
|
1100
|
+
host: ee,
|
|
1003
1101
|
width: "100%",
|
|
1004
1102
|
height: "100%"
|
|
1005
1103
|
})
|
|
@@ -1007,56 +1105,59 @@ const X = "https://www.youtube-nocookie.com", Z = i.memo(
|
|
|
1007
1105
|
[]
|
|
1008
1106
|
);
|
|
1009
1107
|
return /* @__PURE__ */ i.createElement(
|
|
1010
|
-
|
|
1108
|
+
b,
|
|
1011
1109
|
{
|
|
1012
1110
|
...a,
|
|
1013
|
-
loadScript:
|
|
1111
|
+
loadScript: e,
|
|
1014
1112
|
playerFactory: r,
|
|
1015
|
-
playerApiFactory:
|
|
1113
|
+
playerApiFactory: Z
|
|
1016
1114
|
},
|
|
1017
1115
|
(s) => /* @__PURE__ */ i.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ i.createElement("div", { ref: s }))
|
|
1018
1116
|
);
|
|
1019
1117
|
}
|
|
1020
|
-
),
|
|
1021
|
-
Audio:
|
|
1022
|
-
Dailymotion:
|
|
1023
|
-
Niconico:
|
|
1024
|
-
SoundCloud:
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1118
|
+
), ae = {
|
|
1119
|
+
Audio: L,
|
|
1120
|
+
Dailymotion: O,
|
|
1121
|
+
Niconico: _,
|
|
1122
|
+
SoundCloud: K,
|
|
1123
|
+
Twitch: J,
|
|
1124
|
+
Vimeo: X,
|
|
1125
|
+
YouTube: te
|
|
1126
|
+
}, ne = i.memo(
|
|
1127
|
+
({ type: a, videoId: t, options: e }) => {
|
|
1029
1128
|
const { logger: r, playerApiRef: s } = q();
|
|
1030
|
-
r.log(
|
|
1031
|
-
const l =
|
|
1129
|
+
r.log(d.Debug, "NostalgicDiva");
|
|
1130
|
+
const l = ae[a];
|
|
1032
1131
|
return /* @__PURE__ */ i.createElement(
|
|
1033
1132
|
l,
|
|
1034
1133
|
{
|
|
1035
1134
|
logger: r,
|
|
1036
1135
|
type: a,
|
|
1037
1136
|
playerApiRef: s,
|
|
1038
|
-
videoId:
|
|
1039
|
-
options:
|
|
1137
|
+
videoId: t,
|
|
1138
|
+
options: e
|
|
1040
1139
|
}
|
|
1041
1140
|
);
|
|
1042
1141
|
}
|
|
1043
1142
|
);
|
|
1044
1143
|
export {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
Q as
|
|
1144
|
+
L as AudioPlayer,
|
|
1145
|
+
j as AudioPlayerApi,
|
|
1146
|
+
O as DailymotionPlayer,
|
|
1147
|
+
G as DailymotionPlayerApi,
|
|
1148
|
+
_ as NiconicoPlayer,
|
|
1149
|
+
f as NiconicoPlayerApi,
|
|
1150
|
+
ne as NostalgicDiva,
|
|
1151
|
+
ie as NostalgicDivaProvider,
|
|
1152
|
+
C as PlayerApi,
|
|
1153
|
+
K as SoundCloudPlayer,
|
|
1154
|
+
I as SoundCloudPlayerApi,
|
|
1155
|
+
J as TwitchPlayer,
|
|
1156
|
+
z as TwitchPlayerApi,
|
|
1157
|
+
X as VimeoPlayer,
|
|
1158
|
+
Q as VimeoPlayerApi,
|
|
1159
|
+
te as YouTubePlayer,
|
|
1160
|
+
Z as YouTubePlayerApi,
|
|
1060
1161
|
q as useNostalgicDiva
|
|
1061
1162
|
};
|
|
1062
1163
|
//# sourceMappingURL=index.es.js.map
|