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