@aigamo/nostalgic-diva 0.0.1-alpha.67 → 0.0.1-alpha.69
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/AudioPlayer-7plDTn5w.js +31 -0
- package/dist/AudioPlayer-7plDTn5w.js.map +1 -0
- package/dist/AudioPlayer-dEmhfyI_.cjs +2 -0
- package/dist/AudioPlayer-dEmhfyI_.cjs.map +1 -0
- package/dist/DailymotionPlayer-4LQmDDSf.js +61 -0
- package/dist/DailymotionPlayer-4LQmDDSf.js.map +1 -0
- package/dist/DailymotionPlayer-B3UVkJiv.cjs +2 -0
- package/dist/DailymotionPlayer-B3UVkJiv.cjs.map +1 -0
- package/dist/NiconicoPlayer-DiTU-06L.cjs +2 -0
- package/dist/NiconicoPlayer-DiTU-06L.cjs.map +1 -0
- package/dist/NiconicoPlayer-GFCXF5V7.js +35 -0
- package/dist/NiconicoPlayer-GFCXF5V7.js.map +1 -0
- package/dist/PlayerContainer-COjwHOhq.cjs +2 -0
- package/dist/PlayerContainer-COjwHOhq.cjs.map +1 -0
- package/dist/PlayerContainer-VQ3YPGU_.js +226 -0
- package/dist/PlayerContainer-VQ3YPGU_.js.map +1 -0
- package/dist/SoundCloudPlayer-Cqo5VU57.js +33 -0
- package/dist/SoundCloudPlayer-Cqo5VU57.js.map +1 -0
- package/dist/SoundCloudPlayer-tHiueAss.cjs +2 -0
- package/dist/SoundCloudPlayer-tHiueAss.cjs.map +1 -0
- package/dist/TwitchPlayer-BeQUOIE3.js +34 -0
- package/dist/TwitchPlayer-BeQUOIE3.js.map +1 -0
- package/dist/TwitchPlayer-Doh6zF0n.cjs +2 -0
- package/dist/TwitchPlayer-Doh6zF0n.cjs.map +1 -0
- package/dist/VimeoPlayer-7MjNmmgs.cjs +2 -0
- package/dist/VimeoPlayer-7MjNmmgs.cjs.map +1 -0
- package/dist/VimeoPlayer-CgWujBXW.js +33 -0
- package/dist/VimeoPlayer-CgWujBXW.js.map +1 -0
- package/dist/YouTubePlayer-CkaOKK_g.js +36 -0
- package/dist/YouTubePlayer-CkaOKK_g.js.map +1 -0
- package/dist/YouTubePlayer-Clpmqsmv.cjs +2 -0
- package/dist/YouTubePlayer-Clpmqsmv.cjs.map +1 -0
- package/dist/ensureScriptLoaded-BoubPl5C.cjs +2 -0
- package/dist/ensureScriptLoaded-BoubPl5C.cjs.map +1 -0
- package/dist/ensureScriptLoaded-CwERrTru.js +26 -0
- package/dist/ensureScriptLoaded-CwERrTru.js.map +1 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +769 -1232
- package/dist/index.es.js.map +1 -1
- package/package.json +15 -15
- package/dist/AudioPlayer-BMxdg9dp.js +0 -35
- package/dist/AudioPlayer-BMxdg9dp.js.map +0 -1
- package/dist/AudioPlayer-CgUxIJwa.cjs +0 -2
- package/dist/AudioPlayer-CgUxIJwa.cjs.map +0 -1
- package/dist/DailymotionPlayer-B4M9j0Lx.js +0 -65
- package/dist/DailymotionPlayer-B4M9j0Lx.js.map +0 -1
- package/dist/DailymotionPlayer-BdI4qcvJ.cjs +0 -2
- package/dist/DailymotionPlayer-BdI4qcvJ.cjs.map +0 -1
- package/dist/NiconicoPlayer-C1bgzaCT.cjs +0 -2
- package/dist/NiconicoPlayer-C1bgzaCT.cjs.map +0 -1
- package/dist/NiconicoPlayer-Cx3hGYsw.js +0 -36
- package/dist/NiconicoPlayer-Cx3hGYsw.js.map +0 -1
- package/dist/SoundCloudPlayer-BiFTnxn9.cjs +0 -2
- package/dist/SoundCloudPlayer-BiFTnxn9.cjs.map +0 -1
- package/dist/SoundCloudPlayer-C8QVPCXH.js +0 -43
- package/dist/SoundCloudPlayer-C8QVPCXH.js.map +0 -1
- package/dist/TwitchPlayer-C9D_eEaj.js +0 -40
- package/dist/TwitchPlayer-C9D_eEaj.js.map +0 -1
- package/dist/TwitchPlayer-DdhZD1Bh.cjs +0 -2
- package/dist/TwitchPlayer-DdhZD1Bh.cjs.map +0 -1
- package/dist/VimeoPlayer-DfBZwtd9.cjs +0 -2
- package/dist/VimeoPlayer-DfBZwtd9.cjs.map +0 -1
- package/dist/VimeoPlayer-UnKk2VAq.js +0 -43
- package/dist/VimeoPlayer-UnKk2VAq.js.map +0 -1
- package/dist/YouTubePlayer-CeTkdcOO.cjs +0 -2
- package/dist/YouTubePlayer-CeTkdcOO.cjs.map +0 -1
- package/dist/YouTubePlayer-bNmEJD02.js +0 -39
- package/dist/YouTubePlayer-bNmEJD02.js.map +0 -1
- package/dist/ensureScriptLoaded-CkK_-Amf.cjs +0 -2
- package/dist/ensureScriptLoaded-CkK_-Amf.cjs.map +0 -1
- package/dist/ensureScriptLoaded-HHnKf-aZ.js +0 -24
- package/dist/ensureScriptLoaded-HHnKf-aZ.js.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,1238 +1,775 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"NostalgicDivaProvider.setPlaybackRate",
|
|
144
|
-
t.current
|
|
145
|
-
), await t.current.setPlaybackRate(c);
|
|
146
|
-
},
|
|
147
|
-
[e]
|
|
148
|
-
), b = o(async () => (e.log(
|
|
149
|
-
s.Debug,
|
|
150
|
-
"NostalgicDivaProvider.getDuration",
|
|
151
|
-
t.current
|
|
152
|
-
), await t.current.getDuration()), [e]), D = o(async () => (e.log(
|
|
153
|
-
s.Debug,
|
|
154
|
-
"NostalgicDivaProvider.getCurrentTime",
|
|
155
|
-
t.current
|
|
156
|
-
), await t.current.getCurrentTime()), [e]), P = o(async () => (e.log(
|
|
157
|
-
s.Debug,
|
|
158
|
-
"NostalgicDivaProvider.getVolume",
|
|
159
|
-
t.current
|
|
160
|
-
), await t.current.getVolume()), [e]), V = o(async () => (e.log(
|
|
161
|
-
s.Debug,
|
|
162
|
-
"NostalgicDivaProvider.getMuted",
|
|
163
|
-
t.current
|
|
164
|
-
), await t.current.getMuted()), [e]), w = o(async () => (e.log(
|
|
165
|
-
s.Debug,
|
|
166
|
-
"NostalgicDivaProvider.getPlaybackRate",
|
|
167
|
-
t.current
|
|
168
|
-
), await t.current.getPlaybackRate()), [e]), T = o(
|
|
169
|
-
(c) => t.current.supports(c),
|
|
170
|
-
[]
|
|
171
|
-
), l = B(
|
|
172
|
-
() => ({
|
|
173
|
-
logger: e,
|
|
174
|
-
handleControllerChange: r,
|
|
175
|
-
loadVideo: i,
|
|
176
|
-
play: n,
|
|
177
|
-
pause: u,
|
|
178
|
-
setCurrentTime: p,
|
|
179
|
-
setVolume: y,
|
|
180
|
-
setMuted: h,
|
|
181
|
-
setPlaybackRate: E,
|
|
182
|
-
getDuration: b,
|
|
183
|
-
getCurrentTime: D,
|
|
184
|
-
getVolume: P,
|
|
185
|
-
getMuted: V,
|
|
186
|
-
getPlaybackRate: w,
|
|
187
|
-
supports: T
|
|
188
|
-
}),
|
|
189
|
-
[
|
|
190
|
-
e,
|
|
191
|
-
r,
|
|
192
|
-
i,
|
|
193
|
-
n,
|
|
194
|
-
u,
|
|
195
|
-
p,
|
|
196
|
-
y,
|
|
197
|
-
h,
|
|
198
|
-
E,
|
|
199
|
-
b,
|
|
200
|
-
D,
|
|
201
|
-
P,
|
|
202
|
-
V,
|
|
203
|
-
w,
|
|
204
|
-
T
|
|
205
|
-
]
|
|
206
|
-
);
|
|
207
|
-
return /* @__PURE__ */ d(W.Provider, { value: l, children: a });
|
|
208
|
-
}, Q = () => G(W);
|
|
209
|
-
class g {
|
|
210
|
-
constructor(e) {
|
|
211
|
-
this.type = e;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
const ee = /\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i, te = /\.(mp4|og[gv]|webm|mov|m4v)(#t=[,\d+]+)?($|\?)/i;
|
|
215
|
-
class ae extends g {
|
|
216
|
-
constructor() {
|
|
217
|
-
super("Audio");
|
|
218
|
-
}
|
|
219
|
-
canPlay(e) {
|
|
220
|
-
return ee.test(e) || te.test(e);
|
|
221
|
-
}
|
|
222
|
-
extractVideoId(e) {
|
|
223
|
-
return e;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const S = /^(?:(?:https?):)?(?:\/\/)?(?:www\.)?(?:(?:dailymotion\.com(?:\/embed)?\/video)|dai\.ly)\/([a-zA-Z0-9]+)(?:_[\w_-]+)?(?:[\w.#_-]+)?/;
|
|
227
|
-
class re extends g {
|
|
228
|
-
constructor() {
|
|
229
|
-
super("Dailymotion");
|
|
230
|
-
}
|
|
231
|
-
canPlay(e) {
|
|
232
|
-
return S.test(e);
|
|
233
|
-
}
|
|
234
|
-
extractVideoId(e) {
|
|
235
|
-
return S.exec(e)?.[1];
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
const A = /(?:www\.|)?nicovideo\.jp\/watch\/(\w+)$/;
|
|
239
|
-
class se extends g {
|
|
240
|
-
constructor() {
|
|
241
|
-
super("Niconico");
|
|
242
|
-
}
|
|
243
|
-
canPlay(e) {
|
|
244
|
-
return A.test(e);
|
|
245
|
-
}
|
|
246
|
-
extractVideoId(e) {
|
|
247
|
-
return A.exec(e)?.[1];
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
const ie = /(?:soundcloud\.com|snd\.sc)\/[^.]+$/;
|
|
251
|
-
class ne extends g {
|
|
252
|
-
constructor() {
|
|
253
|
-
super("SoundCloud");
|
|
254
|
-
}
|
|
255
|
-
canPlay(e) {
|
|
256
|
-
return ie.test(e);
|
|
257
|
-
}
|
|
258
|
-
extractVideoId(e) {
|
|
259
|
-
return e;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
const U = /(?:www\.|go\.)?twitch\.tv\/videos\/(\d+)($|\?)/;
|
|
263
|
-
class oe extends g {
|
|
264
|
-
constructor() {
|
|
265
|
-
super("Twitch");
|
|
266
|
-
}
|
|
267
|
-
canPlay(e) {
|
|
268
|
-
return U.test(e);
|
|
269
|
-
}
|
|
270
|
-
extractVideoId(e) {
|
|
271
|
-
return U.exec(e)?.[1];
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
const x = /vimeo\.com\/(\d+)$/;
|
|
275
|
-
class ce extends g {
|
|
276
|
-
constructor() {
|
|
277
|
-
super("Vimeo");
|
|
278
|
-
}
|
|
279
|
-
canPlay(e) {
|
|
280
|
-
return x.test(e);
|
|
281
|
-
}
|
|
282
|
-
extractVideoId(e) {
|
|
283
|
-
return x.exec(e)?.[1];
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
const _ = /(?:youtu\.be\/|youtube(?:-nocookie|education)?\.com\/(?:embed\/|v\/|watch\/|watch\?v=|watch\?.+&v=|shorts\/|live\/))((\w|-){11})|youtube\.com\/playlist\?list=|youtube\.com\/user\//;
|
|
287
|
-
class le extends g {
|
|
288
|
-
constructor() {
|
|
289
|
-
super("YouTube");
|
|
290
|
-
}
|
|
291
|
-
canPlay(e) {
|
|
292
|
-
return _.test(e);
|
|
293
|
-
}
|
|
294
|
-
extractVideoId(e) {
|
|
295
|
-
return _.exec(e)?.[1];
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
const de = [
|
|
299
|
-
new le(),
|
|
300
|
-
new oe(),
|
|
301
|
-
new ce(),
|
|
302
|
-
new re(),
|
|
303
|
-
new ne(),
|
|
304
|
-
new ae(),
|
|
305
|
-
new se()
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./PlayerContainer-VQ3YPGU_.js";
|
|
2
|
+
import { Suspense as o, createContext as s, lazy as c, memo as l, useCallback as u, useContext as d, useMemo as f, useRef as p } from "react";
|
|
3
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
4
|
+
import h from "react-dom";
|
|
5
|
+
//#region src/components/NostalgicDivaProvider.tsx
|
|
6
|
+
var g = s(void 0), _ = ({ children: n, logger: i = r }) => {
|
|
7
|
+
let a = p(t), o = u((t) => {
|
|
8
|
+
i.log(e.Debug, "NostalgicDivaProvider.handleControllerChange", a.current, t), a.current = t;
|
|
9
|
+
}, [i]), s = u(async (t) => {
|
|
10
|
+
i.log(e.Debug, "NostalgicDivaProvider.loadVideo", a.current), await a.current.loadVideo(t);
|
|
11
|
+
}, [i]), c = u(async () => {
|
|
12
|
+
i.log(e.Debug, "NostalgicDivaProvider.play", a.current), await a.current.play();
|
|
13
|
+
}, [i]), l = u(async () => {
|
|
14
|
+
i.log(e.Debug, "NostalgicDivaProvider.pause", a.current), await a.current.pause();
|
|
15
|
+
}, [i]), d = u(async (t) => {
|
|
16
|
+
i.log(e.Debug, "NostalgicDivaProvider.setCurrentTime", a.current), await a.current.setCurrentTime(t), await a.current.play();
|
|
17
|
+
}, [i]), h = u(async (t) => {
|
|
18
|
+
i.log(e.Debug, "NostalgicDivaProvider.setVolume", a.current), await a.current.setVolume(t);
|
|
19
|
+
}, [i]), _ = u(async (t) => {
|
|
20
|
+
i.log(e.Debug, "NostalgicDivaProvider.setMuted", a.current), await a.current.setMuted(t);
|
|
21
|
+
}, [i]), v = u(async (t) => {
|
|
22
|
+
i.log(e.Debug, "NostalgicDivaProvider.setPlaybackRate", a.current), await a.current.setPlaybackRate(t);
|
|
23
|
+
}, [i]), y = u(async () => (i.log(e.Debug, "NostalgicDivaProvider.getDuration", a.current), await a.current.getDuration()), [i]), b = u(async () => (i.log(e.Debug, "NostalgicDivaProvider.getCurrentTime", a.current), await a.current.getCurrentTime()), [i]), x = u(async () => (i.log(e.Debug, "NostalgicDivaProvider.getVolume", a.current), await a.current.getVolume()), [i]), S = u(async () => (i.log(e.Debug, "NostalgicDivaProvider.getMuted", a.current), await a.current.getMuted()), [i]), C = u(async () => (i.log(e.Debug, "NostalgicDivaProvider.getPlaybackRate", a.current), await a.current.getPlaybackRate()), [i]), w = u((e) => a.current.supports(e), []), T = f(() => ({
|
|
24
|
+
logger: i,
|
|
25
|
+
handleControllerChange: o,
|
|
26
|
+
loadVideo: s,
|
|
27
|
+
play: c,
|
|
28
|
+
pause: l,
|
|
29
|
+
setCurrentTime: d,
|
|
30
|
+
setVolume: h,
|
|
31
|
+
setMuted: _,
|
|
32
|
+
setPlaybackRate: v,
|
|
33
|
+
getDuration: y,
|
|
34
|
+
getCurrentTime: b,
|
|
35
|
+
getVolume: x,
|
|
36
|
+
getMuted: S,
|
|
37
|
+
getPlaybackRate: C,
|
|
38
|
+
supports: w
|
|
39
|
+
}), [
|
|
40
|
+
i,
|
|
41
|
+
o,
|
|
42
|
+
s,
|
|
43
|
+
c,
|
|
44
|
+
l,
|
|
45
|
+
d,
|
|
46
|
+
h,
|
|
47
|
+
_,
|
|
48
|
+
v,
|
|
49
|
+
y,
|
|
50
|
+
b,
|
|
51
|
+
x,
|
|
52
|
+
S,
|
|
53
|
+
C,
|
|
54
|
+
w
|
|
55
|
+
]);
|
|
56
|
+
return /* @__PURE__ */ m(g.Provider, {
|
|
57
|
+
value: T,
|
|
58
|
+
children: n
|
|
59
|
+
});
|
|
60
|
+
}, v = () => d(g), y = class {
|
|
61
|
+
type;
|
|
62
|
+
constructor(e) {
|
|
63
|
+
this.type = e;
|
|
64
|
+
}
|
|
65
|
+
}, b = /\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i, x = /\.(mp4|og[gv]|webm|mov|m4v)(#t=[,\d+]+)?($|\?)/i, S = class extends y {
|
|
66
|
+
constructor() {
|
|
67
|
+
super("Audio");
|
|
68
|
+
}
|
|
69
|
+
canPlay(e) {
|
|
70
|
+
return b.test(e) || x.test(e);
|
|
71
|
+
}
|
|
72
|
+
extractVideoId(e) {
|
|
73
|
+
return e;
|
|
74
|
+
}
|
|
75
|
+
}, C = /^(?:(?:https?):)?(?:\/\/)?(?:www\.)?(?:(?:dailymotion\.com(?:\/embed)?\/video)|dai\.ly)\/([a-zA-Z0-9]+)(?:_[\w_-]+)?(?:[\w.#_-]+)?/, w = class extends y {
|
|
76
|
+
constructor() {
|
|
77
|
+
super("Dailymotion");
|
|
78
|
+
}
|
|
79
|
+
canPlay(e) {
|
|
80
|
+
return C.test(e);
|
|
81
|
+
}
|
|
82
|
+
extractVideoId(e) {
|
|
83
|
+
return C.exec(e)?.[1];
|
|
84
|
+
}
|
|
85
|
+
}, T = /(?:www\.|)?nicovideo\.jp\/watch\/(\w+)$/, E = class extends y {
|
|
86
|
+
constructor() {
|
|
87
|
+
super("Niconico");
|
|
88
|
+
}
|
|
89
|
+
canPlay(e) {
|
|
90
|
+
return T.test(e);
|
|
91
|
+
}
|
|
92
|
+
extractVideoId(e) {
|
|
93
|
+
return T.exec(e)?.[1];
|
|
94
|
+
}
|
|
95
|
+
}, D = /(?:soundcloud\.com|snd\.sc)\/[^.]+$/, O = class extends y {
|
|
96
|
+
constructor() {
|
|
97
|
+
super("SoundCloud");
|
|
98
|
+
}
|
|
99
|
+
canPlay(e) {
|
|
100
|
+
return D.test(e);
|
|
101
|
+
}
|
|
102
|
+
extractVideoId(e) {
|
|
103
|
+
return e;
|
|
104
|
+
}
|
|
105
|
+
}, k = /(?:www\.|go\.)?twitch\.tv\/videos\/(\d+)($|\?)/, A = class extends y {
|
|
106
|
+
constructor() {
|
|
107
|
+
super("Twitch");
|
|
108
|
+
}
|
|
109
|
+
canPlay(e) {
|
|
110
|
+
return k.test(e);
|
|
111
|
+
}
|
|
112
|
+
extractVideoId(e) {
|
|
113
|
+
return k.exec(e)?.[1];
|
|
114
|
+
}
|
|
115
|
+
}, j = /vimeo\.com\/(\d+)$/, M = class extends y {
|
|
116
|
+
constructor() {
|
|
117
|
+
super("Vimeo");
|
|
118
|
+
}
|
|
119
|
+
canPlay(e) {
|
|
120
|
+
return j.test(e);
|
|
121
|
+
}
|
|
122
|
+
extractVideoId(e) {
|
|
123
|
+
return j.exec(e)?.[1];
|
|
124
|
+
}
|
|
125
|
+
}, N = /(?:youtu\.be\/|youtube(?:-nocookie|education)?\.com\/(?:embed\/|v\/|watch\/|watch\?v=|watch\?.+&v=|shorts\/|live\/))((\w|-){11})|youtube\.com\/playlist\?list=|youtube\.com\/user\//, P = [
|
|
126
|
+
new class extends y {
|
|
127
|
+
constructor() {
|
|
128
|
+
super("YouTube");
|
|
129
|
+
}
|
|
130
|
+
canPlay(e) {
|
|
131
|
+
return N.test(e);
|
|
132
|
+
}
|
|
133
|
+
extractVideoId(e) {
|
|
134
|
+
return N.exec(e)?.[1];
|
|
135
|
+
}
|
|
136
|
+
}(),
|
|
137
|
+
new A(),
|
|
138
|
+
new M(),
|
|
139
|
+
new w(),
|
|
140
|
+
new O(),
|
|
141
|
+
new S(),
|
|
142
|
+
new E()
|
|
306
143
|
];
|
|
307
|
-
function
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
const he = new Map(
|
|
311
|
-
Object.entries({
|
|
312
|
-
Audio: m(() => import("./AudioPlayer-BMxdg9dp.js")),
|
|
313
|
-
Dailymotion: m(() => import("./DailymotionPlayer-B4M9j0Lx.js")),
|
|
314
|
-
Niconico: m(() => import("./NiconicoPlayer-Cx3hGYsw.js")),
|
|
315
|
-
SoundCloud: m(() => import("./SoundCloudPlayer-C8QVPCXH.js")),
|
|
316
|
-
Twitch: m(() => import("./TwitchPlayer-C9D_eEaj.js")),
|
|
317
|
-
Vimeo: m(() => import("./VimeoPlayer-UnKk2VAq.js")),
|
|
318
|
-
YouTube: m(() => import("./YouTubePlayer-bNmEJD02.js"))
|
|
319
|
-
})
|
|
320
|
-
);
|
|
321
|
-
function pe(a) {
|
|
322
|
-
const e = ue(a);
|
|
323
|
-
if (e === void 0)
|
|
324
|
-
return;
|
|
325
|
-
const { type: t, extractVideoId: r } = e, i = r(a);
|
|
326
|
-
if (i !== void 0)
|
|
327
|
-
return { type: t, videoId: i };
|
|
328
|
-
}
|
|
329
|
-
const Y = $(() => /* @__PURE__ */ d("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ d(
|
|
330
|
-
"iframe",
|
|
331
|
-
{
|
|
332
|
-
src: "about:blank",
|
|
333
|
-
title: "about:blank",
|
|
334
|
-
style: {
|
|
335
|
-
width: "100%",
|
|
336
|
-
height: "100%",
|
|
337
|
-
border: 0
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
) })), ye = $(
|
|
341
|
-
({
|
|
342
|
-
src: a,
|
|
343
|
-
options: e,
|
|
344
|
-
onControllerChange: t
|
|
345
|
-
}) => {
|
|
346
|
-
const r = Q(), i = o(
|
|
347
|
-
(h) => {
|
|
348
|
-
r.handleControllerChange(h), t?.(h);
|
|
349
|
-
},
|
|
350
|
-
[r, t]
|
|
351
|
-
);
|
|
352
|
-
r.logger.log(s.Debug, "NostalgicDiva");
|
|
353
|
-
const n = pe(a);
|
|
354
|
-
if (n === void 0)
|
|
355
|
-
return r.logger.log(
|
|
356
|
-
s.Warning,
|
|
357
|
-
`Failed to extract type and videoId from src: "${a}". Returning EmptyPlayer.`
|
|
358
|
-
), /* @__PURE__ */ d(Y, {});
|
|
359
|
-
const { type: u, videoId: p } = n, y = he.get(u);
|
|
360
|
-
return y === void 0 ? (r.logger.log(
|
|
361
|
-
s.Warning,
|
|
362
|
-
`No player found for type "${u}" (videoId: "${p}"). Returning EmptyPlayer.`
|
|
363
|
-
), /* @__PURE__ */ d(Y, {})) : /* @__PURE__ */ d(z, { fallback: null, children: /* @__PURE__ */ d(
|
|
364
|
-
y,
|
|
365
|
-
{
|
|
366
|
-
logger: r.logger,
|
|
367
|
-
type: u,
|
|
368
|
-
onControllerChange: i,
|
|
369
|
-
videoId: p,
|
|
370
|
-
options: e
|
|
371
|
-
}
|
|
372
|
-
) });
|
|
373
|
-
}
|
|
374
|
-
);
|
|
375
|
-
class me extends HTMLElement {
|
|
376
|
-
static observedAttributes = ["src"];
|
|
377
|
-
container;
|
|
378
|
-
controller = f;
|
|
379
|
-
constructor() {
|
|
380
|
-
super(), this.container = this.attachShadow({ mode: "closed" });
|
|
381
|
-
}
|
|
382
|
-
get src() {
|
|
383
|
-
return this.getAttribute("src") ?? "";
|
|
384
|
-
}
|
|
385
|
-
set src(e) {
|
|
386
|
-
this.setAttribute("src", e);
|
|
387
|
-
}
|
|
388
|
-
#t = {
|
|
389
|
-
onError: (e) => this.dispatchEvent(new CustomEvent("error", { detail: e })),
|
|
390
|
-
onLoaded: (e) => this.dispatchEvent(new CustomEvent("loaded", { detail: e })),
|
|
391
|
-
onPlay: () => this.dispatchEvent(new CustomEvent("play")),
|
|
392
|
-
onPause: () => this.dispatchEvent(new CustomEvent("pause")),
|
|
393
|
-
onEnded: () => this.dispatchEvent(new CustomEvent("ended")),
|
|
394
|
-
onTimeUpdate: (e) => this.dispatchEvent(new CustomEvent("timeupdate", { detail: e }))
|
|
395
|
-
};
|
|
396
|
-
#a = (e) => {
|
|
397
|
-
console.debug(
|
|
398
|
-
"[@nostalgic-diva/web-components] handleControllerChange"
|
|
399
|
-
), this.controller = e;
|
|
400
|
-
};
|
|
401
|
-
#e() {
|
|
402
|
-
X.render(
|
|
403
|
-
/* @__PURE__ */ d(J, { children: /* @__PURE__ */ d(
|
|
404
|
-
ye,
|
|
405
|
-
{
|
|
406
|
-
src: this.src,
|
|
407
|
-
options: this.#t,
|
|
408
|
-
onControllerChange: this.#a
|
|
409
|
-
}
|
|
410
|
-
) }),
|
|
411
|
-
this.container
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
connectedCallback() {
|
|
415
|
-
console.debug("[@nostalgic-diva/web-components] connectedCallback"), this.#e();
|
|
416
|
-
}
|
|
417
|
-
disconnectedCallback() {
|
|
418
|
-
console.debug("[@nostalgic-diva/web-components] disconnectedCallback");
|
|
419
|
-
}
|
|
420
|
-
attributeChangedCallback() {
|
|
421
|
-
console.debug(
|
|
422
|
-
"[@nostalgic-diva/web-components] attributeChangedCallback"
|
|
423
|
-
), this.#e();
|
|
424
|
-
}
|
|
425
|
-
async loadVideo(e) {
|
|
426
|
-
await this.controller.loadVideo(e);
|
|
427
|
-
}
|
|
428
|
-
async play() {
|
|
429
|
-
await this.controller.play();
|
|
430
|
-
}
|
|
431
|
-
async pause() {
|
|
432
|
-
await this.controller.pause();
|
|
433
|
-
}
|
|
434
|
-
async setCurrentTime(e) {
|
|
435
|
-
await this.controller.setCurrentTime(e);
|
|
436
|
-
}
|
|
437
|
-
async setVolume(e) {
|
|
438
|
-
await this.controller.setVolume(e);
|
|
439
|
-
}
|
|
440
|
-
async setMuted(e) {
|
|
441
|
-
await this.controller.setMuted(e);
|
|
442
|
-
}
|
|
443
|
-
async setPlaybackRate(e) {
|
|
444
|
-
await this.controller.setPlaybackRate(e);
|
|
445
|
-
}
|
|
446
|
-
async getDuration() {
|
|
447
|
-
return await this.controller.getDuration();
|
|
448
|
-
}
|
|
449
|
-
async getCurrentTime() {
|
|
450
|
-
return await this.controller.getCurrentTime();
|
|
451
|
-
}
|
|
452
|
-
async getVolume() {
|
|
453
|
-
return await this.controller.getVolume();
|
|
454
|
-
}
|
|
455
|
-
async getMuted() {
|
|
456
|
-
return await this.controller.getMuted();
|
|
457
|
-
}
|
|
458
|
-
async getPlaybackRate() {
|
|
459
|
-
return await this.controller.getPlaybackRate();
|
|
460
|
-
}
|
|
461
|
-
supports(e) {
|
|
462
|
-
return this.controller.supports(e);
|
|
463
|
-
}
|
|
144
|
+
function F(e) {
|
|
145
|
+
return P.find((t) => t.canPlay(e));
|
|
464
146
|
}
|
|
465
|
-
|
|
466
|
-
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/components/NostalgicDiva.tsx
|
|
149
|
+
var I = new Map(Object.entries({
|
|
150
|
+
Audio: c(() => import("./AudioPlayer-7plDTn5w.js")),
|
|
151
|
+
Dailymotion: c(() => import("./DailymotionPlayer-4LQmDDSf.js")),
|
|
152
|
+
Niconico: c(() => import("./NiconicoPlayer-GFCXF5V7.js")),
|
|
153
|
+
SoundCloud: c(() => import("./SoundCloudPlayer-Cqo5VU57.js")),
|
|
154
|
+
Twitch: c(() => import("./TwitchPlayer-BeQUOIE3.js")),
|
|
155
|
+
Vimeo: c(() => import("./VimeoPlayer-CgWujBXW.js")),
|
|
156
|
+
YouTube: c(() => import("./YouTubePlayer-CkaOKK_g.js"))
|
|
157
|
+
}));
|
|
158
|
+
function L(e) {
|
|
159
|
+
let t = F(e);
|
|
160
|
+
if (t === void 0) return;
|
|
161
|
+
let { type: n, extractVideoId: r } = t, i = r(e);
|
|
162
|
+
if (i !== void 0) return {
|
|
163
|
+
type: n,
|
|
164
|
+
videoId: i
|
|
165
|
+
};
|
|
467
166
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
getDuration() {
|
|
581
|
-
if (this.debug("getDuration"), this.impl === void 0)
|
|
582
|
-
throw this.createPlayerNotAttachedError();
|
|
583
|
-
if (this.impl.getDuration === void 0)
|
|
584
|
-
throw this.createCommandNotSupportedError("getDuration");
|
|
585
|
-
return this.impl.getDuration();
|
|
586
|
-
}
|
|
587
|
-
getCurrentTime() {
|
|
588
|
-
if (this.debug("getCurrentTime"), this.impl === void 0)
|
|
589
|
-
throw this.createPlayerNotAttachedError();
|
|
590
|
-
if (this.impl.getCurrentTime === void 0)
|
|
591
|
-
throw this.createCommandNotSupportedError("getCurrentTime");
|
|
592
|
-
return this.impl.getCurrentTime();
|
|
593
|
-
}
|
|
594
|
-
getVolume() {
|
|
595
|
-
if (this.debug("getVolume"), this.impl === void 0)
|
|
596
|
-
throw this.createPlayerNotAttachedError();
|
|
597
|
-
if (this.impl.getVolume === void 0)
|
|
598
|
-
throw this.createCommandNotSupportedError("getVolume");
|
|
599
|
-
return this.impl.getVolume();
|
|
600
|
-
}
|
|
601
|
-
getMuted() {
|
|
602
|
-
if (this.debug("getMuted"), this.impl === void 0)
|
|
603
|
-
throw this.createPlayerNotAttachedError();
|
|
604
|
-
if (this.impl.getMuted === void 0)
|
|
605
|
-
throw this.createCommandNotSupportedError("getMuted");
|
|
606
|
-
return this.impl.getMuted();
|
|
607
|
-
}
|
|
608
|
-
getPlaybackRate() {
|
|
609
|
-
if (this.debug("getPlaybackRate"), this.impl === void 0)
|
|
610
|
-
throw this.createPlayerNotAttachedError();
|
|
611
|
-
if (this.impl.getPlaybackRate === void 0)
|
|
612
|
-
throw this.createCommandNotSupportedError("getPlaybackRate");
|
|
613
|
-
return this.impl.getPlaybackRate();
|
|
614
|
-
}
|
|
615
|
-
supports(e) {
|
|
616
|
-
if (this.impl === void 0)
|
|
617
|
-
throw this.createPlayerNotAttachedError();
|
|
618
|
-
return this.impl.supports(e);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
const Te = ({
|
|
622
|
-
logger: a,
|
|
623
|
-
type: e,
|
|
624
|
-
loadScript: t,
|
|
625
|
-
playerFactory: r,
|
|
626
|
-
onControllerChange: i,
|
|
627
|
-
videoId: n,
|
|
628
|
-
options: u,
|
|
629
|
-
controllerFactory: p,
|
|
630
|
-
children: y
|
|
631
|
-
}) => {
|
|
632
|
-
a.log(s.Debug, "PlayerContainer");
|
|
633
|
-
const h = C(n), E = C(void 0), [b, D] = I(), [P, V] = I(f), w = o(
|
|
634
|
-
(l) => {
|
|
635
|
-
V(l), i?.(l);
|
|
636
|
-
},
|
|
637
|
-
[i]
|
|
638
|
-
);
|
|
639
|
-
k(() => {
|
|
640
|
-
(t?.() ?? Promise.resolve()).then(() => r(E.current, h.current)).then((l) => D(l));
|
|
641
|
-
}, [t, r]), k(() => {
|
|
642
|
-
if (b === void 0)
|
|
643
|
-
return;
|
|
644
|
-
const l = new M(
|
|
645
|
-
a,
|
|
646
|
-
e,
|
|
647
|
-
b,
|
|
648
|
-
u,
|
|
649
|
-
p
|
|
650
|
-
);
|
|
651
|
-
return l.attach(h.current).then(() => w(l)), () => {
|
|
652
|
-
l.detach().finally(() => w(f));
|
|
653
|
-
};
|
|
654
|
-
}, [
|
|
655
|
-
a,
|
|
656
|
-
e,
|
|
657
|
-
t,
|
|
658
|
-
b,
|
|
659
|
-
u,
|
|
660
|
-
p,
|
|
661
|
-
w
|
|
662
|
-
]);
|
|
663
|
-
const T = be(n);
|
|
664
|
-
return k(() => {
|
|
665
|
-
T !== void 0 && P.loadVideo(n);
|
|
666
|
-
}, [T, n, P]), /* @__PURE__ */ d(F, { children: y(E, h.current) });
|
|
167
|
+
var R = l(() => /* @__PURE__ */ m("div", {
|
|
168
|
+
style: {
|
|
169
|
+
width: "100%",
|
|
170
|
+
height: "100%"
|
|
171
|
+
},
|
|
172
|
+
children: /* @__PURE__ */ m("iframe", {
|
|
173
|
+
src: "about:blank",
|
|
174
|
+
title: "about:blank",
|
|
175
|
+
style: {
|
|
176
|
+
width: "100%",
|
|
177
|
+
height: "100%",
|
|
178
|
+
border: 0
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
})), z = l(({ src: t, options: n, onControllerChange: r }) => {
|
|
182
|
+
let i = v(), a = u((e) => {
|
|
183
|
+
i.handleControllerChange(e), r?.(e);
|
|
184
|
+
}, [i, r]);
|
|
185
|
+
i.logger.log(e.Debug, "NostalgicDiva");
|
|
186
|
+
let s = L(t);
|
|
187
|
+
if (s === void 0) return i.logger.log(e.Warning, `Failed to extract type and videoId from src: "${t}". Returning EmptyPlayer.`), /* @__PURE__ */ m(R, {});
|
|
188
|
+
let { type: c, videoId: l } = s, d = I.get(c);
|
|
189
|
+
return d === void 0 ? (i.logger.log(e.Warning, `No player found for type "${c}" (videoId: "${l}"). Returning EmptyPlayer.`), /* @__PURE__ */ m(R, {})) : /* @__PURE__ */ m(o, {
|
|
190
|
+
fallback: null,
|
|
191
|
+
children: /* @__PURE__ */ m(d, {
|
|
192
|
+
logger: i.logger,
|
|
193
|
+
type: c,
|
|
194
|
+
onControllerChange: a,
|
|
195
|
+
videoId: l,
|
|
196
|
+
options: n
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
}), B = class extends HTMLElement {
|
|
200
|
+
static observedAttributes = ["src"];
|
|
201
|
+
container;
|
|
202
|
+
controller = t;
|
|
203
|
+
constructor() {
|
|
204
|
+
super(), this.container = this.attachShadow({ mode: "closed" });
|
|
205
|
+
}
|
|
206
|
+
get src() {
|
|
207
|
+
return this.getAttribute("src") ?? "";
|
|
208
|
+
}
|
|
209
|
+
set src(e) {
|
|
210
|
+
this.setAttribute("src", e);
|
|
211
|
+
}
|
|
212
|
+
#e = {
|
|
213
|
+
onError: (e) => this.dispatchEvent(new CustomEvent("error", { detail: e })),
|
|
214
|
+
onLoaded: (e) => this.dispatchEvent(new CustomEvent("loaded", { detail: e })),
|
|
215
|
+
onPlay: () => this.dispatchEvent(new CustomEvent("play")),
|
|
216
|
+
onPause: () => this.dispatchEvent(new CustomEvent("pause")),
|
|
217
|
+
onEnded: () => this.dispatchEvent(new CustomEvent("ended")),
|
|
218
|
+
onTimeUpdate: (e) => this.dispatchEvent(new CustomEvent("timeupdate", { detail: e }))
|
|
219
|
+
};
|
|
220
|
+
#t = (e) => {
|
|
221
|
+
console.debug("[@nostalgic-diva/web-components] handleControllerChange"), this.controller = e;
|
|
222
|
+
};
|
|
223
|
+
#n() {
|
|
224
|
+
h.render(/* @__PURE__ */ m(_, { children: /* @__PURE__ */ m(z, {
|
|
225
|
+
src: this.src,
|
|
226
|
+
options: this.#e,
|
|
227
|
+
onControllerChange: this.#t
|
|
228
|
+
}) }), this.container);
|
|
229
|
+
}
|
|
230
|
+
connectedCallback() {
|
|
231
|
+
console.debug("[@nostalgic-diva/web-components] connectedCallback"), this.#n();
|
|
232
|
+
}
|
|
233
|
+
disconnectedCallback() {
|
|
234
|
+
console.debug("[@nostalgic-diva/web-components] disconnectedCallback");
|
|
235
|
+
}
|
|
236
|
+
attributeChangedCallback() {
|
|
237
|
+
console.debug("[@nostalgic-diva/web-components] attributeChangedCallback"), this.#n();
|
|
238
|
+
}
|
|
239
|
+
async loadVideo(e) {
|
|
240
|
+
await this.controller.loadVideo(e);
|
|
241
|
+
}
|
|
242
|
+
async play() {
|
|
243
|
+
await this.controller.play();
|
|
244
|
+
}
|
|
245
|
+
async pause() {
|
|
246
|
+
await this.controller.pause();
|
|
247
|
+
}
|
|
248
|
+
async setCurrentTime(e) {
|
|
249
|
+
await this.controller.setCurrentTime(e);
|
|
250
|
+
}
|
|
251
|
+
async setVolume(e) {
|
|
252
|
+
await this.controller.setVolume(e);
|
|
253
|
+
}
|
|
254
|
+
async setMuted(e) {
|
|
255
|
+
await this.controller.setMuted(e);
|
|
256
|
+
}
|
|
257
|
+
async setPlaybackRate(e) {
|
|
258
|
+
await this.controller.setPlaybackRate(e);
|
|
259
|
+
}
|
|
260
|
+
async getDuration() {
|
|
261
|
+
return await this.controller.getDuration();
|
|
262
|
+
}
|
|
263
|
+
async getCurrentTime() {
|
|
264
|
+
return await this.controller.getCurrentTime();
|
|
265
|
+
}
|
|
266
|
+
async getVolume() {
|
|
267
|
+
return await this.controller.getVolume();
|
|
268
|
+
}
|
|
269
|
+
async getMuted() {
|
|
270
|
+
return await this.controller.getMuted();
|
|
271
|
+
}
|
|
272
|
+
async getPlaybackRate() {
|
|
273
|
+
return await this.controller.getPlaybackRate();
|
|
274
|
+
}
|
|
275
|
+
supports(e) {
|
|
276
|
+
return this.controller.supports(e);
|
|
277
|
+
}
|
|
667
278
|
};
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
this.player.onerror = (e) => this.options?.onError?.(e), this.player.onloadeddata = () => this.options?.onLoaded?.({ id: this.player.src }), this.player.onplay = () => this.options?.onPlay?.(), this.player.onpause = () => this.options?.onPause?.(), this.player.onended = () => this.options?.onEnded?.(), this.player.ontimeupdate = () => {
|
|
671
|
-
this.options?.onTimeUpdate?.({
|
|
672
|
-
duration: this.player.duration,
|
|
673
|
-
percent: this.player.currentTime / this.player.duration,
|
|
674
|
-
seconds: this.player.currentTime
|
|
675
|
-
});
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
async detach() {
|
|
679
|
-
this.player.onerror = null, this.player.onloadeddata = null, this.player.onplay = null, this.player.onpause = null, this.player.onended = null, this.player.ontimeupdate = null;
|
|
680
|
-
}
|
|
681
|
-
async loadVideo(e) {
|
|
682
|
-
this.player.src = e;
|
|
683
|
-
}
|
|
684
|
-
async play() {
|
|
685
|
-
await this.player.play();
|
|
686
|
-
}
|
|
687
|
-
async pause() {
|
|
688
|
-
this.player.pause();
|
|
689
|
-
}
|
|
690
|
-
async setCurrentTime(e) {
|
|
691
|
-
this.player.currentTime = e;
|
|
692
|
-
}
|
|
693
|
-
async setVolume(e) {
|
|
694
|
-
this.player.volume = e;
|
|
695
|
-
}
|
|
696
|
-
async setMuted(e) {
|
|
697
|
-
this.player.muted = e;
|
|
698
|
-
}
|
|
699
|
-
async setPlaybackRate(e) {
|
|
700
|
-
this.player.playbackRate = e;
|
|
701
|
-
}
|
|
702
|
-
async getDuration() {
|
|
703
|
-
return this.player.duration;
|
|
704
|
-
}
|
|
705
|
-
async getCurrentTime() {
|
|
706
|
-
return this.player.currentTime;
|
|
707
|
-
}
|
|
708
|
-
async getVolume() {
|
|
709
|
-
return this.player.volume;
|
|
710
|
-
}
|
|
711
|
-
async getMuted() {
|
|
712
|
-
return this.player.muted;
|
|
713
|
-
}
|
|
714
|
-
async getPlaybackRate() {
|
|
715
|
-
return this.player.playbackRate;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
const O = [
|
|
719
|
-
"apiready",
|
|
720
|
-
"seeked",
|
|
721
|
-
"video_end",
|
|
722
|
-
"durationchange",
|
|
723
|
-
"pause",
|
|
724
|
-
"playing",
|
|
725
|
-
"error"
|
|
726
|
-
];
|
|
727
|
-
class Ve extends v {
|
|
728
|
-
handlePlayerEvents = (e) => {
|
|
729
|
-
switch (e.type) {
|
|
730
|
-
case "apiready":
|
|
731
|
-
this.options?.onLoaded?.({ id: this.player.video.videoId });
|
|
732
|
-
break;
|
|
733
|
-
case "seeked":
|
|
734
|
-
this.options?.onTimeUpdate?.({
|
|
735
|
-
duration: this.player.duration,
|
|
736
|
-
percent: this.player.currentTime / this.player.duration,
|
|
737
|
-
seconds: this.player.currentTime
|
|
738
|
-
});
|
|
739
|
-
break;
|
|
740
|
-
case "video_end":
|
|
741
|
-
this.options?.onEnded?.();
|
|
742
|
-
break;
|
|
743
|
-
case "durationchange":
|
|
744
|
-
break;
|
|
745
|
-
case "pause":
|
|
746
|
-
this.options?.onPause?.();
|
|
747
|
-
break;
|
|
748
|
-
case "playing":
|
|
749
|
-
this.options?.onPlay?.();
|
|
750
|
-
break;
|
|
751
|
-
case "error":
|
|
752
|
-
this.options?.onError?.(e);
|
|
753
|
-
break;
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
async attach(e) {
|
|
757
|
-
for (const t of O)
|
|
758
|
-
this.player.addEventListener(t, this.handlePlayerEvents);
|
|
759
|
-
}
|
|
760
|
-
async detach() {
|
|
761
|
-
for (const e of O)
|
|
762
|
-
this.player.removeEventListener(e, this.handlePlayerEvents);
|
|
763
|
-
}
|
|
764
|
-
async loadVideo(e) {
|
|
765
|
-
this.player.load(e);
|
|
766
|
-
}
|
|
767
|
-
async play() {
|
|
768
|
-
this.player.play();
|
|
769
|
-
}
|
|
770
|
-
async pause() {
|
|
771
|
-
this.player.pause();
|
|
772
|
-
}
|
|
773
|
-
async setCurrentTime(e) {
|
|
774
|
-
this.player.seek(e);
|
|
775
|
-
}
|
|
776
|
-
async setVolume(e) {
|
|
777
|
-
this.player.setVolume(e);
|
|
778
|
-
}
|
|
779
|
-
async setMuted(e) {
|
|
780
|
-
this.player.setMuted(e);
|
|
781
|
-
}
|
|
782
|
-
setPlaybackRate = void 0;
|
|
783
|
-
async getDuration() {
|
|
784
|
-
return this.player.duration;
|
|
785
|
-
}
|
|
786
|
-
async getCurrentTime() {
|
|
787
|
-
return this.player.currentTime;
|
|
788
|
-
}
|
|
789
|
-
async getVolume() {
|
|
790
|
-
return this.player.volume;
|
|
791
|
-
}
|
|
792
|
-
async getMuted() {
|
|
793
|
-
return this.player.muted;
|
|
794
|
-
}
|
|
795
|
-
getPlaybackRate = void 0;
|
|
796
|
-
}
|
|
797
|
-
var N = /* @__PURE__ */ ((a) => (a[a.Play = 2] = "Play", a[a.Pause = 3] = "Pause", a[a.End = 4] = "End", a))(N || {});
|
|
798
|
-
class R extends v {
|
|
799
|
-
static origin = "https://embed.nicovideo.jp";
|
|
800
|
-
duration = 0;
|
|
801
|
-
currentTime = 0;
|
|
802
|
-
volume = 0;
|
|
803
|
-
muted = !1;
|
|
804
|
-
handleMessage = (e) => {
|
|
805
|
-
if (e.origin !== R.origin) return;
|
|
806
|
-
const t = e.data;
|
|
807
|
-
switch (t.eventName) {
|
|
808
|
-
case "playerStatusChange":
|
|
809
|
-
this.logger.log(
|
|
810
|
-
s.Debug,
|
|
811
|
-
`player status changed: ${N[t.data.playerStatus] ?? t.data.playerStatus}`
|
|
812
|
-
);
|
|
813
|
-
break;
|
|
814
|
-
case "statusChange":
|
|
815
|
-
switch (this.logger.log(
|
|
816
|
-
s.Debug,
|
|
817
|
-
`status changed: ${N[t.data.playerStatus] ?? t.data.playerStatus}`
|
|
818
|
-
), t.data.playerStatus) {
|
|
819
|
-
case 2:
|
|
820
|
-
this.options?.onPlay?.();
|
|
821
|
-
break;
|
|
822
|
-
case 3:
|
|
823
|
-
this.options?.onPause?.();
|
|
824
|
-
break;
|
|
825
|
-
case 4:
|
|
826
|
-
this.options?.onEnded?.();
|
|
827
|
-
break;
|
|
828
|
-
}
|
|
829
|
-
break;
|
|
830
|
-
case "playerMetadataChange":
|
|
831
|
-
t.data.duration !== void 0 && (this.duration = t.data.duration / 1e3), this.currentTime = t.data.currentTime === void 0 ? 0 : t.data.currentTime / 1e3, this.volume = t.data.volume, this.muted = t.data.muted, this.options?.onTimeUpdate?.({
|
|
832
|
-
duration: this.duration,
|
|
833
|
-
percent: this.currentTime !== 0 && this.duration !== 0 ? this.currentTime / this.duration : 0,
|
|
834
|
-
seconds: this.currentTime
|
|
835
|
-
});
|
|
836
|
-
break;
|
|
837
|
-
case "loadComplete":
|
|
838
|
-
this.logger.log(s.Debug, "load completed"), this.duration = t.data.videoInfo.lengthInSeconds, this.options?.onLoaded?.({ id: t.data.videoInfo.watchId });
|
|
839
|
-
break;
|
|
840
|
-
case "error":
|
|
841
|
-
this.options?.onError?.(t);
|
|
842
|
-
break;
|
|
843
|
-
case "player-error:video:play":
|
|
844
|
-
case "player-error:video:seek":
|
|
845
|
-
this.options?.onError?.(t);
|
|
846
|
-
break;
|
|
847
|
-
default:
|
|
848
|
-
this.logger.log(
|
|
849
|
-
s.Debug,
|
|
850
|
-
"message",
|
|
851
|
-
t.eventName,
|
|
852
|
-
t.data
|
|
853
|
-
);
|
|
854
|
-
break;
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
async attach() {
|
|
858
|
-
window.addEventListener("message", this.handleMessage);
|
|
859
|
-
}
|
|
860
|
-
async detach() {
|
|
861
|
-
window.removeEventListener("message", this.handleMessage);
|
|
862
|
-
}
|
|
863
|
-
async loadVideo(e) {
|
|
864
|
-
return new Promise((t, r) => {
|
|
865
|
-
this.duration = 0, this.currentTime = 0, this.volume = 0, this.muted = !1, this.player.onload = () => {
|
|
866
|
-
this.player.onload = null, t();
|
|
867
|
-
}, this.player.src = `https://embed.nicovideo.jp/watch/${e}?jsapi=1&playerId=1`;
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
// https://blog.hayu.io/web/create/nicovideo-embed-player-api/.
|
|
871
|
-
postMessage(e) {
|
|
872
|
-
this.player.contentWindow?.postMessage(
|
|
873
|
-
{
|
|
874
|
-
...e,
|
|
875
|
-
playerId: "1",
|
|
876
|
-
sourceConnectorType: 1
|
|
877
|
-
},
|
|
878
|
-
R.origin
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
async play() {
|
|
882
|
-
this.postMessage({ eventName: "play" });
|
|
883
|
-
}
|
|
884
|
-
async pause() {
|
|
885
|
-
this.postMessage({ eventName: "pause" });
|
|
886
|
-
}
|
|
887
|
-
async setCurrentTime(e) {
|
|
888
|
-
this.postMessage({ eventName: "seek", data: { time: e * 1e3 } });
|
|
889
|
-
}
|
|
890
|
-
async setVolume(e) {
|
|
891
|
-
this.postMessage({
|
|
892
|
-
eventName: "volumeChange",
|
|
893
|
-
data: { volume: e }
|
|
894
|
-
});
|
|
895
|
-
}
|
|
896
|
-
async setMuted(e) {
|
|
897
|
-
this.postMessage({
|
|
898
|
-
eventName: "mute",
|
|
899
|
-
data: { mute: e }
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
setPlaybackRate = void 0;
|
|
903
|
-
async getDuration() {
|
|
904
|
-
return this.duration;
|
|
905
|
-
}
|
|
906
|
-
async getCurrentTime() {
|
|
907
|
-
return this.currentTime;
|
|
908
|
-
}
|
|
909
|
-
async getVolume() {
|
|
910
|
-
return this.volume;
|
|
911
|
-
}
|
|
912
|
-
async getMuted() {
|
|
913
|
-
return this.muted;
|
|
914
|
-
}
|
|
915
|
-
getPlaybackRate = void 0;
|
|
916
|
-
}
|
|
917
|
-
class L extends v {
|
|
918
|
-
getDurationCore() {
|
|
919
|
-
return new Promise((e, t) => {
|
|
920
|
-
this.player.getDuration(e);
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
attach(e) {
|
|
924
|
-
return new Promise((t, r) => {
|
|
925
|
-
this.player.bind(SC.Widget.Events.READY, () => {
|
|
926
|
-
this.player.bind(
|
|
927
|
-
SC.Widget.Events.PLAY_PROGRESS,
|
|
928
|
-
async (i) => {
|
|
929
|
-
const n = await this.getDurationCore();
|
|
930
|
-
this.options?.onTimeUpdate?.({
|
|
931
|
-
duration: n / 1e3,
|
|
932
|
-
percent: i.currentPosition / n,
|
|
933
|
-
seconds: i.currentPosition / 1e3
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
), this.player.bind(
|
|
937
|
-
SC.Widget.Events.ERROR,
|
|
938
|
-
(i) => this.options?.onError?.(i)
|
|
939
|
-
), this.player.bind(
|
|
940
|
-
SC.Widget.Events.PLAY,
|
|
941
|
-
() => this.options?.onPlay?.()
|
|
942
|
-
), this.player.bind(
|
|
943
|
-
SC.Widget.Events.PAUSE,
|
|
944
|
-
() => this.options?.onPause?.()
|
|
945
|
-
), this.player.bind(
|
|
946
|
-
SC.Widget.Events.FINISH,
|
|
947
|
-
() => this.options?.onEnded?.()
|
|
948
|
-
), this.options?.onLoaded?.({ id: e }), t();
|
|
949
|
-
});
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
async detach() {
|
|
953
|
-
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);
|
|
954
|
-
}
|
|
955
|
-
static playerLoadAsync(e, t, r) {
|
|
956
|
-
return new Promise((i, n) => {
|
|
957
|
-
e.load(t, { ...r, callback: i });
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
async loadVideo(e) {
|
|
961
|
-
await L.playerLoadAsync(this.player, e, {
|
|
962
|
-
auto_play: !0
|
|
963
|
-
}), this.options?.onLoaded?.({ id: e });
|
|
964
|
-
}
|
|
965
|
-
async play() {
|
|
966
|
-
this.player.play();
|
|
967
|
-
}
|
|
968
|
-
async pause() {
|
|
969
|
-
this.player.pause();
|
|
970
|
-
}
|
|
971
|
-
async setCurrentTime(e) {
|
|
972
|
-
this.player.seekTo(e * 1e3);
|
|
973
|
-
}
|
|
974
|
-
async setVolume(e) {
|
|
975
|
-
this.player.setVolume(e * 100);
|
|
976
|
-
}
|
|
977
|
-
setMuted = void 0;
|
|
978
|
-
setPlaybackRate = void 0;
|
|
979
|
-
async getDuration() {
|
|
980
|
-
return await this.getDurationCore() / 1e3;
|
|
981
|
-
}
|
|
982
|
-
getCurrentTimeCore() {
|
|
983
|
-
return new Promise((e, t) => {
|
|
984
|
-
this.player.getPosition(e);
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
async getCurrentTime() {
|
|
988
|
-
return await this.getCurrentTimeCore() / 1e3;
|
|
989
|
-
}
|
|
990
|
-
getVolumeCore() {
|
|
991
|
-
return new Promise((e, t) => {
|
|
992
|
-
this.player.getVolume(e);
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
async getVolume() {
|
|
996
|
-
return await this.getVolumeCore() / 100;
|
|
997
|
-
}
|
|
998
|
-
getMuted = void 0;
|
|
999
|
-
getPlaybackRate = void 0;
|
|
1000
|
-
}
|
|
1001
|
-
class fe extends v {
|
|
1002
|
-
handleReady = () => {
|
|
1003
|
-
this.options?.onLoaded?.({ id: this.player.getVideo() });
|
|
1004
|
-
};
|
|
1005
|
-
handlePlay = () => {
|
|
1006
|
-
this.options?.onPlay?.();
|
|
1007
|
-
};
|
|
1008
|
-
handlePause = () => {
|
|
1009
|
-
this.options?.onPause?.();
|
|
1010
|
-
};
|
|
1011
|
-
handleEnded = () => {
|
|
1012
|
-
this.options?.onEnded?.();
|
|
1013
|
-
};
|
|
1014
|
-
handleSeek = () => {
|
|
1015
|
-
this.options?.onTimeUpdate?.({
|
|
1016
|
-
duration: 0,
|
|
1017
|
-
percent: 0,
|
|
1018
|
-
seconds: 0
|
|
1019
|
-
});
|
|
1020
|
-
};
|
|
1021
|
-
async attach(e) {
|
|
1022
|
-
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);
|
|
1023
|
-
}
|
|
1024
|
-
async detach() {
|
|
1025
|
-
}
|
|
1026
|
-
async loadVideo(e) {
|
|
1027
|
-
this.player.setVideo(e, 0);
|
|
1028
|
-
}
|
|
1029
|
-
async play() {
|
|
1030
|
-
this.player.play();
|
|
1031
|
-
}
|
|
1032
|
-
async pause() {
|
|
1033
|
-
this.player.pause();
|
|
1034
|
-
}
|
|
1035
|
-
async setCurrentTime(e) {
|
|
1036
|
-
this.player.seek(e);
|
|
1037
|
-
}
|
|
1038
|
-
async setVolume(e) {
|
|
1039
|
-
this.player.setVolume(e);
|
|
1040
|
-
}
|
|
1041
|
-
async setMuted(e) {
|
|
1042
|
-
this.player.setMuted(e);
|
|
1043
|
-
}
|
|
1044
|
-
setPlaybackRate = void 0;
|
|
1045
|
-
async getDuration() {
|
|
1046
|
-
return this.player.getDuration();
|
|
1047
|
-
}
|
|
1048
|
-
async getCurrentTime() {
|
|
1049
|
-
return this.player.getCurrentTime();
|
|
1050
|
-
}
|
|
1051
|
-
async getVolume() {
|
|
1052
|
-
return this.player.getVolume();
|
|
1053
|
-
}
|
|
1054
|
-
async getMuted() {
|
|
1055
|
-
return this.player.getMuted();
|
|
1056
|
-
}
|
|
1057
|
-
getPlaybackRate = void 0;
|
|
1058
|
-
}
|
|
1059
|
-
class ke extends v {
|
|
1060
|
-
async attach() {
|
|
1061
|
-
await this.player.ready(), this.player.on("error", (e) => this.options?.onError?.(e)), this.player.on(
|
|
1062
|
-
"loaded",
|
|
1063
|
-
(e) => this.options?.onLoaded?.({ id: e.id.toString() })
|
|
1064
|
-
), this.player.on("play", () => this.options?.onPlay?.()), this.player.on("pause", () => this.options?.onPause?.()), this.player.on("ended", () => this.options?.onEnded?.()), this.player.on("timeupdate", (e) => {
|
|
1065
|
-
this.options?.onTimeUpdate?.({
|
|
1066
|
-
duration: e.duration,
|
|
1067
|
-
percent: e.percent,
|
|
1068
|
-
seconds: e.seconds
|
|
1069
|
-
});
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
async detach() {
|
|
1073
|
-
this.player.off("error"), this.player.off("loaded"), this.player.off("play"), this.player.off("pause"), this.player.off("ended"), this.player.off("timeupdate");
|
|
1074
|
-
}
|
|
1075
|
-
async loadVideo(e) {
|
|
1076
|
-
await this.player.loadVideo(e);
|
|
1077
|
-
}
|
|
1078
|
-
async play() {
|
|
1079
|
-
await this.player.play();
|
|
1080
|
-
}
|
|
1081
|
-
async pause() {
|
|
1082
|
-
await this.player.pause();
|
|
1083
|
-
}
|
|
1084
|
-
async setCurrentTime(e) {
|
|
1085
|
-
await this.player.setCurrentTime(e);
|
|
1086
|
-
}
|
|
1087
|
-
async setVolume(e) {
|
|
1088
|
-
await this.player.setVolume(e);
|
|
1089
|
-
}
|
|
1090
|
-
async setMuted(e) {
|
|
1091
|
-
await this.player.setMuted(e);
|
|
1092
|
-
}
|
|
1093
|
-
async setPlaybackRate(e) {
|
|
1094
|
-
await this.player.setPlaybackRate(e);
|
|
1095
|
-
}
|
|
1096
|
-
async getDuration() {
|
|
1097
|
-
return this.player.getDuration();
|
|
1098
|
-
}
|
|
1099
|
-
async getCurrentTime() {
|
|
1100
|
-
return this.player.getCurrentTime();
|
|
1101
|
-
}
|
|
1102
|
-
async getVolume() {
|
|
1103
|
-
return this.player.getVolume();
|
|
1104
|
-
}
|
|
1105
|
-
async getMuted() {
|
|
1106
|
-
return await this.player.getMuted();
|
|
1107
|
-
}
|
|
1108
|
-
async getPlaybackRate() {
|
|
1109
|
-
return this.player.getPlaybackRate();
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
var j = /* @__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))(j || {});
|
|
1113
|
-
class Ne extends v {
|
|
1114
|
-
previousTime;
|
|
1115
|
-
timeUpdateIntervalId;
|
|
1116
|
-
clearTimeUpdateInterval() {
|
|
1117
|
-
this.logger.log(
|
|
1118
|
-
s.Debug,
|
|
1119
|
-
"clearTimeUpdateInterval",
|
|
1120
|
-
this.timeUpdateIntervalId
|
|
1121
|
-
), window.clearInterval(this.timeUpdateIntervalId), this.timeUpdateIntervalId = void 0;
|
|
1122
|
-
}
|
|
1123
|
-
invokeTimeUpdate(e) {
|
|
1124
|
-
const t = e.getCurrentTime();
|
|
1125
|
-
if (t === this.previousTime) return;
|
|
1126
|
-
const r = e.getDuration();
|
|
1127
|
-
this.options?.onTimeUpdate?.({
|
|
1128
|
-
duration: r,
|
|
1129
|
-
percent: t / r,
|
|
1130
|
-
seconds: t
|
|
1131
|
-
}), this.previousTime = t;
|
|
1132
|
-
}
|
|
1133
|
-
setTimeUpdateInterval() {
|
|
1134
|
-
this.logger.log(s.Debug, "setTimeUpdateInterval"), this.clearTimeUpdateInterval(), this.timeUpdateIntervalId = window.setInterval(
|
|
1135
|
-
() => this.invokeTimeUpdate(this.player),
|
|
1136
|
-
250
|
|
1137
|
-
), this.logger.log(
|
|
1138
|
-
s.Debug,
|
|
1139
|
-
"timeUpdateIntervalId",
|
|
1140
|
-
this.timeUpdateIntervalId
|
|
1141
|
-
), this.invokeTimeUpdate(this.player);
|
|
1142
|
-
}
|
|
1143
|
-
attach(e) {
|
|
1144
|
-
return new Promise((t, r) => {
|
|
1145
|
-
this.player.addEventListener("onReady", async () => {
|
|
1146
|
-
this.player.addEventListener(
|
|
1147
|
-
"onError",
|
|
1148
|
-
(i) => this.options?.onError?.(i.data)
|
|
1149
|
-
), this.player.addEventListener(
|
|
1150
|
-
"onStateChange",
|
|
1151
|
-
(i) => {
|
|
1152
|
-
switch (this.logger.log(
|
|
1153
|
-
s.Debug,
|
|
1154
|
-
`state changed: ${j[i.data]}`
|
|
1155
|
-
), i.data) {
|
|
1156
|
-
case YT.PlayerState.CUED:
|
|
1157
|
-
this.options?.onLoaded?.({ id: e });
|
|
1158
|
-
break;
|
|
1159
|
-
case YT.PlayerState.PLAYING:
|
|
1160
|
-
this.options?.onPlay?.(), this.setTimeUpdateInterval();
|
|
1161
|
-
break;
|
|
1162
|
-
case YT.PlayerState.PAUSED:
|
|
1163
|
-
this.options?.onPause?.(), this.clearTimeUpdateInterval();
|
|
1164
|
-
break;
|
|
1165
|
-
case YT.PlayerState.ENDED:
|
|
1166
|
-
this.options?.onEnded?.(), this.clearTimeUpdateInterval();
|
|
1167
|
-
break;
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
), await this.loadVideo(e), t();
|
|
1171
|
-
});
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
|
-
async detach() {
|
|
1175
|
-
this.clearTimeUpdateInterval();
|
|
1176
|
-
}
|
|
1177
|
-
async loadVideo(e) {
|
|
1178
|
-
this.previousTime = void 0, this.player.cueVideoById(e);
|
|
1179
|
-
}
|
|
1180
|
-
async play() {
|
|
1181
|
-
this.player.playVideo();
|
|
1182
|
-
}
|
|
1183
|
-
async pause() {
|
|
1184
|
-
this.player.pauseVideo();
|
|
1185
|
-
}
|
|
1186
|
-
async setCurrentTime(e) {
|
|
1187
|
-
this.player.seekTo(e), this.invokeTimeUpdate(this.player);
|
|
1188
|
-
}
|
|
1189
|
-
async setVolume(e) {
|
|
1190
|
-
this.player.setVolume(e * 100);
|
|
1191
|
-
}
|
|
1192
|
-
async setMuted(e) {
|
|
1193
|
-
e ? this.player.mute() : this.player.unMute();
|
|
1194
|
-
}
|
|
1195
|
-
async setPlaybackRate(e) {
|
|
1196
|
-
this.player.setPlaybackRate(e);
|
|
1197
|
-
}
|
|
1198
|
-
async getDuration() {
|
|
1199
|
-
return this.player.getDuration();
|
|
1200
|
-
}
|
|
1201
|
-
async getCurrentTime() {
|
|
1202
|
-
return this.player.getCurrentTime();
|
|
1203
|
-
}
|
|
1204
|
-
async getVolume() {
|
|
1205
|
-
return this.player.getVolume() / 100;
|
|
1206
|
-
}
|
|
1207
|
-
async getMuted() {
|
|
1208
|
-
return this.player.isMuted();
|
|
1209
|
-
}
|
|
1210
|
-
async getPlaybackRate() {
|
|
1211
|
-
return this.player.getPlaybackRate();
|
|
1212
|
-
}
|
|
279
|
+
function V() {
|
|
280
|
+
customElements.define("nostalgic-diva", B);
|
|
1213
281
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/controllers/AudioPlayerController.ts
|
|
284
|
+
var H = class extends i {
|
|
285
|
+
async attach() {
|
|
286
|
+
this.player.onerror = (e) => this.options?.onError?.(e), this.player.onloadeddata = () => this.options?.onLoaded?.({ id: this.player.src }), this.player.onplay = () => this.options?.onPlay?.(), this.player.onpause = () => this.options?.onPause?.(), this.player.onended = () => this.options?.onEnded?.(), this.player.ontimeupdate = () => {
|
|
287
|
+
this.options?.onTimeUpdate?.({
|
|
288
|
+
duration: this.player.duration,
|
|
289
|
+
percent: this.player.currentTime / this.player.duration,
|
|
290
|
+
seconds: this.player.currentTime
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
async detach() {
|
|
295
|
+
this.player.onerror = null, this.player.onloadeddata = null, this.player.onplay = null, this.player.onpause = null, this.player.onended = null, this.player.ontimeupdate = null;
|
|
296
|
+
}
|
|
297
|
+
async loadVideo(e) {
|
|
298
|
+
this.player.src = e;
|
|
299
|
+
}
|
|
300
|
+
async play() {
|
|
301
|
+
await this.player.play();
|
|
302
|
+
}
|
|
303
|
+
async pause() {
|
|
304
|
+
this.player.pause();
|
|
305
|
+
}
|
|
306
|
+
async setCurrentTime(e) {
|
|
307
|
+
this.player.currentTime = e;
|
|
308
|
+
}
|
|
309
|
+
async setVolume(e) {
|
|
310
|
+
this.player.volume = e;
|
|
311
|
+
}
|
|
312
|
+
async setMuted(e) {
|
|
313
|
+
this.player.muted = e;
|
|
314
|
+
}
|
|
315
|
+
async setPlaybackRate(e) {
|
|
316
|
+
this.player.playbackRate = e;
|
|
317
|
+
}
|
|
318
|
+
async getDuration() {
|
|
319
|
+
return this.player.duration;
|
|
320
|
+
}
|
|
321
|
+
async getCurrentTime() {
|
|
322
|
+
return this.player.currentTime;
|
|
323
|
+
}
|
|
324
|
+
async getVolume() {
|
|
325
|
+
return this.player.volume;
|
|
326
|
+
}
|
|
327
|
+
async getMuted() {
|
|
328
|
+
return this.player.muted;
|
|
329
|
+
}
|
|
330
|
+
async getPlaybackRate() {
|
|
331
|
+
return this.player.playbackRate;
|
|
332
|
+
}
|
|
333
|
+
}, U = [
|
|
334
|
+
"apiready",
|
|
335
|
+
"seeked",
|
|
336
|
+
"video_end",
|
|
337
|
+
"durationchange",
|
|
338
|
+
"pause",
|
|
339
|
+
"playing",
|
|
340
|
+
"error"
|
|
341
|
+
], W = class extends i {
|
|
342
|
+
handlePlayerEvents = (e) => {
|
|
343
|
+
switch (e.type) {
|
|
344
|
+
case "apiready":
|
|
345
|
+
this.options?.onLoaded?.({ id: this.player.video.videoId });
|
|
346
|
+
break;
|
|
347
|
+
case "seeked":
|
|
348
|
+
this.options?.onTimeUpdate?.({
|
|
349
|
+
duration: this.player.duration,
|
|
350
|
+
percent: this.player.currentTime / this.player.duration,
|
|
351
|
+
seconds: this.player.currentTime
|
|
352
|
+
});
|
|
353
|
+
break;
|
|
354
|
+
case "video_end":
|
|
355
|
+
this.options?.onEnded?.();
|
|
356
|
+
break;
|
|
357
|
+
case "durationchange": break;
|
|
358
|
+
case "pause":
|
|
359
|
+
this.options?.onPause?.();
|
|
360
|
+
break;
|
|
361
|
+
case "playing":
|
|
362
|
+
this.options?.onPlay?.();
|
|
363
|
+
break;
|
|
364
|
+
case "error":
|
|
365
|
+
this.options?.onError?.(e);
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
async attach(e) {
|
|
370
|
+
for (let e of U) this.player.addEventListener(e, this.handlePlayerEvents);
|
|
371
|
+
}
|
|
372
|
+
async detach() {
|
|
373
|
+
for (let e of U) this.player.removeEventListener(e, this.handlePlayerEvents);
|
|
374
|
+
}
|
|
375
|
+
async loadVideo(e) {
|
|
376
|
+
this.player.load(e);
|
|
377
|
+
}
|
|
378
|
+
async play() {
|
|
379
|
+
this.player.play();
|
|
380
|
+
}
|
|
381
|
+
async pause() {
|
|
382
|
+
this.player.pause();
|
|
383
|
+
}
|
|
384
|
+
async setCurrentTime(e) {
|
|
385
|
+
this.player.seek(e);
|
|
386
|
+
}
|
|
387
|
+
async setVolume(e) {
|
|
388
|
+
this.player.setVolume(e);
|
|
389
|
+
}
|
|
390
|
+
async setMuted(e) {
|
|
391
|
+
this.player.setMuted(e);
|
|
392
|
+
}
|
|
393
|
+
setPlaybackRate = void 0;
|
|
394
|
+
async getDuration() {
|
|
395
|
+
return this.player.duration;
|
|
396
|
+
}
|
|
397
|
+
async getCurrentTime() {
|
|
398
|
+
return this.player.currentTime;
|
|
399
|
+
}
|
|
400
|
+
async getVolume() {
|
|
401
|
+
return this.player.volume;
|
|
402
|
+
}
|
|
403
|
+
async getMuted() {
|
|
404
|
+
return this.player.muted;
|
|
405
|
+
}
|
|
406
|
+
getPlaybackRate = void 0;
|
|
407
|
+
}, G = /* @__PURE__ */ function(e) {
|
|
408
|
+
return e[e.Play = 2] = "Play", e[e.Pause = 3] = "Pause", e[e.End = 4] = "End", e;
|
|
409
|
+
}(G || {}), K = class t extends i {
|
|
410
|
+
static origin = "https://embed.nicovideo.jp";
|
|
411
|
+
duration = 0;
|
|
412
|
+
currentTime = 0;
|
|
413
|
+
volume = 0;
|
|
414
|
+
muted = !1;
|
|
415
|
+
handleMessage = (n) => {
|
|
416
|
+
if (n.origin !== t.origin) return;
|
|
417
|
+
let r = n.data;
|
|
418
|
+
switch (r.eventName) {
|
|
419
|
+
case "playerStatusChange":
|
|
420
|
+
this.logger.log(e.Debug, `player status changed: ${G[r.data.playerStatus] ?? r.data.playerStatus}`);
|
|
421
|
+
break;
|
|
422
|
+
case "statusChange":
|
|
423
|
+
switch (this.logger.log(e.Debug, `status changed: ${G[r.data.playerStatus] ?? r.data.playerStatus}`), r.data.playerStatus) {
|
|
424
|
+
case 2:
|
|
425
|
+
this.options?.onPlay?.();
|
|
426
|
+
break;
|
|
427
|
+
case 3:
|
|
428
|
+
this.options?.onPause?.();
|
|
429
|
+
break;
|
|
430
|
+
case 4:
|
|
431
|
+
this.options?.onEnded?.();
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
435
|
+
case "playerMetadataChange":
|
|
436
|
+
r.data.duration !== void 0 && (this.duration = r.data.duration / 1e3), this.currentTime = r.data.currentTime === void 0 ? 0 : r.data.currentTime / 1e3, this.volume = r.data.volume, this.muted = r.data.muted, this.options?.onTimeUpdate?.({
|
|
437
|
+
duration: this.duration,
|
|
438
|
+
percent: this.currentTime !== 0 && this.duration !== 0 ? this.currentTime / this.duration : 0,
|
|
439
|
+
seconds: this.currentTime
|
|
440
|
+
});
|
|
441
|
+
break;
|
|
442
|
+
case "loadComplete":
|
|
443
|
+
this.logger.log(e.Debug, "load completed"), this.duration = r.data.videoInfo.lengthInSeconds, this.options?.onLoaded?.({ id: r.data.videoInfo.watchId });
|
|
444
|
+
break;
|
|
445
|
+
case "error":
|
|
446
|
+
this.options?.onError?.(r);
|
|
447
|
+
break;
|
|
448
|
+
case "player-error:video:play":
|
|
449
|
+
case "player-error:video:seek":
|
|
450
|
+
this.options?.onError?.(r);
|
|
451
|
+
break;
|
|
452
|
+
default:
|
|
453
|
+
this.logger.log(e.Debug, "message", r.eventName, r.data);
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
async attach() {
|
|
458
|
+
window.addEventListener("message", this.handleMessage);
|
|
459
|
+
}
|
|
460
|
+
async detach() {
|
|
461
|
+
window.removeEventListener("message", this.handleMessage);
|
|
462
|
+
}
|
|
463
|
+
async loadVideo(e) {
|
|
464
|
+
return new Promise((t, n) => {
|
|
465
|
+
this.duration = 0, this.currentTime = 0, this.volume = 0, this.muted = !1, this.player.onload = () => {
|
|
466
|
+
this.player.onload = null, t();
|
|
467
|
+
}, this.player.src = `https://embed.nicovideo.jp/watch/${e}?jsapi=1&playerId=1`;
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
postMessage(e) {
|
|
471
|
+
this.player.contentWindow?.postMessage({
|
|
472
|
+
...e,
|
|
473
|
+
playerId: "1",
|
|
474
|
+
sourceConnectorType: 1
|
|
475
|
+
}, t.origin);
|
|
476
|
+
}
|
|
477
|
+
async play() {
|
|
478
|
+
this.postMessage({ eventName: "play" });
|
|
479
|
+
}
|
|
480
|
+
async pause() {
|
|
481
|
+
this.postMessage({ eventName: "pause" });
|
|
482
|
+
}
|
|
483
|
+
async setCurrentTime(e) {
|
|
484
|
+
this.postMessage({
|
|
485
|
+
eventName: "seek",
|
|
486
|
+
data: { time: e * 1e3 }
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
async setVolume(e) {
|
|
490
|
+
this.postMessage({
|
|
491
|
+
eventName: "volumeChange",
|
|
492
|
+
data: { volume: e }
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
async setMuted(e) {
|
|
496
|
+
this.postMessage({
|
|
497
|
+
eventName: "mute",
|
|
498
|
+
data: { mute: e }
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
setPlaybackRate = void 0;
|
|
502
|
+
async getDuration() {
|
|
503
|
+
return this.duration;
|
|
504
|
+
}
|
|
505
|
+
async getCurrentTime() {
|
|
506
|
+
return this.currentTime;
|
|
507
|
+
}
|
|
508
|
+
async getVolume() {
|
|
509
|
+
return this.volume;
|
|
510
|
+
}
|
|
511
|
+
async getMuted() {
|
|
512
|
+
return this.muted;
|
|
513
|
+
}
|
|
514
|
+
getPlaybackRate = void 0;
|
|
515
|
+
}, q = class e extends i {
|
|
516
|
+
getDurationCore() {
|
|
517
|
+
return new Promise((e, t) => {
|
|
518
|
+
this.player.getDuration(e);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
attach(e) {
|
|
522
|
+
return new Promise((t, n) => {
|
|
523
|
+
this.player.bind(SC.Widget.Events.READY, () => {
|
|
524
|
+
this.player.bind(SC.Widget.Events.PLAY_PROGRESS, async (e) => {
|
|
525
|
+
let t = await this.getDurationCore();
|
|
526
|
+
this.options?.onTimeUpdate?.({
|
|
527
|
+
duration: t / 1e3,
|
|
528
|
+
percent: e.currentPosition / t,
|
|
529
|
+
seconds: e.currentPosition / 1e3
|
|
530
|
+
});
|
|
531
|
+
}), this.player.bind(SC.Widget.Events.ERROR, (e) => this.options?.onError?.(e)), this.player.bind(SC.Widget.Events.PLAY, () => this.options?.onPlay?.()), this.player.bind(SC.Widget.Events.PAUSE, () => this.options?.onPause?.()), this.player.bind(SC.Widget.Events.FINISH, () => this.options?.onEnded?.()), this.options?.onLoaded?.({ id: e }), t();
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
async detach() {
|
|
536
|
+
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);
|
|
537
|
+
}
|
|
538
|
+
static playerLoadAsync(e, t, n) {
|
|
539
|
+
return new Promise((r, i) => {
|
|
540
|
+
e.load(t, {
|
|
541
|
+
...n,
|
|
542
|
+
callback: r
|
|
543
|
+
});
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
async loadVideo(t) {
|
|
547
|
+
await e.playerLoadAsync(this.player, t, { auto_play: !0 }), this.options?.onLoaded?.({ id: t });
|
|
548
|
+
}
|
|
549
|
+
async play() {
|
|
550
|
+
this.player.play();
|
|
551
|
+
}
|
|
552
|
+
async pause() {
|
|
553
|
+
this.player.pause();
|
|
554
|
+
}
|
|
555
|
+
async setCurrentTime(e) {
|
|
556
|
+
this.player.seekTo(e * 1e3);
|
|
557
|
+
}
|
|
558
|
+
async setVolume(e) {
|
|
559
|
+
this.player.setVolume(e * 100);
|
|
560
|
+
}
|
|
561
|
+
setMuted = void 0;
|
|
562
|
+
setPlaybackRate = void 0;
|
|
563
|
+
async getDuration() {
|
|
564
|
+
return await this.getDurationCore() / 1e3;
|
|
565
|
+
}
|
|
566
|
+
getCurrentTimeCore() {
|
|
567
|
+
return new Promise((e, t) => {
|
|
568
|
+
this.player.getPosition(e);
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
async getCurrentTime() {
|
|
572
|
+
return await this.getCurrentTimeCore() / 1e3;
|
|
573
|
+
}
|
|
574
|
+
getVolumeCore() {
|
|
575
|
+
return new Promise((e, t) => {
|
|
576
|
+
this.player.getVolume(e);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
async getVolume() {
|
|
580
|
+
return await this.getVolumeCore() / 100;
|
|
581
|
+
}
|
|
582
|
+
getMuted = void 0;
|
|
583
|
+
getPlaybackRate = void 0;
|
|
584
|
+
}, J = class extends i {
|
|
585
|
+
handleReady = () => {
|
|
586
|
+
this.options?.onLoaded?.({ id: this.player.getVideo() });
|
|
587
|
+
};
|
|
588
|
+
handlePlay = () => {
|
|
589
|
+
this.options?.onPlay?.();
|
|
590
|
+
};
|
|
591
|
+
handlePause = () => {
|
|
592
|
+
this.options?.onPause?.();
|
|
593
|
+
};
|
|
594
|
+
handleEnded = () => {
|
|
595
|
+
this.options?.onEnded?.();
|
|
596
|
+
};
|
|
597
|
+
handleSeek = () => {
|
|
598
|
+
this.options?.onTimeUpdate?.({
|
|
599
|
+
duration: 0,
|
|
600
|
+
percent: 0,
|
|
601
|
+
seconds: 0
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
async attach(e) {
|
|
605
|
+
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);
|
|
606
|
+
}
|
|
607
|
+
async detach() {}
|
|
608
|
+
async loadVideo(e) {
|
|
609
|
+
this.player.setVideo(e, 0);
|
|
610
|
+
}
|
|
611
|
+
async play() {
|
|
612
|
+
this.player.play();
|
|
613
|
+
}
|
|
614
|
+
async pause() {
|
|
615
|
+
this.player.pause();
|
|
616
|
+
}
|
|
617
|
+
async setCurrentTime(e) {
|
|
618
|
+
this.player.seek(e);
|
|
619
|
+
}
|
|
620
|
+
async setVolume(e) {
|
|
621
|
+
this.player.setVolume(e);
|
|
622
|
+
}
|
|
623
|
+
async setMuted(e) {
|
|
624
|
+
this.player.setMuted(e);
|
|
625
|
+
}
|
|
626
|
+
setPlaybackRate = void 0;
|
|
627
|
+
async getDuration() {
|
|
628
|
+
return this.player.getDuration();
|
|
629
|
+
}
|
|
630
|
+
async getCurrentTime() {
|
|
631
|
+
return this.player.getCurrentTime();
|
|
632
|
+
}
|
|
633
|
+
async getVolume() {
|
|
634
|
+
return this.player.getVolume();
|
|
635
|
+
}
|
|
636
|
+
async getMuted() {
|
|
637
|
+
return this.player.getMuted();
|
|
638
|
+
}
|
|
639
|
+
getPlaybackRate = void 0;
|
|
640
|
+
}, Y = class extends i {
|
|
641
|
+
async attach() {
|
|
642
|
+
await this.player.ready(), this.player.on("error", (e) => this.options?.onError?.(e)), this.player.on("loaded", (e) => this.options?.onLoaded?.({ id: e.id.toString() })), this.player.on("play", () => this.options?.onPlay?.()), this.player.on("pause", () => this.options?.onPause?.()), this.player.on("ended", () => this.options?.onEnded?.()), this.player.on("timeupdate", (e) => {
|
|
643
|
+
this.options?.onTimeUpdate?.({
|
|
644
|
+
duration: e.duration,
|
|
645
|
+
percent: e.percent,
|
|
646
|
+
seconds: e.seconds
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
async detach() {
|
|
651
|
+
this.player.off("error"), this.player.off("loaded"), this.player.off("play"), this.player.off("pause"), this.player.off("ended"), this.player.off("timeupdate");
|
|
652
|
+
}
|
|
653
|
+
async loadVideo(e) {
|
|
654
|
+
await this.player.loadVideo(e);
|
|
655
|
+
}
|
|
656
|
+
async play() {
|
|
657
|
+
await this.player.play();
|
|
658
|
+
}
|
|
659
|
+
async pause() {
|
|
660
|
+
await this.player.pause();
|
|
661
|
+
}
|
|
662
|
+
async setCurrentTime(e) {
|
|
663
|
+
await this.player.setCurrentTime(e);
|
|
664
|
+
}
|
|
665
|
+
async setVolume(e) {
|
|
666
|
+
await this.player.setVolume(e);
|
|
667
|
+
}
|
|
668
|
+
async setMuted(e) {
|
|
669
|
+
await this.player.setMuted(e);
|
|
670
|
+
}
|
|
671
|
+
async setPlaybackRate(e) {
|
|
672
|
+
await this.player.setPlaybackRate(e);
|
|
673
|
+
}
|
|
674
|
+
async getDuration() {
|
|
675
|
+
return this.player.getDuration();
|
|
676
|
+
}
|
|
677
|
+
async getCurrentTime() {
|
|
678
|
+
return this.player.getCurrentTime();
|
|
679
|
+
}
|
|
680
|
+
async getVolume() {
|
|
681
|
+
return this.player.getVolume();
|
|
682
|
+
}
|
|
683
|
+
async getMuted() {
|
|
684
|
+
return await this.player.getMuted();
|
|
685
|
+
}
|
|
686
|
+
async getPlaybackRate() {
|
|
687
|
+
return this.player.getPlaybackRate();
|
|
688
|
+
}
|
|
689
|
+
}, X = /* @__PURE__ */ function(e) {
|
|
690
|
+
return e[e.UNSTARTED = -1] = "UNSTARTED", e[e.ENDED = 0] = "ENDED", e[e.PLAYING = 1] = "PLAYING", e[e.PAUSED = 2] = "PAUSED", e[e.BUFFERING = 3] = "BUFFERING", e[e.CUED = 5] = "CUED", e;
|
|
691
|
+
}(X || {}), Z = class extends i {
|
|
692
|
+
previousTime;
|
|
693
|
+
timeUpdateIntervalId;
|
|
694
|
+
clearTimeUpdateInterval() {
|
|
695
|
+
this.logger.log(e.Debug, "clearTimeUpdateInterval", this.timeUpdateIntervalId), window.clearInterval(this.timeUpdateIntervalId), this.timeUpdateIntervalId = void 0;
|
|
696
|
+
}
|
|
697
|
+
invokeTimeUpdate(e) {
|
|
698
|
+
let t = e.getCurrentTime();
|
|
699
|
+
if (t === this.previousTime) return;
|
|
700
|
+
let n = e.getDuration();
|
|
701
|
+
this.options?.onTimeUpdate?.({
|
|
702
|
+
duration: n,
|
|
703
|
+
percent: t / n,
|
|
704
|
+
seconds: t
|
|
705
|
+
}), this.previousTime = t;
|
|
706
|
+
}
|
|
707
|
+
setTimeUpdateInterval() {
|
|
708
|
+
this.logger.log(e.Debug, "setTimeUpdateInterval"), this.clearTimeUpdateInterval(), this.timeUpdateIntervalId = window.setInterval(() => this.invokeTimeUpdate(this.player), 250), this.logger.log(e.Debug, "timeUpdateIntervalId", this.timeUpdateIntervalId), this.invokeTimeUpdate(this.player);
|
|
709
|
+
}
|
|
710
|
+
attach(t) {
|
|
711
|
+
return new Promise((n, r) => {
|
|
712
|
+
this.player.addEventListener("onReady", async () => {
|
|
713
|
+
this.player.addEventListener("onError", (e) => this.options?.onError?.(e.data)), this.player.addEventListener("onStateChange", (n) => {
|
|
714
|
+
switch (this.logger.log(e.Debug, `state changed: ${X[n.data]}`), n.data) {
|
|
715
|
+
case YT.PlayerState.CUED:
|
|
716
|
+
this.options?.onLoaded?.({ id: t });
|
|
717
|
+
break;
|
|
718
|
+
case YT.PlayerState.PLAYING:
|
|
719
|
+
this.options?.onPlay?.(), this.setTimeUpdateInterval();
|
|
720
|
+
break;
|
|
721
|
+
case YT.PlayerState.PAUSED:
|
|
722
|
+
this.options?.onPause?.(), this.clearTimeUpdateInterval();
|
|
723
|
+
break;
|
|
724
|
+
case YT.PlayerState.ENDED:
|
|
725
|
+
this.options?.onEnded?.(), this.clearTimeUpdateInterval();
|
|
726
|
+
break;
|
|
727
|
+
}
|
|
728
|
+
}), await this.loadVideo(t), n();
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
async detach() {
|
|
733
|
+
this.clearTimeUpdateInterval();
|
|
734
|
+
}
|
|
735
|
+
async loadVideo(e) {
|
|
736
|
+
this.previousTime = void 0, this.player.cueVideoById(e);
|
|
737
|
+
}
|
|
738
|
+
async play() {
|
|
739
|
+
this.player.playVideo();
|
|
740
|
+
}
|
|
741
|
+
async pause() {
|
|
742
|
+
this.player.pauseVideo();
|
|
743
|
+
}
|
|
744
|
+
async setCurrentTime(e) {
|
|
745
|
+
this.player.seekTo(e), this.invokeTimeUpdate(this.player);
|
|
746
|
+
}
|
|
747
|
+
async setVolume(e) {
|
|
748
|
+
this.player.setVolume(e * 100);
|
|
749
|
+
}
|
|
750
|
+
async setMuted(e) {
|
|
751
|
+
e ? this.player.mute() : this.player.unMute();
|
|
752
|
+
}
|
|
753
|
+
async setPlaybackRate(e) {
|
|
754
|
+
this.player.setPlaybackRate(e);
|
|
755
|
+
}
|
|
756
|
+
async getDuration() {
|
|
757
|
+
return this.player.getDuration();
|
|
758
|
+
}
|
|
759
|
+
async getCurrentTime() {
|
|
760
|
+
return this.player.getCurrentTime();
|
|
761
|
+
}
|
|
762
|
+
async getVolume() {
|
|
763
|
+
return this.player.getVolume() / 100;
|
|
764
|
+
}
|
|
765
|
+
async getMuted() {
|
|
766
|
+
return this.player.isMuted();
|
|
767
|
+
}
|
|
768
|
+
async getPlaybackRate() {
|
|
769
|
+
return this.player.getPlaybackRate();
|
|
770
|
+
}
|
|
1237
771
|
};
|
|
1238
|
-
//#
|
|
772
|
+
//#endregion
|
|
773
|
+
export { H as AudioPlayerController, W as DailymotionPlayerController, e as LogLevel, K as NiconicoPlayerController, z as NostalgicDiva, B as NostalgicDivaElement, _ as NostalgicDivaProvider, a as PlayerContainer, n as PlayerController, i as PlayerControllerImpl, q as SoundCloudPlayerController, J as TwitchPlayerController, y as VideoService, Y as VimeoPlayerController, Z as YouTubePlayerController, r as defaultLogger, V as defineNostalgicDiva, F as findVideoService, t as nullPlayerController, I as players, v as useNostalgicDiva, P as videoServices };
|
|
774
|
+
|
|
775
|
+
//# sourceMappingURL=index.es.js.map
|