@vidispine/vdt-videojs 23.2.0-pre.1 → 23.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -472
- package/dist/index.js +1915 -343
- package/dist/index.umd.cjs +460 -0
- package/package.json +23 -22
- package/.prettierignore +0 -3
- package/deprecated-app/README.md +0 -21
- package/deprecated-app/index.html +0 -426
- package/deprecated-app/index.js +0 -614
- package/deprecated-app/samples/birds-es.vvt +0 -53
- package/deprecated-app/samples/birds.vvt +0 -53
- package/deprecated-app/tests.js +0 -365
- package/dist/index.es.js +0 -336
- package/dist/index.umd.js +0 -352
- package/rollup.config.js +0 -58
- package/screenshot.png +0 -0
- package/src/constants.js +0 -51
- package/src/externalControls.js +0 -318
- package/src/helpOverlay.js +0 -110
- package/src/helpers.js +0 -39
- package/src/index.js +0 -7
- package/src/index.stories.mdx +0 -52
- package/src/menu.api.stories.mdx +0 -53
- package/src/menu.js +0 -373
- package/src/menu.usage.stories.mdx +0 -78
- package/src/osd.js +0 -105
- package/src/player.api.stories.mdx +0 -114
- package/src/player.js +0 -1029
- package/src/player.scss +0 -667
- package/src/player.usage.stories.mdx +0 -62
- package/src/seekBar.js +0 -904
- package/src/timeCodeDisplay.js +0 -274
- package/src/videoTime.js +0 -66
package/dist/index.js
CHANGED
|
@@ -1,350 +1,1922 @@
|
|
|
1
|
-
|
|
1
|
+
import m from "mousetrap";
|
|
2
|
+
import v from "video.js/dist/alt/video.core.min";
|
|
3
|
+
const D = "@vidispine/vdt-videojs", B = "23.2.0", I = "SEE LICENSE IN LICENSE.md", M = {
|
|
4
|
+
access: "public"
|
|
5
|
+
}, P = "Javascript player based on videojs", O = "https://vidispine.github.io/vdt/?path=/docs/vdt-videojs", R = {
|
|
6
|
+
type: "git",
|
|
7
|
+
url: "https://github.com/vidispine/vdt.git",
|
|
8
|
+
directory: "packages/vdt-videojs"
|
|
9
|
+
}, H = "module", A = "./dist/index.umd.cjs", z = "./dist/index.js", W = "./dist/index.css", _ = {
|
|
10
|
+
".": {
|
|
11
|
+
import: "./dist/index.js",
|
|
12
|
+
require: "./dist/index.umd.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./dist/index.css": "./dist/index.css"
|
|
15
|
+
}, U = [
|
|
16
|
+
"dist"
|
|
17
|
+
], K = {
|
|
18
|
+
build: "yarn vite build",
|
|
19
|
+
"build:watch": "yarn vite build --watch --mode development",
|
|
20
|
+
lint: "eslint . --cache --max-warnings=0 --ext .js,.jsx,.ts,.tsx,.md,.mdx",
|
|
21
|
+
format: "prettier . --check"
|
|
22
|
+
}, X = {
|
|
23
|
+
mousetrap: "^1.6.5",
|
|
24
|
+
"video.js": "^7.21.2"
|
|
25
|
+
}, q = {
|
|
26
|
+
"@vidispine/eslint-config-base": "workspace:*",
|
|
27
|
+
"@vidispine/eslint-config-mdx": "workspace:*",
|
|
28
|
+
"@vidispine/eslint-config-storybook": "workspace:*",
|
|
29
|
+
"@vidispine/prettier-config": "workspace:*",
|
|
30
|
+
eslint: "8.34.0",
|
|
31
|
+
prettier: "2.8.4",
|
|
32
|
+
vite: "4.3.1"
|
|
33
|
+
}, J = [
|
|
34
|
+
"since 2017-06"
|
|
35
|
+
], G = {
|
|
36
|
+
extends: [
|
|
37
|
+
"@vidispine/eslint-config-base",
|
|
38
|
+
"@vidispine/eslint-config-mdx",
|
|
39
|
+
"@vidispine/eslint-config-storybook"
|
|
40
|
+
]
|
|
41
|
+
}, Q = "@vidispine/prettier-config", E = {
|
|
42
|
+
name: D,
|
|
43
|
+
version: B,
|
|
44
|
+
license: I,
|
|
45
|
+
publishConfig: M,
|
|
46
|
+
description: P,
|
|
47
|
+
homepage: O,
|
|
48
|
+
repository: R,
|
|
49
|
+
type: H,
|
|
50
|
+
main: A,
|
|
51
|
+
module: z,
|
|
52
|
+
style: W,
|
|
53
|
+
exports: _,
|
|
54
|
+
files: U,
|
|
55
|
+
scripts: K,
|
|
56
|
+
dependencies: X,
|
|
57
|
+
devDependencies: q,
|
|
58
|
+
browserslist: J,
|
|
59
|
+
eslintConfig: G,
|
|
60
|
+
prettier: Q
|
|
61
|
+
}, V = Object.freeze({
|
|
62
|
+
frameRate: 3e4 / 1001,
|
|
63
|
+
jumpSeconds: 10,
|
|
64
|
+
inactivityTimeout: 1200,
|
|
65
|
+
// hide player controls if user inactive for this duration
|
|
66
|
+
audioInactivityTimeout: 0
|
|
67
|
+
}), b = Object.freeze({
|
|
68
|
+
play: 0,
|
|
69
|
+
pause: 1,
|
|
70
|
+
volchange: 2,
|
|
71
|
+
jumpForward: 3,
|
|
72
|
+
jumpBackward: 4
|
|
73
|
+
}), Y = Object.freeze({
|
|
74
|
+
volume: "volume-setting",
|
|
75
|
+
subLang: "subtitles-language",
|
|
76
|
+
subs: "subtitles-enabled"
|
|
77
|
+
}), p = Object.freeze({
|
|
78
|
+
poster: "has-poster",
|
|
79
|
+
subtitles: "has-subtitles",
|
|
80
|
+
subtitlesActive: "subtitles-active",
|
|
81
|
+
onDark: "on-dark",
|
|
82
|
+
loading: "loading"
|
|
83
|
+
}), g = Object.freeze({
|
|
84
|
+
gray: "#787878",
|
|
85
|
+
light: "rgba(255,255,255,.75)"
|
|
86
|
+
}), Z = Object.freeze({
|
|
87
|
+
name: E.name.split("/")[1],
|
|
88
|
+
vendor: E.name.split("/")[0]
|
|
89
|
+
}), l = Object.freeze({
|
|
90
|
+
defaults: V,
|
|
91
|
+
settings: Y,
|
|
92
|
+
classNames: p,
|
|
93
|
+
colors: g,
|
|
94
|
+
osd: b,
|
|
95
|
+
packageInfo: Z
|
|
96
|
+
});
|
|
97
|
+
function ee(c, e) {
|
|
98
|
+
return c.length > e ? `${c.substring(0, e)}...` : c;
|
|
99
|
+
}
|
|
100
|
+
function w() {
|
|
101
|
+
function c(e) {
|
|
102
|
+
if (typeof e == "object") {
|
|
103
|
+
const t = Object.getOwnPropertyNames(e), s = Object.getPrototypeOf(this);
|
|
104
|
+
t.forEach((o) => {
|
|
105
|
+
const i = Object.getOwnPropertyDescriptor(s, o);
|
|
106
|
+
i && i.set && (this[o] = e[o]);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
this.handleNewProps = c;
|
|
111
|
+
}
|
|
112
|
+
function x(c) {
|
|
113
|
+
const e = document.createElement("div");
|
|
114
|
+
return e.textContent = c, e.innerHTML;
|
|
115
|
+
}
|
|
116
|
+
const a = Object.freeze({
|
|
117
|
+
play: "play-pause",
|
|
118
|
+
start: "start",
|
|
119
|
+
fb: "frame-backward",
|
|
120
|
+
ff: "frame-forward",
|
|
121
|
+
end: "end"
|
|
122
|
+
}), te = [
|
|
123
|
+
// order matters
|
|
124
|
+
a.start,
|
|
125
|
+
a.fb,
|
|
126
|
+
a.play,
|
|
127
|
+
a.ff,
|
|
128
|
+
a.end
|
|
129
|
+
], se = `
|
|
130
|
+
.vdt-external-controls{
|
|
131
|
+
display: flex;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
align-items: center;
|
|
134
|
+
}
|
|
2
135
|
|
|
3
|
-
|
|
136
|
+
.control{
|
|
137
|
+
flex: 1;
|
|
138
|
+
flex-grow: 1;
|
|
139
|
+
height: 100%;
|
|
140
|
+
align-contents: center;
|
|
141
|
+
align-self: center;
|
|
142
|
+
text-align: center;
|
|
143
|
+
vertical-align: middle;
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
user-select: none;
|
|
146
|
+
height: 20px;
|
|
147
|
+
padding-top: 10px;
|
|
148
|
+
padding-bottom: 10px;
|
|
149
|
+
}
|
|
4
150
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
151
|
+
.control .icon{
|
|
152
|
+
display: inline-block;
|
|
153
|
+
height: 20px;
|
|
154
|
+
white-space: nowrap;
|
|
155
|
+
opacity: .9;
|
|
156
|
+
}
|
|
8
157
|
|
|
9
|
-
|
|
158
|
+
.control:hover .icon{ opacity: 1; }
|
|
10
159
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
160
|
+
.control .icon:before{
|
|
161
|
+
opacity: 1;
|
|
162
|
+
flex: 1;
|
|
163
|
+
align-self: center;
|
|
164
|
+
content: " ";
|
|
165
|
+
display: inline-block;
|
|
166
|
+
margin: 0 auto;
|
|
14
167
|
|
|
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
|
-
|
|
168
|
+
/* triangles */
|
|
169
|
+
width: 0;
|
|
170
|
+
height: 0;
|
|
171
|
+
border-style: solid;
|
|
172
|
+
border-width: 16px 0 16px 23px;
|
|
173
|
+
border-color: transparent transparent transparent ${g.gray};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.vdt-external-controls.${p.onDark} .control .icon:before{
|
|
177
|
+
border-color: transparent transparent transparent ${g.light};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* specific buttons */
|
|
181
|
+
|
|
182
|
+
.control.${a.start},
|
|
183
|
+
.control.${a.end}{
|
|
184
|
+
height: 20px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.control.${a.play}{
|
|
188
|
+
height: 30px;
|
|
189
|
+
padding-top: 0px;
|
|
190
|
+
padding-bottom: 0px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.control.${a.play} .icon{
|
|
194
|
+
height: 30px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.control.${a.ff} .icon:before,
|
|
198
|
+
.control.${a.fb} .icon:before,
|
|
199
|
+
.control.${a.end} .icon:before,
|
|
200
|
+
.control.${a.start} .icon:before{
|
|
201
|
+
border-width: 10px 0 10px 16px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.control.${a.fb} .icon,
|
|
205
|
+
.control.${a.start}{
|
|
206
|
+
transform: rotate(180deg);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.control.${a.end} .icon:after,
|
|
210
|
+
.control.${a.start} .icon:after{
|
|
211
|
+
content: " ";
|
|
212
|
+
width: 4px;
|
|
213
|
+
height: 20px;
|
|
214
|
+
display: inline-block;
|
|
215
|
+
background: ${g.gray};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.vdt-external-controls.${p.onDark} .control.${a.end} .icon:after,
|
|
219
|
+
.vdt-external-controls.${p.onDark} .control.${a.start} .icon:after{
|
|
220
|
+
background: ${g.light};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* stateful styles */
|
|
224
|
+
.control.${a.play}.playing .icon:before{
|
|
225
|
+
height: 30px;
|
|
226
|
+
width: 6px;
|
|
227
|
+
border-width: 0px 8px 0px 8px;
|
|
228
|
+
border-color: transparent ${g.gray} transparent ${g.gray};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.vdt-external-controls.${p.onDark} .control.${a.play}.playing .icon:before{
|
|
232
|
+
border-color: transparent ${g.light} transparent ${g.light};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.vdt-external-controls.${p.loading} .control.${a.play}{
|
|
236
|
+
border-color: transparent #f00 transparent #f00;
|
|
237
|
+
}
|
|
238
|
+
`;
|
|
239
|
+
class ie {
|
|
240
|
+
constructor(e) {
|
|
241
|
+
this.props = e, w.apply(this), this.state = {
|
|
242
|
+
playing: !1,
|
|
243
|
+
onDark: !1,
|
|
244
|
+
loading: !1
|
|
245
|
+
}, this.shadowRoot = document.createElement("div"), this.shadowRoot.className = "vdt-external-controls-wrapper", this.container = document.createElement("div"), this.container.className = "vdt-external-controls", this.props.target && (this.props.target.appendChild(this.shadowRoot), this.shadow = this.shadowRoot.attachShadow({ mode: "open" }), this.style = document.createElement("style"), this.style.type = "text/css", this.style.appendChild(document.createTextNode(se)), this.shadow.appendChild(this.style), this.shadow.appendChild(this.container)), this.handleNewProps(e), this.bindEvents(), this.draw();
|
|
246
|
+
}
|
|
247
|
+
draw() {
|
|
248
|
+
this.buttons = {};
|
|
249
|
+
const e = this.props.excludes || [];
|
|
250
|
+
te.forEach((t) => {
|
|
251
|
+
if (e.indexOf(t) < 0) {
|
|
252
|
+
const s = document.createElement("div");
|
|
253
|
+
s.className = `control ${t}`, s.innerHTML = '<span class="icon"></span>', s.onclick = () => {
|
|
254
|
+
this.handlePress(t);
|
|
255
|
+
}, this.buttons[t] = s, this.container.appendChild(s);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/*
|
|
260
|
+
bind to play / pause / stop and other events,
|
|
261
|
+
so that controls reflect the player state
|
|
262
|
+
*/
|
|
263
|
+
bindEvents() {
|
|
264
|
+
if (this.props.player && this.props.player.videojs) {
|
|
265
|
+
const { player: e } = this.props;
|
|
266
|
+
e.videojs.on("play", () => {
|
|
267
|
+
this.playing = !0;
|
|
268
|
+
}), e.videojs.on("pause", () => {
|
|
269
|
+
this.playing = !1;
|
|
270
|
+
}), e.videojs.on("stop", () => {
|
|
271
|
+
this.playing = !1;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
handlePress(e) {
|
|
276
|
+
if (this.props.player) {
|
|
277
|
+
const { player: t } = this.props;
|
|
278
|
+
switch (t.osd && t.osd.disable(), e) {
|
|
279
|
+
case a.start:
|
|
280
|
+
t.toStart();
|
|
281
|
+
break;
|
|
282
|
+
case a.fb:
|
|
283
|
+
t.triggerHotkey("left");
|
|
284
|
+
break;
|
|
285
|
+
case a.play:
|
|
286
|
+
t.triggerHotkey("k");
|
|
287
|
+
break;
|
|
288
|
+
case a.ff:
|
|
289
|
+
t.triggerHotkey("right");
|
|
290
|
+
break;
|
|
291
|
+
case a.end:
|
|
292
|
+
t.toEnd();
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
t.osd && t.osd.enable();
|
|
296
|
+
} else
|
|
297
|
+
switch (e) {
|
|
298
|
+
case a.start:
|
|
299
|
+
this.props.onPrev && this.props.onPrev();
|
|
300
|
+
break;
|
|
301
|
+
case a.fb:
|
|
302
|
+
this.props.onFB && this.props.onFB();
|
|
303
|
+
break;
|
|
304
|
+
case a.play:
|
|
305
|
+
this.playing ? this.props.onPause && this.props.onPause() : this.props.onPlay && this.props.onPlay();
|
|
306
|
+
break;
|
|
307
|
+
case a.ff:
|
|
308
|
+
this.props.onFF && this.props.onFF();
|
|
309
|
+
break;
|
|
310
|
+
case a.end:
|
|
311
|
+
this.props.onNext && this.props.onNext();
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// setters and getters for state
|
|
316
|
+
set playing(e) {
|
|
317
|
+
e ? (this.state.playing = !0, this.buttons[a.play].classList.add("playing")) : (this.state.playing = !1, this.buttons[a.play].classList.remove("playing"));
|
|
318
|
+
}
|
|
319
|
+
get playing() {
|
|
320
|
+
return this.state.playing;
|
|
321
|
+
}
|
|
322
|
+
set onDark(e) {
|
|
323
|
+
e ? (this.state.onDark = !0, this.container.classList.add(p.onDark)) : (this.state.onDark = !1, this.container.classList.remove(p.onDark));
|
|
324
|
+
}
|
|
325
|
+
get onDark() {
|
|
326
|
+
return this.container.classList.contains(p.onDark);
|
|
327
|
+
}
|
|
328
|
+
set loading(e) {
|
|
329
|
+
e ? (this.state.loading = !0, this.container.classList.add(p.loading)) : (this.state.loading = !1, this.container.classList.remove(p.loading));
|
|
330
|
+
}
|
|
331
|
+
get loading() {
|
|
332
|
+
return this.state.loading;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
ie.buttonNames = a;
|
|
336
|
+
class oe {
|
|
337
|
+
constructor(e) {
|
|
338
|
+
this.props = e, this.state = {
|
|
339
|
+
active: this.props.active || !1
|
|
340
|
+
}, this.container = document.createElement("div"), this.container.className = "vdt-help-overlay", this.container.innerHTML = "", this.container.onclick = () => {
|
|
341
|
+
this.hide();
|
|
342
|
+
}, this.props.target && this.props.target.appendChild(this.container), this.draw();
|
|
343
|
+
}
|
|
344
|
+
draw() {
|
|
345
|
+
let e = "";
|
|
346
|
+
const t = [
|
|
347
|
+
["⎵", "Play / Pause"],
|
|
348
|
+
["⇧", "Increase volume "],
|
|
349
|
+
["⇩", "Decrease volume"],
|
|
350
|
+
["⇨", "Step frame forward"],
|
|
351
|
+
["⇦", "Step frame backward"],
|
|
352
|
+
["M", "Mute / Unmute"],
|
|
353
|
+
["J", "Seek 10 seconds backward"],
|
|
354
|
+
["K", "Play / Pause"],
|
|
355
|
+
["L", "Seek 10 seconds forward"],
|
|
356
|
+
["C", "Toggle subtitles"],
|
|
357
|
+
["N", "Toggle settings menu"],
|
|
358
|
+
["H", "Toggle this help overlay"]
|
|
359
|
+
], s = Math.round(t.length / 2), o = [t.slice(0, s), t.slice(s, t.length)];
|
|
360
|
+
for (let i = 0; i < s; i += 1)
|
|
361
|
+
e += `
|
|
362
|
+
<tr>
|
|
363
|
+
<td><div>${o[0][i][0]}</div></td>
|
|
364
|
+
<td>- ${o[0][i][1]}</td>
|
|
365
|
+
|
|
366
|
+
<td>${o[1][i] ? `<div>${o[1][i][0]}</div>` : ""}</td>
|
|
367
|
+
<td>${o[1][i] ? `- ${o[1][i][1]}` : ""}</td>
|
|
368
|
+
</tr>
|
|
369
|
+
`;
|
|
370
|
+
this.container.innerHTML = `
|
|
371
|
+
<table>
|
|
372
|
+
<tbody>
|
|
373
|
+
<tr>
|
|
374
|
+
<td class="vdt-help-contents">
|
|
375
|
+
<table><tbody>${e}</tbody></table>
|
|
376
|
+
</td>
|
|
377
|
+
</tr>
|
|
378
|
+
</tbody>
|
|
379
|
+
</table>
|
|
380
|
+
`;
|
|
381
|
+
}
|
|
382
|
+
show() {
|
|
383
|
+
this.state.active || (this.container.classList.add("active"), this.state.active = !0, m.bind("esc", () => {
|
|
384
|
+
this.hide();
|
|
385
|
+
}), this.props.onToggle && this.props.onToggle(!0));
|
|
386
|
+
}
|
|
387
|
+
hide() {
|
|
388
|
+
this.state.active && (this.container.classList.remove("active"), this.state.active = !1, m.unbind("esc"), this.props.onToggle && this.props.onToggle(!1));
|
|
389
|
+
}
|
|
390
|
+
toggle() {
|
|
391
|
+
this.state.active ? this.hide() : this.show();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const h = Object.freeze({
|
|
395
|
+
className: "vdt-menu",
|
|
396
|
+
menuClassName: "menu",
|
|
397
|
+
subLvlClassName: "sub-level",
|
|
398
|
+
menuItemClassName: "menu-item",
|
|
399
|
+
animationLength: 300,
|
|
400
|
+
defaults: {
|
|
401
|
+
bgColor: "rgba(0,0,0,.8)",
|
|
402
|
+
textColor: "#999",
|
|
403
|
+
textColorDark: "#333",
|
|
404
|
+
textColorLight: "rgba(255,255,255)",
|
|
405
|
+
bgColorLight: "rgba(255,255,255,.2)",
|
|
406
|
+
bgColorSelected: "rgba(255,255,255,.1)"
|
|
407
|
+
}
|
|
408
|
+
}), ne = () => `
|
|
409
|
+
.${h.menuClassName}{
|
|
410
|
+
position: relative;
|
|
411
|
+
height: 100%;
|
|
412
|
+
width: 200%;
|
|
413
|
+
// min-width: 200px;
|
|
414
|
+
right: 0px;
|
|
415
|
+
bottom: 0px;
|
|
416
|
+
background: ${h.defaults.bgColor};
|
|
417
|
+
z-index: 1px;
|
|
418
|
+
transform: translate3d(100%, 0px, 0px);
|
|
419
|
+
transition: all 300ms ease-in-out;
|
|
420
|
+
box-shadow: 0px 0px 30px rgb;
|
|
421
|
+
-webkit-backdrop-filter: blur(10px);
|
|
422
|
+
overflow: hidden;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.${h.menuClassName} .level-1{
|
|
426
|
+
float: left;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.${h.menuClassName} div h3{
|
|
430
|
+
padding: 16px 24px;
|
|
431
|
+
font-size: 12px;
|
|
432
|
+
border-bottom: 1px solid ${h.defaults.bgColorLight}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.${h.menuClassName} .level-2 h3{
|
|
436
|
+
cursor: pointer;
|
|
437
|
+
position: relative;
|
|
438
|
+
}
|
|
439
|
+
.${h.menuClassName} .level-2 h3:before{
|
|
440
|
+
content: '◂';
|
|
441
|
+
margin-left: -12px;
|
|
442
|
+
width: 12px;
|
|
443
|
+
display: inline-block;
|
|
444
|
+
position: absolute;
|
|
445
|
+
margin-top: -1px;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.${h.menuClassName} .level-1,
|
|
449
|
+
.${h.menuClassName} .level-2{
|
|
450
|
+
transform: translate3d(0px, 0px, 0px);
|
|
451
|
+
transition: all 300ms ease-in-out;
|
|
452
|
+
width: 50%;
|
|
453
|
+
height: 100%;
|
|
454
|
+
float: left;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.${h.menuClassName}.sub-level .level-1,
|
|
458
|
+
.${h.menuClassName}.sub-level .level-2{
|
|
459
|
+
transform: translate3d(-100%, 0px, 0px);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.${h.menuClassName} table{
|
|
463
|
+
border-collapse: collapse;
|
|
464
|
+
width: 100%;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.${h.menuClassName}.open{
|
|
468
|
+
transform: translate3d(0px, 0px, 0px);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.${h.menuClassName} tr{
|
|
472
|
+
cursor: pointer;
|
|
473
|
+
height: 40px;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.${h.menuClassName} tr.selected{
|
|
477
|
+
background: ${h.defaults.bgColorSelected};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
.${h.menuClassName} tr td{
|
|
482
|
+
color: white;
|
|
483
|
+
font-size: 15px;
|
|
484
|
+
vertical-align: middle;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
.${h.menuClassName} tr:hover td{
|
|
489
|
+
color: white;
|
|
490
|
+
background: ${h.defaults.bgColorLight};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.${h.menuClassName} tr td.title{
|
|
494
|
+
padding-top: 12px;
|
|
495
|
+
padding-bottom: 12px;
|
|
496
|
+
font-weight: 300;
|
|
497
|
+
font-family: Helvetica, Arial, sans-serif;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.${h.menuClassName} tr td.caret{
|
|
501
|
+
font-size: 12px;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.${h.menuClassName} tr td:first-child{
|
|
505
|
+
padding-left: 24px;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.${h.menuClassName} tr td:last-child{
|
|
509
|
+
padding-right: 16px;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.${h.menuClassName} tr.has-items td:last-child{
|
|
513
|
+
text-align: right;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.${h.menuClassName} tr.has-items td.subtitle{
|
|
517
|
+
font-size: 12px;
|
|
518
|
+
text-align: right;
|
|
519
|
+
color: ${h.defaults.textColorLight};
|
|
520
|
+
}
|
|
521
|
+
`;
|
|
522
|
+
class S {
|
|
523
|
+
constructor(e) {
|
|
524
|
+
this.props = e;
|
|
525
|
+
const t = [
|
|
526
|
+
h.menuItemClassName,
|
|
527
|
+
this.props.items && "has-items",
|
|
528
|
+
this.props.selected && "selected"
|
|
529
|
+
];
|
|
530
|
+
this.container = document.createElement("tr"), this.container.className = t.join(" "), this.props.target && this.props.target.appendChild(this.container), this.container.onclick = (s) => {
|
|
531
|
+
this.props.onClick && this.props.onClick(s);
|
|
532
|
+
}, this.render();
|
|
533
|
+
}
|
|
534
|
+
render() {
|
|
535
|
+
this.props.items ? this.container.innerHTML = `
|
|
536
|
+
<td class="title"></td>
|
|
537
|
+
<td class="subtitle"></td>
|
|
538
|
+
<td class="caret">▷</td>
|
|
539
|
+
` : this.container.innerHTML = `
|
|
540
|
+
<td class="title"></td>
|
|
541
|
+
`;
|
|
542
|
+
const e = this.container.getElementsByClassName("title")[0], t = this.props.items ? this.container.getElementsByClassName("subtitle")[0] : !1;
|
|
543
|
+
e.textContent = this.props.title, t && (t.textContent = this.props.subtitle);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
class re {
|
|
547
|
+
constructor(e) {
|
|
548
|
+
this.props = e, this.container = document.createElement("div"), this.container.className = `${h.className}`, this.state = {
|
|
549
|
+
opened: !1,
|
|
550
|
+
selectedItem: 0,
|
|
551
|
+
items: [],
|
|
552
|
+
subItems: []
|
|
553
|
+
}, this.mount(), this.draw();
|
|
554
|
+
}
|
|
555
|
+
mount() {
|
|
556
|
+
this.props.target && (this.container.style.position = "absolute", this.container.style.bottom = this.container.style.right = "0px", this.container.style.height = "100%", this.container.style.overflow = "hidden", this.container.style.width = "30%", this.container.style.minWidth = "250px", this.container.style.maxWidth = "320px", this.shadow = this.container.attachShadow({ mode: "open" }), this.props.target && this.props.target.appendChild(this.container), this.menuContainer = document.createElement("div"), this.menuContainer.className = "menu", this.shadow.appendChild(this.menuContainer), this.style = document.createElement("style"), this.style.type = "text/css", this.style.innerHTML = ne(), this.shadow.appendChild(this.style));
|
|
557
|
+
}
|
|
558
|
+
draw() {
|
|
559
|
+
const e = document.createElement("div");
|
|
560
|
+
e.className = "level-1", this.mainLevel = document.createElement("table"), e.innerHTML = "<h3>Settings</h3>", e.appendChild(this.mainLevel);
|
|
561
|
+
const t = document.createElement("div");
|
|
562
|
+
t.className = "level-2", this.subLvlTitle = document.createElement("h3"), this.subLvlTitle.onclick = () => {
|
|
563
|
+
this.up();
|
|
564
|
+
}, t.appendChild(this.subLvlTitle), this.secondaryLevel = document.createElement("table"), t.appendChild(this.secondaryLevel), this.menuContainer.appendChild(e), this.menuContainer.appendChild(t), this.props.items.forEach((s) => {
|
|
565
|
+
const o = s.items[s.getActiveIndex(s.items)].title || "", i = new S({
|
|
566
|
+
target: this.mainLevel,
|
|
567
|
+
subtitle: o,
|
|
568
|
+
onClick: () => {
|
|
569
|
+
this.handleSupItemSelected(s);
|
|
570
|
+
},
|
|
571
|
+
...s
|
|
572
|
+
});
|
|
573
|
+
this.state.items.push(i);
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
open() {
|
|
577
|
+
this.render(), this.menuContainer.classList.add("open"), this.props.onOpen && this.props.onOpen(), this.state.opened = !0, this.handleClicksWhenMenuOpened || (this.handleClicksWhenMenuOpened = function(e) {
|
|
578
|
+
this.state.opened && (e.stopPropagation(), this.container.contains(e.target) || this.close());
|
|
579
|
+
}.bind(this)), this.handleClicksWhenMenuOpenedTimeout = setTimeout(() => {
|
|
580
|
+
document.addEventListener("click", this.handleClicksWhenMenuOpened), m.bind("esc", this.close.bind(this));
|
|
581
|
+
}, h.animationLength);
|
|
582
|
+
}
|
|
583
|
+
close() {
|
|
584
|
+
this.menuContainer.classList.remove("open"), this.state.opened = !1, this.handleClicksWhenMenuOpenedTimeout && clearTimeout(this.handleClicksWhenMenuOpenedTimeout), document.removeEventListener("click", this.handleClicksWhenMenuOpened), this.props.onClose && this.props.onClose(), m.unbind("esc");
|
|
585
|
+
}
|
|
586
|
+
toggle() {
|
|
587
|
+
this.state.opened ? this.close() : this.open();
|
|
588
|
+
}
|
|
589
|
+
up() {
|
|
590
|
+
this.menuContainer.classList.remove(h.subLvlClassName), this.render();
|
|
591
|
+
}
|
|
592
|
+
handleSupItemSelected(e) {
|
|
593
|
+
this.subLvlTitle.textContent = e.title, this.renderSubItems(e.items, e.getActiveIndex(e.items)), this.menuContainer.classList.add(h.subLvlClassName);
|
|
594
|
+
}
|
|
595
|
+
renderSubItems(e, t = !1) {
|
|
596
|
+
this.secondaryLevel.innerHTML = "";
|
|
597
|
+
const s = [];
|
|
598
|
+
e.forEach((o, i) => {
|
|
599
|
+
const r = new S({
|
|
600
|
+
target: this.secondaryLevel,
|
|
601
|
+
...o,
|
|
602
|
+
onClick: (n) => {
|
|
603
|
+
this.handleSubItemSelected(n, o);
|
|
604
|
+
},
|
|
605
|
+
selected: i === t
|
|
606
|
+
// mark selected
|
|
607
|
+
});
|
|
608
|
+
s.push(r);
|
|
609
|
+
}), this.state.subItems = s;
|
|
610
|
+
}
|
|
611
|
+
handleSubItemSelected(e, t) {
|
|
612
|
+
this.close(), t.onClick && t.onClick(e, t), this.up();
|
|
613
|
+
}
|
|
614
|
+
get opened() {
|
|
615
|
+
return this.state.opened;
|
|
616
|
+
}
|
|
617
|
+
set opened(e) {
|
|
618
|
+
this.state.opened = e;
|
|
619
|
+
}
|
|
620
|
+
render() {
|
|
621
|
+
this.state.items.forEach((e, t) => {
|
|
622
|
+
const { items: s } = this.props, o = s[t].getActiveIndex(s[t].items), i = s[t].items[o].title;
|
|
623
|
+
e.props.subtitle = i, e.render();
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
class ae {
|
|
628
|
+
constructor(e) {
|
|
629
|
+
this.props = e, this.state = {
|
|
630
|
+
enabled: !0
|
|
631
|
+
}, this.container = document.createElement("div"), this.container.className = "vdt-player-osd", this.container.innerHTML = `
|
|
632
|
+
<table>
|
|
633
|
+
<tbody>
|
|
634
|
+
<td>
|
|
635
|
+
<div class="osd-feedback-icon"></div>
|
|
636
|
+
</td>
|
|
637
|
+
</tbody>
|
|
638
|
+
</table>
|
|
639
|
+
`, this.iconEl = this.container.getElementsByClassName("osd-feedback-icon")[0], this.props.target && this.props.target.appendChild(this.container);
|
|
640
|
+
}
|
|
641
|
+
feedback(e, t = null) {
|
|
642
|
+
if (!this.state.enabled)
|
|
643
|
+
return;
|
|
644
|
+
let s;
|
|
645
|
+
switch (e) {
|
|
646
|
+
case b.pause:
|
|
647
|
+
s = "pause";
|
|
648
|
+
break;
|
|
649
|
+
case b.play:
|
|
650
|
+
s = "play";
|
|
651
|
+
break;
|
|
652
|
+
case b.volchange:
|
|
653
|
+
const o = t.volume;
|
|
654
|
+
let i;
|
|
655
|
+
o === 0 ? i = "null" : o > 0.65 ? i = "high" : o < 0.35 ? i = "low" : i = "mid", s = `volchange ${i}`;
|
|
656
|
+
break;
|
|
657
|
+
case b.jumpForward:
|
|
658
|
+
s = "forward-jump";
|
|
659
|
+
break;
|
|
660
|
+
case b.jumpBackward:
|
|
661
|
+
s = "backward-jump";
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
this.osdTimeout && (this.container.classList.remove("active"), clearTimeout(this.osdTimeout)), this.container.classList.add("active"), this.osdTimeout = setTimeout(() => {
|
|
665
|
+
this.container.classList.remove("active");
|
|
666
|
+
}, 200), this.iconEl.className = `osd-feedback-icon ${s}`;
|
|
667
|
+
}
|
|
668
|
+
disable() {
|
|
669
|
+
this.state.enabled = !1;
|
|
670
|
+
}
|
|
671
|
+
enable() {
|
|
672
|
+
this.state.enabled = !0;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
const d = Object.freeze({
|
|
676
|
+
className: "vdt-seekbar",
|
|
677
|
+
defaults: {
|
|
678
|
+
bgColor: "#fafafa",
|
|
679
|
+
fillColor: "#f00",
|
|
680
|
+
regionColor: "#f6e58d",
|
|
681
|
+
// yellow
|
|
682
|
+
markerWidth: 16,
|
|
683
|
+
regionAccentColor: "#00a8ff",
|
|
684
|
+
transitionTime: 300
|
|
685
|
+
// ms
|
|
686
|
+
},
|
|
687
|
+
markerTypes: {
|
|
688
|
+
in: "in",
|
|
689
|
+
out: "out"
|
|
690
|
+
}
|
|
691
|
+
}), le = (c, e) => `
|
|
692
|
+
.${d.className}{
|
|
693
|
+
user-select: none;
|
|
694
|
+
background: ${g.light};
|
|
695
|
+
height: 6px;
|
|
696
|
+
width: 100%;
|
|
697
|
+
position: relative;
|
|
698
|
+
cursor: pointer;
|
|
699
|
+
z-index: 5;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.${p.onDark}.${d.className}{
|
|
703
|
+
background: ${g.gray};
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.fill, .load-indicator{
|
|
707
|
+
height: 100%;
|
|
708
|
+
display: inline-block;
|
|
709
|
+
position: absolute;
|
|
710
|
+
left: 0px;
|
|
711
|
+
top: 0px;
|
|
712
|
+
background: ${e};
|
|
713
|
+
transition: width ${d.defaults.transitionTime}ms linear;
|
|
714
|
+
z-index: 2;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
.load-indicator{
|
|
718
|
+
background: #e1e1e1;
|
|
719
|
+
z-index: 1;
|
|
720
|
+
opacity: .2;
|
|
721
|
+
transition: none;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.${p.onDark}.${d.className} .load-indicator{
|
|
725
|
+
background: white;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.${d.className}.dragging .fill{
|
|
729
|
+
transition: none;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
.marker, .region{
|
|
734
|
+
position: absolute;
|
|
735
|
+
top: 0px;
|
|
736
|
+
height: 100%;
|
|
737
|
+
background: cyan;
|
|
738
|
+
width: 1px;
|
|
739
|
+
display: inline-block;
|
|
740
|
+
z-index: 4;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
.marker{
|
|
744
|
+
transition: opacity ${d.defaults.transitionTime}ms linear;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
.marker{ display: none; }
|
|
748
|
+
.marker.active{ display: initial; }
|
|
749
|
+
|
|
750
|
+
.marker .handle{
|
|
751
|
+
position: absolute;
|
|
752
|
+
bottom: 10px; right: 0px;
|
|
753
|
+
width: ${d.defaults.markerWidth}px;
|
|
754
|
+
height: 28px;
|
|
755
|
+
background: #999;
|
|
756
|
+
border-radius: 3px;
|
|
757
|
+
cursor: col-resize;
|
|
758
|
+
z-index: 3;
|
|
759
|
+
box-sizing: border-box;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.marker.regional .handle{
|
|
763
|
+
background: ${d.defaults.regionAccentColor};
|
|
764
|
+
box-shadow: -2px 1px 1px rgba(0,0,0,.1);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
.marker.regional.in .handle{
|
|
768
|
+
box-shadow: 2px 1px 1px rgba(0,0,0,.1);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.marker.in .handle{
|
|
772
|
+
border-bottom-left-radius: 40px;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.marker.out .handle{
|
|
776
|
+
left: 1px;
|
|
777
|
+
right: initial;
|
|
778
|
+
border-bottom-right-radius: 20px;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.handle:active{
|
|
782
|
+
background: ${d.defaults.regionColor};
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.region{
|
|
786
|
+
position: absolute;
|
|
787
|
+
width: auto;
|
|
788
|
+
background: ${d.defaults.regionColor};
|
|
789
|
+
opacity: .7;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.region.nav{
|
|
793
|
+
background: transparent;
|
|
794
|
+
opacity: 1;
|
|
795
|
+
border-left: 1px solid cyan;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
.region.nav .bubble,
|
|
799
|
+
.region.nav:after{
|
|
800
|
+
content: " ";
|
|
801
|
+
height: 16px;
|
|
802
|
+
bottom: 10px;
|
|
803
|
+
width: 16px;
|
|
804
|
+
border-radius: 16px;
|
|
805
|
+
background: ${d.defaults.regionAccentColor};
|
|
806
|
+
position: absolute;
|
|
807
|
+
margin-left: -8px;
|
|
808
|
+
transition: transform 200ms ease-out;
|
|
809
|
+
transform: translate3d(0px, 0px, 0px);
|
|
810
|
+
transform-origin: bottom center;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.region.nav .popout{
|
|
814
|
+
width: 160px;
|
|
815
|
+
z-index: 4;
|
|
816
|
+
background: rgba(28, 28, 28, .7);
|
|
817
|
+
color: white;
|
|
818
|
+
font-size: 14px;
|
|
819
|
+
min-height: 100px;
|
|
820
|
+
bottom: 16px;
|
|
821
|
+
left: -80px;
|
|
822
|
+
position: absolute;
|
|
823
|
+
border-radius: 8px;
|
|
824
|
+
-webkit-backdrop-filter: blur(10px);
|
|
825
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
826
|
+
overflow: hidden;
|
|
827
|
+
opacity: 0;
|
|
828
|
+
visibility: hidden;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
.region.nav.right-aligned .popout{
|
|
832
|
+
right: 0px;
|
|
833
|
+
left: initial;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
.region.nav.left-aligned .popout{
|
|
837
|
+
left: -32px;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.region.nav .popout .title{
|
|
841
|
+
padding: 4px 14px;
|
|
842
|
+
text-align: center;
|
|
843
|
+
color: black;
|
|
844
|
+
background: white;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
.region.nav .popout .annotation{
|
|
848
|
+
padding: 8px 12px;
|
|
849
|
+
font-weight: light;
|
|
850
|
+
color: rgba(255,255,255,.9);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
.region.nav:after{
|
|
854
|
+
width: 1px;
|
|
855
|
+
left: 8px;
|
|
856
|
+
height: 10px;
|
|
857
|
+
bottom: 0px;
|
|
858
|
+
background: #00a8ff;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
.region.nav:hover{
|
|
862
|
+
background: rgba(28, 28, 28, .5);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
.region.nav.has-popout:hover .bubble{
|
|
866
|
+
background: rgba(28, 28, 28, .8);
|
|
867
|
+
opacity: 1;
|
|
868
|
+
z-index: 3;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
.region.nav:hover:after,
|
|
872
|
+
.region.nav:hover:before{
|
|
873
|
+
background: rgba(28, 28, 28, .8);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.region.nav:hover .popout{
|
|
877
|
+
opacity: 1;
|
|
878
|
+
visibility: visible;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
.${d.className}.dragging .bubble{
|
|
882
|
+
transform: scale3d(.75,.75,.75);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
.${d.className}.hide-markers .marker{
|
|
886
|
+
opacity: 0;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
`;
|
|
890
|
+
class T {
|
|
891
|
+
constructor(e) {
|
|
892
|
+
Object.assign(this, {
|
|
893
|
+
in: null,
|
|
894
|
+
out: null,
|
|
895
|
+
title: "",
|
|
896
|
+
annotation: "",
|
|
897
|
+
el: null
|
|
898
|
+
// can store a
|
|
899
|
+
}, e);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
class L {
|
|
903
|
+
constructor(e) {
|
|
904
|
+
if (this.props = e, w.apply(this), this.container = document.createElement("div"), this.container.className = `${d.className}-wrapper`, this.state = {
|
|
905
|
+
in: null,
|
|
906
|
+
// in seconds from 0
|
|
907
|
+
out: null,
|
|
908
|
+
markersEnabled: this.props.markersEnabled === void 0 ? !0 : this.props.markersEnabled,
|
|
909
|
+
regions: [],
|
|
910
|
+
// array with regions providing {in: 0, out: 12} and possibly more
|
|
911
|
+
dragging: !1
|
|
912
|
+
}, this.markers = {}, this.props.target) {
|
|
913
|
+
this.shadow = this.container.attachShadow({ mode: "open" }), this.props.target.appendChild(this.container), this.style = document.createElement("style"), this.style.type = "text/css";
|
|
914
|
+
const s = this.props.bgColor ? this.props.bgColor : d.defaults.bgColor, o = this.props.fillColor ? this.props.fillColor : d.defaults.fillColor;
|
|
915
|
+
this.style.innerHTML = le(x(s), x(o)), this.shadow.appendChild(this.style);
|
|
916
|
+
}
|
|
917
|
+
this.bindEvents(), this.draw(), this.bindHotkeys();
|
|
918
|
+
const { player: t } = this.props;
|
|
919
|
+
t && t.videojs.on("loadedmetadata", () => {
|
|
920
|
+
this.handleNewProps(this.props);
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
/*
|
|
924
|
+
Video.js seekbar works a bit differently - it
|
|
925
|
+
sets an interval and checks the playback position
|
|
926
|
+
very frequently, could do it that way -
|
|
927
|
+
then could use requestAnimationFrame and
|
|
928
|
+
get a smoother animation at more expense
|
|
929
|
+
*/
|
|
930
|
+
bindEvents() {
|
|
931
|
+
if (this.props.player) {
|
|
932
|
+
const { player: e } = this.props;
|
|
933
|
+
e.videojs.on("timeupdate", () => {
|
|
934
|
+
const t = e.videojs.currentTime() / e.videojs.duration();
|
|
935
|
+
this.fill.style.width = `${100 * t}%`;
|
|
936
|
+
}), e.videojs.on("progress", () => {
|
|
937
|
+
this.percentLoaded = e.percentLoaded;
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
bindHotkeys() {
|
|
942
|
+
if (this.bindings = [], this.props.player) {
|
|
943
|
+
const { player: e } = this.props;
|
|
944
|
+
this.bindings = [
|
|
945
|
+
{
|
|
946
|
+
key: ["i"],
|
|
947
|
+
method: () => {
|
|
948
|
+
this.markersEnabled && (this.in = e.videojs.currentTime());
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
key: ["o"],
|
|
953
|
+
method: () => {
|
|
954
|
+
this.markersEnabled && (this.out = e.videojs.currentTime());
|
|
955
|
+
}
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
key: ["shift+i"],
|
|
959
|
+
method: () => {
|
|
960
|
+
this.markersEnabled && this.navigateToIn();
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
key: ["shift+o"],
|
|
965
|
+
method: () => {
|
|
966
|
+
this.markersEnabled && this.navigateToOut();
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
];
|
|
970
|
+
}
|
|
971
|
+
if (this.props.player) {
|
|
972
|
+
const { player: e } = this.props;
|
|
973
|
+
m.bind("i", () => {
|
|
974
|
+
this.markersEnabled && (this.in = e.videojs.currentTime());
|
|
975
|
+
}), m.bind("o", () => {
|
|
976
|
+
this.markersEnabled && (this.out = e.videojs.currentTime());
|
|
977
|
+
}), m.bind("shift+i", () => {
|
|
978
|
+
this.markersEnabled && this.navigateToIn();
|
|
979
|
+
}), m.bind("shift+o", () => {
|
|
980
|
+
this.markersEnabled && this.navigateToOut();
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
this.bindings.forEach((e) => {
|
|
984
|
+
m.bind(e.key, (t) => {
|
|
985
|
+
e.method(t);
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
unbindHotKeys() {
|
|
990
|
+
this.bindings && this.bindings.forEach((e) => {
|
|
991
|
+
m.unbind(e.key);
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
handleSeek(e) {
|
|
995
|
+
if (this.props.player) {
|
|
996
|
+
const { player: t } = this.props;
|
|
997
|
+
if (this.state.regions) {
|
|
998
|
+
let i = !1, r = !1;
|
|
999
|
+
if (this.state.regions.forEach((n) => {
|
|
1000
|
+
n.el.contains(e.target) && (this.props.onRegionClick ? (r = this.props.onRegionClick(n), r || t.seekTo(n.in)) : t.seekTo(n.in), i = !0);
|
|
1001
|
+
}), i)
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
const o = (e.clientX - this.bar.getBoundingClientRect().left) / this.bar.offsetWidth * t.videojs.duration();
|
|
1005
|
+
t.seekTo(o);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
handleSeekDrag(e) {
|
|
1009
|
+
const t = this.bar.getBoundingClientRect().left, s = this.bar.getBoundingClientRect().width, o = this.props.player.videojs.duration();
|
|
1010
|
+
let i;
|
|
1011
|
+
const r = (u) => {
|
|
1012
|
+
i = u.clientX - t;
|
|
1013
|
+
const k = Math.abs(e.clientX - u.clientX);
|
|
1014
|
+
if (i >= 0 && i < s && k > 1) {
|
|
1015
|
+
this.dragging = !0;
|
|
1016
|
+
const C = parseFloat(i) / s * o;
|
|
1017
|
+
this.props.player.videojs.currentTime(C);
|
|
1018
|
+
}
|
|
1019
|
+
u.preventDefault();
|
|
1020
|
+
}, n = (u) => {
|
|
1021
|
+
this.dragging = !1, document.removeEventListener("mousemove", r, !1), document.removeEventListener("mouseup", n, !1);
|
|
1022
|
+
const f = parseFloat(i) / s * o;
|
|
1023
|
+
this.props.player.videojs.currentTime(f), u.stopPropagation();
|
|
1024
|
+
};
|
|
1025
|
+
document.addEventListener("mousemove", r, !1), document.addEventListener("mouseup", n, !1);
|
|
1026
|
+
}
|
|
1027
|
+
draw() {
|
|
1028
|
+
this.bar = document.createElement("div"), this.bar.className = d.className, this.bar.onclick = (e) => {
|
|
1029
|
+
!e.target.classList.contains("marker") && !e.target.classList.contains("handle") && this.handleSeek(e);
|
|
1030
|
+
}, this.bar.addEventListener(
|
|
1031
|
+
"mousedown",
|
|
1032
|
+
(e) => {
|
|
1033
|
+
e.preventDefault(), this.dragging || this.handleSeekDrag(e);
|
|
1034
|
+
},
|
|
1035
|
+
!1
|
|
1036
|
+
), this.fill = document.createElement("div"), this.fill.className = "fill", this.loadIndicator = document.createElement("div"), this.loadIndicator.className = "load-indicator", this.region = document.createElement("div"), this.region.className = "region", this.bar.appendChild(this.fill), this.bar.appendChild(this.loadIndicator), this.bar.appendChild(this.region), this.shadow.appendChild(this.bar), this.drawMarkers();
|
|
1037
|
+
}
|
|
1038
|
+
drawMarkers() {
|
|
1039
|
+
if (this.markersEnabled) {
|
|
1040
|
+
const e = this.markers[d.markerTypes.in] = document.createElement("div"), t = this.markers[d.markerTypes.out] = document.createElement("div");
|
|
1041
|
+
e.className = `marker ${d.markerTypes.in}`, t.className = `marker ${d.markerTypes.out}`;
|
|
1042
|
+
const s = document.createElement("div"), o = document.createElement("div");
|
|
1043
|
+
s.className = o.className = "handle", s.addEventListener(
|
|
1044
|
+
"mousedown",
|
|
1045
|
+
(i) => {
|
|
1046
|
+
i.preventDefault(), i.stopPropagation(), this.handleMarkerDrag(e, d.markerTypes.in, i);
|
|
1047
|
+
},
|
|
1048
|
+
!1
|
|
1049
|
+
), o.addEventListener(
|
|
1050
|
+
"mousedown",
|
|
1051
|
+
(i) => {
|
|
1052
|
+
i.preventDefault(), i.stopPropagation(), this.handleMarkerDrag(t, d.markerTypes.out, i);
|
|
1053
|
+
},
|
|
1054
|
+
!1
|
|
1055
|
+
), e.appendChild(s), t.appendChild(o), this.bar.appendChild(e), this.bar.appendChild(t);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
updateMarkers(e) {
|
|
1059
|
+
this.markers[e.type].style.left = `${e.value * 100}%`, this.markers[e.type].classList.add("active"), this.state.regions && ([].length > 0 ? this.markers[e.type].classList.add("regional") : this.markers[e.type].classList.remove("regional")), this.drawInAndOutRegion();
|
|
1060
|
+
}
|
|
1061
|
+
drawInAndOutRegion() {
|
|
1062
|
+
this.state.in !== null && this.state.out !== null && (this.region.style.left = this.markers[d.markerTypes.in].style.left, this.region.style.right = `${100 - parseFloat(this.markers[d.markerTypes.out].style.left.replace("%", ""))}%`);
|
|
1063
|
+
}
|
|
1064
|
+
/*
|
|
1065
|
+
TODO - handle touch events,
|
|
1066
|
+
but find out if there is a mobile use
|
|
1067
|
+
case before that
|
|
1068
|
+
*/
|
|
1069
|
+
handleMarkerDrag(e, t, s) {
|
|
1070
|
+
const o = this.bar.getBoundingClientRect().left, i = this.bar.getBoundingClientRect().width, r = this.props.player.videojs.duration();
|
|
1071
|
+
let n = !1;
|
|
1072
|
+
const u = (f) => {
|
|
1073
|
+
const C = Math.abs(s.clientX - f.clientX), y = t === d.markerTypes.in ? d.defaults.markerWidth / 2 : -(d.defaults.markerWidth / 2), j = f.clientX - o + y;
|
|
1074
|
+
if (j >= 0 && j < i && C > 1) {
|
|
1075
|
+
n = this.dragging = !0, e.style.left = `${j}px`, e.classList.add("active");
|
|
1076
|
+
const F = parseFloat(e.getBoundingClientRect().left - o) / i * r;
|
|
1077
|
+
this.props.player.videojs.currentTime(F);
|
|
1078
|
+
}
|
|
1079
|
+
f.preventDefault();
|
|
1080
|
+
}, k = (f) => {
|
|
1081
|
+
this.dragging = !1, document.removeEventListener("mousemove", u, !1), document.removeEventListener("mouseup", k, !1);
|
|
1082
|
+
const y = parseFloat(e.getBoundingClientRect().left - o) / i * r;
|
|
1083
|
+
this[t] = y, this.props.player.videojs.currentTime(y), n || (t === d.markerTypes.in ? this.navigateToIn() : this.navigateToOut()), this.props.onDragFinish && this.props.onDragFinish({ type: t, seconds: y }), f.stopPropagation();
|
|
1084
|
+
};
|
|
1085
|
+
document.addEventListener("mousemove", u, !1), document.addEventListener("mouseup", k, !1);
|
|
1086
|
+
}
|
|
1087
|
+
/*
|
|
1088
|
+
hide dead markers (for state parity) or ones that
|
|
1089
|
+
make no sense (like out point before in point)
|
|
1090
|
+
*/
|
|
1091
|
+
cleanupMarkers() {
|
|
1092
|
+
let e = !1;
|
|
1093
|
+
this.state.in === null && (this.markers[d.markerTypes.in].classList.remove("active"), e = !0), this.state.out === null && (this.markers[d.markerTypes.out].classList.remove("active"), e = !0), e && (this.region.style.left = "initial", this.region.style.right = "initial");
|
|
1094
|
+
}
|
|
1095
|
+
clearMarkers() {
|
|
1096
|
+
this.in = null, this.out = null;
|
|
1097
|
+
}
|
|
1098
|
+
// utilizes player instance from props
|
|
1099
|
+
setInFromCurrent() {
|
|
1100
|
+
this.in = this.props.player.videojs.currentTime();
|
|
1101
|
+
}
|
|
1102
|
+
setOutFromCurrent() {
|
|
1103
|
+
this.out = this.props.player.videojs.currentTime();
|
|
1104
|
+
}
|
|
1105
|
+
navigateToIn() {
|
|
1106
|
+
const { player: e } = this.props;
|
|
1107
|
+
e.seekTo(this.in);
|
|
1108
|
+
}
|
|
1109
|
+
navigateToOut() {
|
|
1110
|
+
const { player: e } = this.props;
|
|
1111
|
+
e.seekTo(this.out);
|
|
1112
|
+
}
|
|
1113
|
+
// setters and getters
|
|
1114
|
+
set in(e) {
|
|
1115
|
+
if (this.state.markersEnabled)
|
|
1116
|
+
if (this.state.in = e, e != null) {
|
|
1117
|
+
const { player: t } = this.props;
|
|
1118
|
+
this.updateMarkers({
|
|
1119
|
+
type: d.markerTypes.in,
|
|
1120
|
+
value: e / t.videojs.duration()
|
|
1121
|
+
}), this.state.out !== null && e > this.state.out && (this.out = null), this.props.onIn && this.props.onIn(this.state.in);
|
|
1122
|
+
} else
|
|
1123
|
+
this.cleanupMarkers();
|
|
1124
|
+
}
|
|
1125
|
+
get in() {
|
|
1126
|
+
return this.state.in;
|
|
1127
|
+
}
|
|
1128
|
+
set out(e) {
|
|
1129
|
+
if (this.state.markersEnabled)
|
|
1130
|
+
if (this.state.out = e, e != null) {
|
|
1131
|
+
const { player: t } = this.props;
|
|
1132
|
+
this.updateMarkers({
|
|
1133
|
+
type: d.markerTypes.out,
|
|
1134
|
+
value: e / t.videojs.duration()
|
|
1135
|
+
}), this.state.in != null && e < this.state.in && (this.in = null), this.props.onOut && this.props.onOut(this.state.out);
|
|
1136
|
+
} else
|
|
1137
|
+
this.cleanupMarkers();
|
|
1138
|
+
}
|
|
1139
|
+
get out() {
|
|
1140
|
+
return this.state.out;
|
|
1141
|
+
}
|
|
1142
|
+
get markersEnabled() {
|
|
1143
|
+
return this.state.markersEnabled;
|
|
1144
|
+
}
|
|
1145
|
+
set markersEnabled(e) {
|
|
1146
|
+
typeof e == "boolean" && (e ? (!this.markersEnabled && this.drawMarkers(), this.state.markersEnabled = !0) : (this.clearMarkers(), this.state.markersEnabled = !1));
|
|
1147
|
+
}
|
|
1148
|
+
set regions(e) {
|
|
1149
|
+
this.state.regions.length < 1 ? e && e.forEach((t) => {
|
|
1150
|
+
this.addRegion(t);
|
|
1151
|
+
}) : (this.state.regions.forEach((t, s) => {
|
|
1152
|
+
this.removeRegion(s);
|
|
1153
|
+
}), this.state.regions = [], this.regions = e);
|
|
1154
|
+
}
|
|
1155
|
+
get regions() {
|
|
1156
|
+
return this.state.regions;
|
|
1157
|
+
}
|
|
1158
|
+
set dragging(e) {
|
|
1159
|
+
e && !this.state.dragging ? (this.state.dragging = !0, this.bar.classList.add("dragging")) : !e && this.state.dragging && (this.state.dragging = !1, this.bar.classList.remove("dragging"));
|
|
1160
|
+
}
|
|
1161
|
+
get dragging() {
|
|
1162
|
+
return this.state.dragging;
|
|
1163
|
+
}
|
|
1164
|
+
addRegion(e) {
|
|
1165
|
+
e.constructor.name === T.name ? (this.state.regions.push(e), this.drawRegion(e)) : this.addRegion(new T(e));
|
|
1166
|
+
}
|
|
1167
|
+
removeRegion(e) {
|
|
1168
|
+
typeof e == typeof T || (this.state.regions[e].el.remove(), this.state.regions[e] = null, delete this.state.regions[e]);
|
|
1169
|
+
}
|
|
1170
|
+
drawRegion(e) {
|
|
1171
|
+
const t = this.props.player.videojs.duration(), o = e.in / t * 100, i = (t - e.out) / t * 100, r = document.createElement("div");
|
|
1172
|
+
if (r.className = "region nav ", r.innerHTML = '<div class="bubble"></div>', e.title && e.annotation) {
|
|
1173
|
+
let n = "";
|
|
1174
|
+
o > 70 && (n = "right-aligned"), o < 30 && (n = "left-aligned"), r.className += ` has-popout ${n}`;
|
|
1175
|
+
const u = document.createElement("div");
|
|
1176
|
+
u.className = "popout", u.innerHTML = `
|
|
1177
|
+
<div class="title">
|
|
1178
|
+
${x(e.title)}
|
|
1179
|
+
</div>
|
|
1180
|
+
<div class="annotation">
|
|
1181
|
+
${ee(x(e.annotation), 72)}
|
|
1182
|
+
</div>
|
|
1183
|
+
`, r.appendChild(u);
|
|
1184
|
+
}
|
|
1185
|
+
r.style.left = `${o}%`, r.style.right = `${i}%`, e.el = r, this.bar.appendChild(r);
|
|
1186
|
+
}
|
|
1187
|
+
set onDark(e) {
|
|
1188
|
+
e ? this.bar.classList.add(p.onDark) : this.bar.classList.remove(p.onDark);
|
|
1189
|
+
}
|
|
1190
|
+
get onDark() {
|
|
1191
|
+
return this.container.classList.contains(p.onDark);
|
|
1192
|
+
}
|
|
1193
|
+
set percentLoaded(e) {
|
|
1194
|
+
this.loadIndicator.style.width = `${e}%`;
|
|
1195
|
+
}
|
|
1196
|
+
destroy() {
|
|
1197
|
+
this.unbindHotKeys();
|
|
1198
|
+
}
|
|
1199
|
+
toggleMarkers() {
|
|
1200
|
+
this.bar.classList.contains("hide-markers") ? this.showMarkers() : this.hideMarkers();
|
|
1201
|
+
}
|
|
1202
|
+
hideMarkers() {
|
|
1203
|
+
this.bar.classList.add("hide-markers");
|
|
1204
|
+
}
|
|
1205
|
+
showMarkers() {
|
|
1206
|
+
this.bar.classList.remove("hide-markers");
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
L.Region = T;
|
|
1210
|
+
const de = ["hours", "minutes", "seconds", "frame"];
|
|
1211
|
+
class N {
|
|
1212
|
+
// displays and renders smpte timecodes
|
|
1213
|
+
constructor(e) {
|
|
1214
|
+
this.props = e, this.state = {
|
|
1215
|
+
selectedNode: null
|
|
1216
|
+
// avoid updating values in a selected node
|
|
1217
|
+
};
|
|
1218
|
+
const t = [
|
|
1219
|
+
"vdt-timecode",
|
|
1220
|
+
"vjs-time-control",
|
|
1221
|
+
// will apply default videojs style to the whole container, centers things vertically
|
|
1222
|
+
this.props.onInput ? "" : "duration"
|
|
1223
|
+
// if no input capability, assume it's a duration timecode
|
|
1224
|
+
];
|
|
1225
|
+
this.container = document.createElement("div"), this.container.className = t.join(" "), this.nodeNames = [].concat(de), this.nodes = {}, this.nodeNames.forEach((s, o) => {
|
|
1226
|
+
const i = document.createElement("input");
|
|
1227
|
+
i.className = s, i.tabIndex = -1, this.props.onInput ? (i.maxLength = 2, i.onfocus = (n) => {
|
|
1228
|
+
this.handleInputFocus(n, s);
|
|
1229
|
+
}, i.onblur = (n) => {
|
|
1230
|
+
this.handleInputBlur(n, s);
|
|
1231
|
+
}, i.onmouseup = (n) => {
|
|
1232
|
+
n.preventDefault(), n.currentTarget.select();
|
|
1233
|
+
}, i.onkeydown = (n) => {
|
|
1234
|
+
this.handleTimeCodeInput(n, s);
|
|
1235
|
+
}, i.onkeyup = (n) => {
|
|
1236
|
+
this.handleTimeCodeInputOnKeyUp(n, s);
|
|
1237
|
+
}) : i.readOnly = !0, this.nodes[s] = i;
|
|
1238
|
+
const r = document.createElement("span");
|
|
1239
|
+
r.innerHTML = ":", this.container.appendChild(i), o !== this.nodeNames.length - 1 && this.container.appendChild(r);
|
|
1240
|
+
}), this.props.target ? (this.props.appendAfter ? this.props.target.parentNode.insertBefore(this.container, this.props.target.nextSibling) : this.props.target.appendChild(this.container), this.reset()) : console.error(`Unable to instantiate a new ${this.constructor.name} without target DOM node`);
|
|
1241
|
+
}
|
|
1242
|
+
update(e) {
|
|
1243
|
+
const t = this.nodeNames.length - 1;
|
|
1244
|
+
let s;
|
|
1245
|
+
for (s = t; s > -1; s--) {
|
|
1246
|
+
const o = this.nodeNames[s];
|
|
1247
|
+
if (typeof e[o] < "u" && e[o] !== parseInt(this.nodes[o].value, 10) && o !== this.state.selectedNode) {
|
|
1248
|
+
const i = e[o].toString();
|
|
1249
|
+
this.nodes[o].value = this.toDigitPairStr(i);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
reset() {
|
|
1254
|
+
this.update({
|
|
1255
|
+
hours: 0,
|
|
1256
|
+
minutes: 0,
|
|
1257
|
+
seconds: 0,
|
|
1258
|
+
frame: 0
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
handleInputFocus(e, t) {
|
|
1262
|
+
this.state.selectedNode = t, this.nodes[t].select(), this.props.onInputFocus && this.props.onInputFocus(t);
|
|
1263
|
+
}
|
|
1264
|
+
handleInputBlur(e, t) {
|
|
1265
|
+
this.state.selectedNode = null, this.props.onInputBlur && this.props.onInputBlur(t);
|
|
1266
|
+
}
|
|
1267
|
+
sanitize(e) {
|
|
1268
|
+
return e.replace(/[^0-9]/g, "");
|
|
1269
|
+
}
|
|
1270
|
+
toDigitPairStr(e) {
|
|
1271
|
+
return e.length < 2 ? `0${e}` : e;
|
|
1272
|
+
}
|
|
1273
|
+
handleTimeCodeInput(e, t) {
|
|
1274
|
+
const s = this.nodeNames.indexOf(t);
|
|
1275
|
+
switch (e.code) {
|
|
1276
|
+
case "Enter":
|
|
1277
|
+
this.checkAndNormalizeAllInputs(), this.props.onInput && this.props.onInput(e, t, {
|
|
1278
|
+
hours: this.hours,
|
|
1279
|
+
minutes: this.minutes,
|
|
1280
|
+
seconds: this.seconds,
|
|
1281
|
+
frame: this.frame
|
|
1282
|
+
}), this[t] = e.currentTarget.value, e.currentTarget.blur();
|
|
1283
|
+
break;
|
|
1284
|
+
case "Tab":
|
|
1285
|
+
e.preventDefault(), e.shiftKey ? s - 1 >= 0 ? this.nodes[this.nodeNames[s - 1]].focus() : this.nodes[this.nodeNames[this.nodeNames.length - 1]].focus() : s + 1 <= this.nodeNames.length - 1 ? this.nodes[this.nodeNames[s + 1]].focus() : this.nodes[this.nodeNames[0]].focus();
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
handleTimeCodeInputOnKeyUp(e, t) {
|
|
1290
|
+
if (this.nodes[t].value.length === 2 && !isNaN(e.key)) {
|
|
1291
|
+
const s = this.nodeNames.indexOf(t);
|
|
1292
|
+
s + 1 <= this.nodeNames.length - 1 && this.nodes[this.nodeNames[s + 1]].focus();
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
checkAndNormalizeAllInputs() {
|
|
1296
|
+
this.nodeNames.forEach((e) => {
|
|
1297
|
+
this.nodes[e].value.length < 1 && (this.nodes[e].value = "00"), this.nodes[e].value = this.toDigitPairStr(this.sanitize(this.nodes[e].value));
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
// setters and getters
|
|
1301
|
+
set frame(e) {
|
|
1302
|
+
this.nodes.frame.value = this.toDigitPairStr(e);
|
|
1303
|
+
}
|
|
1304
|
+
get frame() {
|
|
1305
|
+
return parseInt(this.nodes.frame.value, 10);
|
|
1306
|
+
}
|
|
1307
|
+
set seconds(e) {
|
|
1308
|
+
this.nodes.seconds.value = this.toDigitPairStr(e);
|
|
1309
|
+
}
|
|
1310
|
+
get seconds() {
|
|
1311
|
+
return parseInt(this.nodes.seconds.value, 10);
|
|
1312
|
+
}
|
|
1313
|
+
set minutes(e) {
|
|
1314
|
+
this.nodes.minutes.value = this.toDigitPairStr(e);
|
|
1315
|
+
}
|
|
1316
|
+
get minutes() {
|
|
1317
|
+
return parseInt(this.nodes.minutes.value, 10);
|
|
1318
|
+
}
|
|
1319
|
+
set hours(e) {
|
|
1320
|
+
this.nodes.hours.value = this.toDigitPairStr(e);
|
|
1321
|
+
}
|
|
1322
|
+
get hours() {
|
|
1323
|
+
return parseInt(this.nodes.hours.value, 10);
|
|
1324
|
+
}
|
|
1325
|
+
getFormatted(e) {
|
|
1326
|
+
return this.toDigitPairStr(this[e].toString());
|
|
1327
|
+
}
|
|
1328
|
+
get smpte() {
|
|
1329
|
+
return {
|
|
1330
|
+
hours: this.hours,
|
|
1331
|
+
minutes: this.minutes,
|
|
1332
|
+
seconds: this.seconds,
|
|
1333
|
+
frame: this.frame
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
set smpte(e) {
|
|
1337
|
+
this.update(e);
|
|
1338
|
+
}
|
|
1339
|
+
get smpteString() {
|
|
1340
|
+
return `${this.getFormatted("hours")}:${this.getFormatted("minutes")}:${this.getFormatted(
|
|
1341
|
+
"seconds"
|
|
1342
|
+
)}:${this.getFormatted("frame")}`;
|
|
1343
|
+
}
|
|
1344
|
+
set external(e) {
|
|
1345
|
+
e ? this.container.classList.add("external") : this.container.classList.remove("external");
|
|
1346
|
+
}
|
|
1347
|
+
get external() {
|
|
1348
|
+
return this.container.classList.contains("external");
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
class he {
|
|
1352
|
+
constructor(e) {
|
|
1353
|
+
if (e.frameRate === void 0)
|
|
1354
|
+
throw delete this, new Error('No "frameRate" option provided, refer to docs.');
|
|
1355
|
+
this.props = e;
|
|
1356
|
+
}
|
|
1357
|
+
secondsToFramesFromStart(e) {
|
|
1358
|
+
let t = e * this.props.frameRate;
|
|
1359
|
+
return t = Math.round(t), t;
|
|
1360
|
+
}
|
|
1361
|
+
currentTimeToFramesFromStart(e) {
|
|
1362
|
+
return this.secondsToFramesFromStart(e);
|
|
1363
|
+
}
|
|
1364
|
+
secondsToFrame(e) {
|
|
1365
|
+
let t = this.secondsToFramesFromStart(e) % this.props.frameRate;
|
|
1366
|
+
return t = Math.round(t), t;
|
|
1367
|
+
}
|
|
1368
|
+
currentFrame(e) {
|
|
1369
|
+
return Math.round(this.secondsToFrame(e));
|
|
1370
|
+
}
|
|
1371
|
+
frameToCurrentTimeFromStart(e) {
|
|
1372
|
+
return e / this.props.frameRate;
|
|
1373
|
+
}
|
|
1374
|
+
smpteToCurrentTimeFromStart(e) {
|
|
1375
|
+
return e.hours * 3600 + e.minutes * 60 + e.seconds + e.frame / this.props.frameRate;
|
|
1376
|
+
}
|
|
1377
|
+
secondsFromStartToSMPTE(e) {
|
|
1378
|
+
let t = e;
|
|
1379
|
+
const s = Math.floor(t / 3600), o = t / 60 - 60 * s;
|
|
1380
|
+
t %= 3600;
|
|
1381
|
+
const i = Math.floor(o), r = Math.floor(t % 60), n = this.secondsToFrame(t);
|
|
1382
|
+
return {
|
|
1383
|
+
hours: s,
|
|
1384
|
+
minutes: i,
|
|
1385
|
+
seconds: r,
|
|
1386
|
+
frame: n
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
const ce = {
|
|
1391
|
+
"audio/x-aac": "audio/aac"
|
|
1392
|
+
}, pe = (c) => ce[c] || c;
|
|
1393
|
+
class be {
|
|
1394
|
+
constructor(e) {
|
|
1395
|
+
this.props = e, w.apply(this);
|
|
1396
|
+
const t = [
|
|
1397
|
+
// add conditional css classes here for the whole container
|
|
1398
|
+
"video-js",
|
|
1399
|
+
"vjs-big-play-centered",
|
|
1400
|
+
this.props.posterUrl ? l.classNames.poster : "",
|
|
1401
|
+
this.props.subtitles && this.props.subtitles.length > 0 ? l.classNames.subtitles : "",
|
|
1402
|
+
"init"
|
|
1403
|
+
// make player height 0 while no metadata for video size available with css
|
|
1404
|
+
];
|
|
1405
|
+
this.externalTimecodes = {
|
|
1406
|
+
// either one of these can hold an array of TimeCodeDisplay instances
|
|
1407
|
+
duration: [],
|
|
1408
|
+
playback: []
|
|
1409
|
+
}, this.timeConverter = new he({
|
|
1410
|
+
frameRate: this.props.frameRate || l.defaults.frameRate
|
|
1411
|
+
}), this.videoEl = document.createElement("video"), this.videoEl.crossOrigin = this.props.crossOrigin, this.videoEl.id = "vdt-video", this.videoEl.className = t.join(" "), this.videoEl.controls = !0, this.props.sources && (this.props.sources.length > 1 && this.props.sources.sort((r) => r.type.indexOf("mp4") > 0 ? 1 : -1), this.props.sources.forEach((r) => {
|
|
1412
|
+
const n = document.createElement("source");
|
|
1413
|
+
n.src = r.src, n.type = pe(r.type), this.videoEl.appendChild(n);
|
|
1414
|
+
})), this.videoEl.onloadedmetadata = () => {
|
|
1415
|
+
this.durationTimeCode && this.setDurationTimeCode(), this.videojs.el_ && this.videojs.el_.classList.remove("init");
|
|
1416
|
+
}, setTimeout(() => {
|
|
1417
|
+
this.videojs.el_ && this.videojs.el_.classList.remove("init");
|
|
1418
|
+
}, 2e3), this.props.subtitles && this.props.subtitles.forEach((r) => {
|
|
1419
|
+
const n = document.createElement("track");
|
|
1420
|
+
n.kind = "subtitles", n.srclang = r.lang, n.label = r.label, typeof r.src == "string" ? n.src = r.src : n.src = window.URL.createObjectURL(r.src), this.videoEl.appendChild(n);
|
|
1421
|
+
}), this.props.target && this.props.target.appendChild(this.videoEl);
|
|
1422
|
+
const s = this.props.timecode !== !0, o = this.props.controls !== !1, i = this.props.options || {};
|
|
1423
|
+
this.videojs = new v("vdt-video", {
|
|
1424
|
+
responsive: !0,
|
|
1425
|
+
fluid: !0,
|
|
1426
|
+
controls: o,
|
|
1427
|
+
alwaysCaptureHotkeys: !1,
|
|
1428
|
+
controlBar: {
|
|
1429
|
+
RemainingTimeDisplay: !1,
|
|
1430
|
+
timeDivider: s,
|
|
1431
|
+
// relates to built-in time display
|
|
1432
|
+
durationDisplay: s,
|
|
1433
|
+
currentTimeDisplay: s
|
|
1434
|
+
},
|
|
1435
|
+
inactivityTimeout: this.audioOnly ? l.defaults.audioInactivityTimeout : l.defaults.inactivityTimeout,
|
|
1436
|
+
preload: "auto",
|
|
1437
|
+
captionsButton: !1,
|
|
1438
|
+
subsCapsButton: !1,
|
|
1439
|
+
subtitlesButton: !1,
|
|
1440
|
+
textTrackSettings: !1,
|
|
1441
|
+
html5: {
|
|
1442
|
+
nativeTextTracks: !1
|
|
1443
|
+
},
|
|
1444
|
+
languages: {
|
|
1445
|
+
en: {
|
|
1446
|
+
"captions off": "off",
|
|
1447
|
+
"subtitles off": "off"
|
|
1448
|
+
}
|
|
1449
|
+
},
|
|
1450
|
+
...i
|
|
1451
|
+
}), this.props.posterUrl && this.videojs.poster(this.props.posterUrl), this.handleNewProps(this.props), this.videojs.ready(() => {
|
|
1452
|
+
this.bindHotkeys(), this.bindEvents(), this.props.onReady && this.props.onReady(this.videojs), this.restoreSettings(), this.setupTimeCode(), this.doEsothericWork(), this.setupMenu(), this.setupCustomSeekbar();
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
setupCustomSeekbar() {
|
|
1456
|
+
if (this.props.seekBar) {
|
|
1457
|
+
this.videojs.controlBar.progressControl.disable(), this.videojs.controlBar.progressControl.hide();
|
|
1458
|
+
const t = {
|
|
1459
|
+
target: this.container.getElementsByClassName("vjs-control-bar")[0],
|
|
1460
|
+
player: this,
|
|
1461
|
+
onDark: this.props.onDark,
|
|
1462
|
+
...this.props.seekBar
|
|
1463
|
+
};
|
|
1464
|
+
this.seekBar = new L(t), this.videojs.on("userinactive", () => {
|
|
1465
|
+
var s, o, i, r;
|
|
1466
|
+
this.controlsBelowPlayer ? (r = (i = this.seekBar) == null ? void 0 : i.showMarkers) == null || r.call(i) : this.seekBar && ((o = (s = this.seekBar).hideMarkers) == null || o.call(s));
|
|
1467
|
+
}), this.videojs.on("useractive", () => {
|
|
1468
|
+
this.seekBar && this.seekBar.showMarkers();
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
setupTimeCode(e = null) {
|
|
1473
|
+
const t = {
|
|
1474
|
+
onInput: (s, o, i) => {
|
|
1475
|
+
this.seekTo(this.timeConverter.smpteToCurrentTimeFromStart(i));
|
|
1476
|
+
},
|
|
1477
|
+
onInputFocus: () => {
|
|
1478
|
+
this.videojs.options_.inactivityTimeout = 0, this.videojs.cache_.inactivityTimeout = 0, this.videojs.reportUserActivity(), this.videojs.pause();
|
|
1479
|
+
},
|
|
1480
|
+
onInputBlur: () => {
|
|
1481
|
+
this.videojs.options().inactivityTimeout = l.defaults.inactivityTimeout, this.videojs.cache_.inactivityTimeout = l.defaults.inactivityTimeout;
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
if (e !== null)
|
|
1485
|
+
e.props = Object.assign(e.props, t), this.externalTimecodes.playback.push(e);
|
|
1486
|
+
else if (this.props.timecode === !0 && this.props.controls !== !1) {
|
|
1487
|
+
const s = document.getElementsByClassName("vjs-volume-panel")[0];
|
|
1488
|
+
this.timeCode = new N(Object.assign(t, { target: s, appendAfter: !0 })), this.durationTimeCode = new N({
|
|
1489
|
+
target: this.timeCode.container,
|
|
1490
|
+
appendAfter: !0
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
(this.timeCode || this.externalTimecodes.playback.length > 0) && (this.videojs.on("timeupdate", () => {
|
|
1494
|
+
this.updateTimeCode();
|
|
1495
|
+
}), this.videojs.on("play", () => {
|
|
1496
|
+
this.updateTimeCodeFrame();
|
|
1497
|
+
}));
|
|
1498
|
+
}
|
|
1499
|
+
updateTimeCode() {
|
|
1500
|
+
const e = this.videojs.currentTime(), t = this.timeConverter.secondsFromStartToSMPTE(e);
|
|
1501
|
+
this.timeCode && this.timeCode.update(t), this.externalTimecodes.playback.length > 0 && this.externalTimecodes.playback.forEach((s) => {
|
|
1502
|
+
s.update(t);
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
updateTimeCodeFrame() {
|
|
1506
|
+
const e = this.timeConverter.currentFrame(this.videojs.currentTime());
|
|
1507
|
+
this.timeCode && this.timeCode.update({ frame: e }), this.externalTimecodes.playback.length > 0 && this.externalTimecodes.playback.forEach((t) => {
|
|
1508
|
+
t.update({ frame: e });
|
|
1509
|
+
}), this.videojs.paused() || (this.rafID = requestAnimationFrame(() => {
|
|
1510
|
+
this.updateTimeCodeFrame();
|
|
1511
|
+
}));
|
|
1512
|
+
}
|
|
1513
|
+
setDurationTimeCode() {
|
|
1514
|
+
const e = this.videojs.duration(), t = this.timeConverter.secondsFromStartToSMPTE(e);
|
|
1515
|
+
t.frame = this.timeConverter.secondsToFrame(e), this.durationTimeCode.update(t), this.durationTimeCode.container.classList.add("duration");
|
|
1516
|
+
}
|
|
1517
|
+
bindHotkeys() {
|
|
1518
|
+
this.bindings = [
|
|
1519
|
+
{
|
|
1520
|
+
key: ["space", "k"],
|
|
1521
|
+
method: (e) => {
|
|
1522
|
+
e.preventDefault && e.preventDefault(), this.togglePlayback();
|
|
1523
|
+
}
|
|
1524
|
+
},
|
|
1525
|
+
{
|
|
1526
|
+
key: "j",
|
|
1527
|
+
method: () => {
|
|
1528
|
+
this.videojs.hasStarted_ && this.jumpBackward();
|
|
1529
|
+
}
|
|
1530
|
+
},
|
|
1531
|
+
{
|
|
1532
|
+
key: "l",
|
|
1533
|
+
method: () => {
|
|
1534
|
+
this.videojs.hasStarted_ && this.jumpForward();
|
|
1535
|
+
}
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
key: [".", "right"],
|
|
1539
|
+
method: () => {
|
|
1540
|
+
this.frameForward();
|
|
1541
|
+
}
|
|
1542
|
+
},
|
|
1543
|
+
{
|
|
1544
|
+
key: [",", "left"],
|
|
1545
|
+
method: () => {
|
|
1546
|
+
this.frameBackward();
|
|
1547
|
+
}
|
|
1548
|
+
},
|
|
1549
|
+
{
|
|
1550
|
+
key: "f",
|
|
1551
|
+
method: () => {
|
|
1552
|
+
this.toggleFullscreen();
|
|
1553
|
+
}
|
|
1554
|
+
},
|
|
1555
|
+
{
|
|
1556
|
+
key: "m",
|
|
1557
|
+
method: () => {
|
|
1558
|
+
this.toggleMute();
|
|
1559
|
+
}
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
key: "up",
|
|
1563
|
+
method: (e) => {
|
|
1564
|
+
e.preventDefault && e.preventDefault(), this.volumeUp();
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
key: "down",
|
|
1569
|
+
method: (e) => {
|
|
1570
|
+
e.preventDefault && e.preventDefault(), this.volumeDown();
|
|
1571
|
+
}
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
key: "h",
|
|
1575
|
+
method: () => {
|
|
1576
|
+
this.help.toggle();
|
|
1577
|
+
}
|
|
1578
|
+
},
|
|
1579
|
+
{
|
|
1580
|
+
key: "n",
|
|
1581
|
+
method: () => {
|
|
1582
|
+
this.menu && this.menu.toggle();
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
], this.props.subtitles && this.bindings.push({
|
|
1586
|
+
key: "c",
|
|
1587
|
+
method: () => {
|
|
1588
|
+
this.toggleSubs();
|
|
1589
|
+
}
|
|
1590
|
+
}), this.bindings.forEach((e) => {
|
|
1591
|
+
m.bind(e.key, (t) => {
|
|
1592
|
+
e.method(t), this.onHotkeyPressed(e.key);
|
|
1593
|
+
});
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
unbindHotKeys() {
|
|
1597
|
+
this.bindings && this.bindings.forEach((e) => {
|
|
1598
|
+
m.unbind(e.key);
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
bindEvents() {
|
|
1602
|
+
this.videojs.on("volumechange", () => {
|
|
1603
|
+
this.persistSetting(l.settings.volume, this.volume);
|
|
1604
|
+
}), this.videojs.textTracks().on("change", () => {
|
|
1605
|
+
const t = this.videojs.textTracks().tracks_.filter((o) => o.mode === "showing");
|
|
1606
|
+
t.length > 0 ? (this.videojs.el_.classList.add(l.classNames.subtitlesActive), this.persistSetting(l.settings.subs, !0), this.persistSetting(l.settings.subLang, t[0].language)) : (this.videojs.el_.classList.remove(l.classNames.subtitlesActive), this.persistSetting(l.settings.subs, !1));
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
volumeUp() {
|
|
1610
|
+
this.videojs.controlBar.volumePanel.volumeControl.volumeBar.stepForward(), this.osd.feedback(l.osd.volchange, { volume: this.volume });
|
|
1611
|
+
}
|
|
1612
|
+
volumeDown() {
|
|
1613
|
+
this.videojs.controlBar.volumePanel.volumeControl.volumeBar.stepBack(), this.osd.feedback(l.osd.volchange, { volume: this.volume });
|
|
1614
|
+
}
|
|
1615
|
+
toggleMute() {
|
|
1616
|
+
this.videojs.muted() ? (this.videojs.muted(!1), this.osd.feedback(l.osd.volchange, { volume: this.volume })) : (this.videojs.muted(!0), this.osd.feedback(l.osd.volchange, { volume: this.volume }));
|
|
1617
|
+
}
|
|
1618
|
+
toggleFullscreen() {
|
|
1619
|
+
this.videojs.isFullscreen() ? this.videojs.exitFullscreen() : this.videojs.requestFullscreen();
|
|
1620
|
+
}
|
|
1621
|
+
seek(e) {
|
|
1622
|
+
let t = this.videojs.currentTime() + e;
|
|
1623
|
+
t < 0 && (t = 0), this.videojs.currentTime(t);
|
|
1624
|
+
}
|
|
1625
|
+
seekTo(e) {
|
|
1626
|
+
this.videojs.hasStarted() || this.videojs.hasStarted(!0), this.videojs.currentTime(e);
|
|
1627
|
+
}
|
|
1628
|
+
jumpForward() {
|
|
1629
|
+
this.seek(l.defaults.jumpSeconds), this.osd.feedback(l.osd.jumpForward);
|
|
1630
|
+
}
|
|
1631
|
+
jumpBackward() {
|
|
1632
|
+
this.seek(-l.defaults.jumpSeconds), this.osd.feedback(l.osd.jumpBackward);
|
|
1633
|
+
}
|
|
1634
|
+
frameForward() {
|
|
1635
|
+
const e = this.timeConverter.secondsToFramesFromStart(this.videojs.currentTime()), t = Math.round(e) + 1;
|
|
1636
|
+
this.videojs.currentTime(this.timeConverter.frameToCurrentTimeFromStart(t));
|
|
1637
|
+
}
|
|
1638
|
+
frameBackward() {
|
|
1639
|
+
const e = this.timeConverter.secondsToFramesFromStart(this.videojs.currentTime()), t = Math.round(e) - 1;
|
|
1640
|
+
this.videojs.currentTime(this.timeConverter.frameToCurrentTimeFromStart(t));
|
|
1641
|
+
}
|
|
1642
|
+
secondsToFramesFromStart(e) {
|
|
1643
|
+
const t = this.props.frameRate || l.defaults.frameRate;
|
|
1644
|
+
let s = e * t;
|
|
1645
|
+
return s = Math.round(s), s;
|
|
1646
|
+
}
|
|
1647
|
+
doEsothericWork() {
|
|
1648
|
+
this.props.color && (document.getElementsByClassName("vjs-play-progress")[0].style.backgroundColor = this.props.color), this.osd = new ae({
|
|
1649
|
+
target: this.videoEl.parentElement
|
|
1650
|
+
}), this.props.onCinema && (this.videoEl.parentElement.classList.add("has-cinema-button"), this.cinema = !1, this.addButtonToControlBar({
|
|
1651
|
+
onClick: () => {
|
|
1652
|
+
this.props.onCinema(!this.cinema), this.cinema = !this.cinema;
|
|
1653
|
+
},
|
|
1654
|
+
componentName: "CinemaButton",
|
|
1655
|
+
className: "vdt-cinema-button",
|
|
1656
|
+
title: "Cinema-mode"
|
|
1657
|
+
})), this.props.onScreenshot && (this.videoEl.parentElement.classList.add("has-screenshot-button"), this.addButtonToControlBar({
|
|
1658
|
+
onClick: () => {
|
|
1659
|
+
this.props.onScreenshot(this.videojs.currentTime());
|
|
1660
|
+
},
|
|
1661
|
+
componentName: "ScreenshotButton",
|
|
1662
|
+
className: "vdt-screenshot-button",
|
|
1663
|
+
title: "Screenshot"
|
|
1664
|
+
})), this.help = new oe({
|
|
1665
|
+
target: this.videoEl.parentElement,
|
|
1666
|
+
onToggle: (e) => {
|
|
1667
|
+
this.menu && this.menu.opened && this.menu.close(), e && !this.controlsBelowPlayer ? this.hideControls() : this.showControls();
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
restoreSettings() {
|
|
1672
|
+
const e = localStorage.getItem(l.settings.volume), t = localStorage.getItem(l.settings.subs), s = localStorage.getItem(l.settings.subLang);
|
|
1673
|
+
this.settings = {
|
|
1674
|
+
// avoid .99999999 and other float pecularities in js
|
|
1675
|
+
[l.settings.volume]: e !== null ? Math.round(e * 100) / 100 : 1,
|
|
1676
|
+
[l.settings.subLang]: s !== null ? s : "en",
|
|
1677
|
+
[l.settings.subs]: t !== null ? JSON.parse(t) : !1
|
|
1678
|
+
}, this.volume = this.settings[l.settings.volume], this.settings[l.settings.subs] && this.enableSubs();
|
|
1679
|
+
}
|
|
1680
|
+
persistSetting(e, t) {
|
|
1681
|
+
this.settings[e] = t, localStorage.setItem(e, t);
|
|
1682
|
+
}
|
|
1683
|
+
enableSubs() {
|
|
1684
|
+
const e = this.videojs.textTracks();
|
|
1685
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
1686
|
+
const s = e[t];
|
|
1687
|
+
s.language === this.settings[l.settings.subLang] ? s.mode = "showing" : s.mode = "hidden";
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
disableSubs() {
|
|
1691
|
+
const e = this.videojs.textTracks();
|
|
1692
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
1693
|
+
const s = e[t];
|
|
1694
|
+
s.mode = "hidden";
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
toggleSubs() {
|
|
1698
|
+
this.videojs.textTracks().length > 0 && (this.videojs.textTracks().tracks_.filter((e) => e.mode === "showing").length > 0 ? this.disableSubs() : this.enableSubs());
|
|
1699
|
+
}
|
|
1700
|
+
/*
|
|
1701
|
+
A quick example
|
|
1702
|
+
options = {
|
|
1703
|
+
onClick: ()=>{},
|
|
1704
|
+
componentName: 'ScreenshotButton',
|
|
1705
|
+
className: 'vdt-screenshot-button'
|
|
1706
|
+
}
|
|
1707
|
+
*/
|
|
1708
|
+
addButtonToControlBar(e) {
|
|
1709
|
+
const t = v.getComponent("Button"), s = v.extend(t, {
|
|
1710
|
+
/* eslint-disable func-names, object-shorthand */
|
|
1711
|
+
constructor: function() {
|
|
1712
|
+
t.apply(this, arguments), e.className && this.el_.classList.add(e.className), e.title && (this.el_.title = e.title);
|
|
1713
|
+
},
|
|
1714
|
+
handleClick: () => {
|
|
1715
|
+
e.onClick && e.onClick();
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
v.registerComponent(e.componentName, s), this.videojs.getChild("controlBar").addChild(e.componentName, {}, 7);
|
|
1719
|
+
}
|
|
1720
|
+
// convenient getters / setters
|
|
1721
|
+
get volume() {
|
|
1722
|
+
return this.videojs.controlBar.volumePanel.volumeControl.volumeBar.getPercent();
|
|
1723
|
+
}
|
|
1724
|
+
set volume(e) {
|
|
1725
|
+
e === 0 ? this.videojs.muted(!0) : (this.videojs.muted(!1), this.videojs.volume(e));
|
|
1726
|
+
}
|
|
1727
|
+
setupMenu() {
|
|
1728
|
+
const e = this.props.menuItems || [], t = [];
|
|
1729
|
+
if (this.props.sources.length > 1 && (this.props.sources.forEach((s) => {
|
|
1730
|
+
s.label && t.push({
|
|
1731
|
+
title: s.label,
|
|
1732
|
+
onClick: () => {
|
|
1733
|
+
this.src = s;
|
|
1734
|
+
}
|
|
1735
|
+
});
|
|
1736
|
+
}), e.push({
|
|
1737
|
+
title: "Sources",
|
|
1738
|
+
getActiveIndex: () => {
|
|
1739
|
+
const s = this.props.sources.find(
|
|
1740
|
+
(o) => o.src === this.videojs.src()
|
|
1741
|
+
);
|
|
1742
|
+
return t.indexOf(
|
|
1743
|
+
t.find((o) => o.title === s.label)
|
|
1744
|
+
);
|
|
1745
|
+
},
|
|
1746
|
+
items: t
|
|
1747
|
+
})), this.props.subtitles && this.props.subtitles.length > 0) {
|
|
1748
|
+
const s = [
|
|
1749
|
+
{
|
|
1750
|
+
title: "Off",
|
|
1751
|
+
onClick: () => {
|
|
1752
|
+
this.disableSubs();
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
];
|
|
1756
|
+
this.props.subtitles.forEach((o, i) => {
|
|
1757
|
+
s.push({
|
|
1758
|
+
title: o.label,
|
|
1759
|
+
onClick: () => {
|
|
1760
|
+
const r = this.videojs.textTracks();
|
|
1761
|
+
for (let n = 0; n < r.length; n += 1) {
|
|
1762
|
+
const u = r[n];
|
|
1763
|
+
n === i ? u.mode = "showing" : u.mode = "hidden";
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
}), e.push({
|
|
1768
|
+
title: "Subtitles",
|
|
1769
|
+
getActiveIndex: () => {
|
|
1770
|
+
const o = this.videojs.textTracks();
|
|
1771
|
+
for (let i = 0; i < o.length; i += 1)
|
|
1772
|
+
if (o[i].mode === "showing")
|
|
1773
|
+
return i + 1;
|
|
1774
|
+
return 0;
|
|
1775
|
+
},
|
|
1776
|
+
items: s
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
if (e.length > 0) {
|
|
1780
|
+
const s = this.videojs.el_;
|
|
1781
|
+
this.menu = new re({
|
|
1782
|
+
target: s,
|
|
1783
|
+
items: e,
|
|
1784
|
+
onOpen: () => {
|
|
1785
|
+
this.controlsBelowPlayer || this.hideControls();
|
|
1786
|
+
},
|
|
1787
|
+
onClose: () => {
|
|
1788
|
+
this.controlsBelowPlayer || this.videojs.controls(!0);
|
|
1789
|
+
}
|
|
1790
|
+
}), this.videoEl.parentElement.classList.add("has-vdt-menu"), this.addButtonToControlBar({
|
|
1791
|
+
onClick: () => {
|
|
1792
|
+
this.menu.toggle();
|
|
1793
|
+
},
|
|
1794
|
+
componentName: "SettingsMenuButton",
|
|
1795
|
+
className: "vdt-settings-menu-button",
|
|
1796
|
+
title: "Settings"
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
hideControls() {
|
|
1801
|
+
this.videojs.userActive(!1), this.videojs.controls(!1), this.videojs.fluid(!0), this.videoEl.parentElement.classList.remove("vjs-user-active"), this.videojs.userActive(!1);
|
|
1802
|
+
}
|
|
1803
|
+
showControls() {
|
|
1804
|
+
this.videojs.fluid(!this.controlsBelowPlayer), this.videojs.controls(!0), this.videojs.userActive(!0);
|
|
1805
|
+
}
|
|
1806
|
+
toggleControls() {
|
|
1807
|
+
this.videojs.controls() ? this.hideControls() : this.showControls();
|
|
1808
|
+
}
|
|
1809
|
+
onHotkeyPressed(e) {
|
|
1810
|
+
e !== "h" && this.help.state.active && this.help.hide();
|
|
1811
|
+
}
|
|
1812
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1813
|
+
triggerHotkey(e) {
|
|
1814
|
+
m.trigger(e);
|
|
1815
|
+
}
|
|
1816
|
+
toStart() {
|
|
1817
|
+
this.videojs.currentTime(0);
|
|
1818
|
+
}
|
|
1819
|
+
toEnd() {
|
|
1820
|
+
this.videojs.currentTime(this.videojs.duration());
|
|
1821
|
+
}
|
|
1822
|
+
replay() {
|
|
1823
|
+
this.toStart(), this.videojs.play();
|
|
1824
|
+
}
|
|
1825
|
+
play() {
|
|
1826
|
+
this.videojs.play();
|
|
1827
|
+
}
|
|
1828
|
+
pause() {
|
|
1829
|
+
this.videojs.paused() || this.videojs.pause();
|
|
1830
|
+
}
|
|
1831
|
+
togglePlayback() {
|
|
1832
|
+
this.videojs.paused() ? (this.play(), this.videojs.hasStarted_ && this.osd.feedback(l.osd.play)) : (this.pause(), this.osd.feedback(l.osd.pause));
|
|
1833
|
+
}
|
|
1834
|
+
updateSmpte(e) {
|
|
1835
|
+
const t = this.nodeNames.length - 1;
|
|
1836
|
+
let s;
|
|
1837
|
+
for (s = t; s > -1; s -= 1) {
|
|
1838
|
+
const o = this.nodeNames[s];
|
|
1839
|
+
if (typeof e[o] < "u" && e[o] !== parseInt(this.nodes[o].value, 10) && o !== this.state.selectedNode) {
|
|
1840
|
+
const i = e[o].toString();
|
|
1841
|
+
this.nodes[o].value = this.toDigitPairStr(i);
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
destroy() {
|
|
1846
|
+
this.videojs.paused(!0), this.rafID && cancelAnimationFrame(this.rafID), this.videojs.dispose(), this.unbindHotKeys(), this.seekBar && this.seekBar.destroy();
|
|
1847
|
+
}
|
|
1848
|
+
get container() {
|
|
1849
|
+
return this.videoEl.parentElement;
|
|
1850
|
+
}
|
|
1851
|
+
set onDark(e) {
|
|
1852
|
+
e ? this.container.classList.add("on-dark") : this.container.classList.remove("on-dark"), this.seekBar && (this.seekBar.onDark = e);
|
|
1853
|
+
}
|
|
1854
|
+
get onDark() {
|
|
1855
|
+
return this.container.classList.contains("on-dark");
|
|
1856
|
+
}
|
|
1857
|
+
set controlsBelowPlayer(e) {
|
|
1858
|
+
this.videojs.controls() && (e ? (this.container.classList.add("controls-below-player"), this.videojs.fluid(!1)) : (this.container.classList.remove("controls-below-player"), this.videojs.fluid(!0)));
|
|
1859
|
+
}
|
|
1860
|
+
get controlsBelowPlayer() {
|
|
1861
|
+
return this.container.classList.contains("controls-below-player");
|
|
1862
|
+
}
|
|
1863
|
+
get smpte() {
|
|
1864
|
+
const e = this.videojs.currentTime();
|
|
1865
|
+
return this.timeConverter.secondsFromStartToSMPTE(e);
|
|
1866
|
+
}
|
|
1867
|
+
set smpte(e) {
|
|
1868
|
+
this.updateSmpte(e);
|
|
1869
|
+
}
|
|
1870
|
+
set src({ src: e, type: t = "video/mp4", label: s = null }) {
|
|
1871
|
+
const o = this.videojs.currentTime(), i = this.props.sources.find((n) => n.src === e), r = () => {
|
|
1872
|
+
let n = !1;
|
|
1873
|
+
this.videojs.on("loadedmetadata", () => {
|
|
1874
|
+
this.videojs.currentTime(o);
|
|
1875
|
+
}), this.videojs.on("canplaythrough", () => {
|
|
1876
|
+
n || (this.videojs.currentTime(o), n = !0, this.videojs.play());
|
|
1877
|
+
});
|
|
1878
|
+
};
|
|
1879
|
+
i && Array.isArray(i) && i.length > 0 ? (this.videojs.addClass("vjs-waiting"), this.videojs.src({
|
|
1880
|
+
...i[0]
|
|
1881
|
+
}), r()) : (this.videojs.addClass("vjs-waiting"), this.videojs.src(this.addSrc(e, t, s)), r());
|
|
1882
|
+
}
|
|
1883
|
+
get src() {
|
|
1884
|
+
return this.videojs.src();
|
|
1885
|
+
}
|
|
1886
|
+
addSrc(e, t, s) {
|
|
1887
|
+
const o = {
|
|
1888
|
+
src: e,
|
|
1889
|
+
type: t,
|
|
1890
|
+
label: s
|
|
1891
|
+
}, i = this.props.sources.push(o) - 1;
|
|
1892
|
+
return this.props.sources[i];
|
|
1893
|
+
}
|
|
1894
|
+
// eslint-disable-next-line class-methods-use-this, no-unused-vars
|
|
1895
|
+
removeSrc(e) {
|
|
1896
|
+
}
|
|
1897
|
+
set controls(e) {
|
|
1898
|
+
e ? this.showControls() : this.hideControls();
|
|
1899
|
+
}
|
|
1900
|
+
get percentLoaded() {
|
|
1901
|
+
return this.videojs.buffered().end(0) / this.videojs.duration() * 100;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
const $ = v.prototype.constructor.getComponent("Button");
|
|
1905
|
+
$.prototype.handleKeyDown = function(c) {
|
|
1906
|
+
c.keyCode === 32 && c.preventDefault();
|
|
69
1907
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
devDependencies: devDependencies,
|
|
85
|
-
browserslist: browserslist,
|
|
86
|
-
eslintConfig: eslintConfig,
|
|
87
|
-
prettier: prettier
|
|
1908
|
+
v.prototype.constructor.registerComponent("Button", $);
|
|
1909
|
+
const ue = v.prototype.constructor.getComponent("SubsCapsButton");
|
|
1910
|
+
class me extends ue {
|
|
1911
|
+
constructor(e, t = {}) {
|
|
1912
|
+
super(e, t), this.menuButton_.off("mouseenter"), this.menuButton_.off("mouseleave");
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
v.prototype.constructor.registerComponent("SubsCapsButton", me);
|
|
1916
|
+
export {
|
|
1917
|
+
ie as ExternalControls,
|
|
1918
|
+
be as Player,
|
|
1919
|
+
L as SeekBar,
|
|
1920
|
+
N as TimeCodeDisplay,
|
|
1921
|
+
he as VideoTime
|
|
88
1922
|
};
|
|
89
|
-
|
|
90
|
-
const defaults=Object.freeze({frameRate:30000/1001,jumpSeconds:10,inactivityTimeout:1200,
|
|
91
|
-
audioInactivityTimeout:0});const osd=Object.freeze({play:0,pause:1,volchange:2,jumpForward:3,jumpBackward:4});const settings=Object.freeze({volume:'volume-setting',subLang:'subtitles-language',subs:'subtitles-enabled'});const classNames=Object.freeze({poster:'has-poster',subtitles:'has-subtitles',subtitlesActive:'subtitles-active',onDark:'on-dark',loading:'loading'});const colors=Object.freeze({gray:'#787878',light:'rgba(255,255,255,.75)'});const packageInfo=Object.freeze({name:pkgInfo.name.split('/')[1],vendor:pkgInfo.name.split('/')[0]});const constants$2=Object.freeze({defaults,settings,classNames,colors,osd,packageInfo});
|
|
92
|
-
|
|
93
|
-
function truncate(input,len){if(input.length>len)return "".concat(input.substring(0,len),"...");return input;}
|
|
94
|
-
function reactiveSetters(){
|
|
95
|
-
function handleNewProps(props){if(typeof props==='object'){const keys=Object.getOwnPropertyNames(props);const proto=Object.getPrototypeOf(this);keys.forEach(key=>{
|
|
96
|
-
const descriptor=Object.getOwnPropertyDescriptor(proto,key);if(descriptor&&descriptor.set){
|
|
97
|
-
this[key]=props[key];}});}}
|
|
98
|
-
this.handleNewProps=handleNewProps;}
|
|
99
|
-
function sanitize(str){const temp=document.createElement('div');temp.textContent=str;return temp.innerHTML;}
|
|
100
|
-
|
|
101
|
-
const buttonNames=Object.freeze({play:'play-pause',start:'start',fb:'frame-backward',ff:'frame-forward',end:'end'});const buttons=[
|
|
102
|
-
buttonNames.start,buttonNames.fb,buttonNames.play,buttonNames.ff,buttonNames.end];
|
|
103
|
-
const CSS$2="\n .vdt-external-controls{\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .control{\n flex: 1;\n flex-grow: 1;\n height: 100%;\n align-contents: center;\n align-self: center;\n text-align: center;\n vertical-align: middle;\n cursor: pointer;\n user-select: none;\n height: 20px;\n padding-top: 10px;\n padding-bottom: 10px;\n }\n\n .control .icon{\n display: inline-block;\n height: 20px;\n white-space: nowrap;\n opacity: .9;\n }\n\n .control:hover .icon{ opacity: 1; }\n\n .control .icon:before{\n opacity: 1;\n flex: 1;\n align-self: center;\n content: \" \";\n display: inline-block;\n margin: 0 auto;\n\n /* triangles */\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 16px 0 16px 23px;\n border-color: transparent transparent transparent ".concat(colors.gray,";\n }\n\n .vdt-external-controls.").concat(classNames.onDark," .control .icon:before{\n border-color: transparent transparent transparent ").concat(colors.light,";\n }\n\n /* specific buttons */\n\n .control.").concat(buttonNames.start,",\n .control.").concat(buttonNames.end,"{\n height: 20px;\n }\n\n .control.").concat(buttonNames.play,"{\n height: 30px;\n padding-top: 0px;\n padding-bottom: 0px;\n }\n\n .control.").concat(buttonNames.play," .icon{\n height: 30px;\n }\n\n .control.").concat(buttonNames.ff," .icon:before,\n .control.").concat(buttonNames.fb," .icon:before,\n .control.").concat(buttonNames.end," .icon:before,\n .control.").concat(buttonNames.start," .icon:before{\n border-width: 10px 0 10px 16px;\n }\n\n .control.").concat(buttonNames.fb," .icon,\n .control.").concat(buttonNames.start,"{\n transform: rotate(180deg);\n }\n\n .control.").concat(buttonNames.end," .icon:after,\n .control.").concat(buttonNames.start," .icon:after{\n content: \" \";\n width: 4px;\n height: 20px;\n display: inline-block;\n background: ").concat(colors.gray,";\n }\n\n .vdt-external-controls.").concat(classNames.onDark," .control.").concat(buttonNames.end," .icon:after,\n .vdt-external-controls.").concat(classNames.onDark," .control.").concat(buttonNames.start," .icon:after{\n background: ").concat(colors.light,";\n }\n\n /* stateful styles */\n .control.").concat(buttonNames.play,".playing .icon:before{\n height: 30px;\n width: 6px;\n border-width: 0px 8px 0px 8px;\n border-color: transparent ").concat(colors.gray," transparent ").concat(colors.gray,";\n }\n\n .vdt-external-controls.").concat(classNames.onDark," .control.").concat(buttonNames.play,".playing .icon:before{\n border-color: transparent ").concat(colors.light," transparent ").concat(colors.light,";\n }\n\n .vdt-external-controls.").concat(classNames.loading," .control.").concat(buttonNames.play,"{\n border-color: transparent #f00 transparent #f00;\n }\n");class ExternalControls{constructor(props){this.props=props;reactiveSetters.apply(this);this.state={playing:false,onDark:false,loading:false};this.shadowRoot=document.createElement('div');
|
|
104
|
-
this.shadowRoot.className='vdt-external-controls-wrapper';this.container=document.createElement('div');this.container.className='vdt-external-controls';if(this.props.target){this.props.target.appendChild(this.shadowRoot);this.shadow=this.shadowRoot.attachShadow({mode:'open'});
|
|
105
|
-
this.style=document.createElement('style');this.style.type='text/css';this.style.appendChild(document.createTextNode(CSS$2));this.shadow.appendChild(this.style);
|
|
106
|
-
this.shadow.appendChild(this.container);}this.handleNewProps(props);this.bindEvents();this.draw();}draw(){this.buttons={};
|
|
107
|
-
const excludes=this.props.excludes||[];buttons.forEach(buttonName=>{if(excludes.indexOf(buttonName)<0){const btn=document.createElement('div');btn.className="control ".concat(buttonName);btn.innerHTML='<span class="icon"></span>';btn.onclick=()=>{this.handlePress(buttonName);};this.buttons[buttonName]=btn;this.container.appendChild(btn);}});}
|
|
108
|
-
bindEvents(){if(this.props.player&&this.props.player.videojs){const{player}=this.props;player.videojs.on('play',()=>{this.playing=true;});player.videojs.on('pause',()=>{this.playing=false;});player.videojs.on('stop',()=>{this.playing=false;});}}handlePress(buttonName){if(this.props.player){
|
|
109
|
-
const{player}=this.props;if(player.osd)player.osd.disable();
|
|
110
|
-
switch(buttonName){case buttonNames.start:player.toStart();break;case buttonNames.fb:player.triggerHotkey('left');break;case buttonNames.play:player.triggerHotkey('k');
|
|
111
|
-
break;case buttonNames.ff:player.triggerHotkey('right');break;case buttonNames.end:player.toEnd();break;}if(player.osd)player.osd.enable();
|
|
112
|
-
}else {switch(buttonName){case buttonNames.start:if(this.props.onPrev)this.props.onPrev();break;case buttonNames.fb:if(this.props.onFB)this.props.onFB();break;case buttonNames.play:if(this.playing){if(this.props.onPause)this.props.onPause();}else if(this.props.onPlay)this.props.onPlay();break;case buttonNames.ff:if(this.props.onFF)this.props.onFF();break;case buttonNames.end:if(this.props.onNext)this.props.onNext();break;}}}
|
|
113
|
-
set playing(bool){if(bool){this.state.playing=true;this.buttons[buttonNames.play].classList.add('playing');}else {this.state.playing=false;this.buttons[buttonNames.play].classList.remove('playing');}}get playing(){return this.state.playing;}set onDark(bool){if(bool){this.state.onDark=true;this.container.classList.add(classNames.onDark);}else {this.state.onDark=false;this.container.classList.remove(classNames.onDark);}}get onDark(){return this.container.classList.contains(classNames.onDark);}set loading(bool){if(bool){this.state.loading=true;this.container.classList.add(classNames.loading);}else {this.state.loading=false;this.container.classList.remove(classNames.loading);}}get loading(){return this.state.loading;}}ExternalControls.buttonNames=buttonNames;
|
|
114
|
-
|
|
115
|
-
class HelpOverlay{constructor(props){this.props=props;this.state={active:this.props.active||false};this.container=document.createElement('div');this.container.className='vdt-help-overlay';this.container.innerHTML='';this.container.onclick=()=>{this.hide();};if(this.props.target)this.props.target.appendChild(this.container);this.draw();}draw(){
|
|
116
|
-
let tableRowMarkup='';
|
|
117
|
-
const rows=[['⎵','Play / Pause'],['⇧','Increase volume '],['⇩','Decrease volume'],['⇨','Step frame forward'],['⇦','Step frame backward'],['M','Mute / Unmute'],['J','Seek 10 seconds backward'],['K','Play / Pause'],['L','Seek 10 seconds forward'],['C','Toggle subtitles'],['N','Toggle settings menu'],['H','Toggle this help overlay']];
|
|
118
|
-
const halfpointIndex=Math.round(rows.length/2);const columns=[rows.slice(0,halfpointIndex),rows.slice(halfpointIndex,rows.length)];
|
|
119
|
-
for(let i=0;i<halfpointIndex;i+=1){tableRowMarkup+="\n <tr>\n <td><div>".concat(columns[0][i][0],"</div></td>\n <td>- ").concat(columns[0][i][1],"</td>\n\n <td>").concat(columns[1][i]?"<div>".concat(columns[1][i][0],"</div>"):'',"</td>\n <td>").concat(columns[1][i]?"- ".concat(columns[1][i][1]):'',"</td>\n </tr>\n ");}
|
|
120
|
-
this.container.innerHTML="\n <table>\n <tbody>\n <tr>\n <td class=\"vdt-help-contents\">\n <table><tbody>".concat(tableRowMarkup,"</tbody></table>\n </td>\n </tr>\n </tbody>\n </table>\n ");}show(){if(!this.state.active){this.container.classList.add('active');this.state.active=true;mousetrap__default["default"].bind('esc',()=>{this.hide();});if(this.props.onToggle)this.props.onToggle(true);}}hide(){if(this.state.active){this.container.classList.remove('active');this.state.active=false;mousetrap__default["default"].unbind('esc');if(this.props.onToggle)this.props.onToggle(false);}}toggle(){if(this.state.active){this.hide();}else {this.show();}}}
|
|
121
|
-
|
|
122
|
-
function ownKeys$1(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread$1(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys$1(Object(source),!0).forEach(function(key){_defineProperty__default["default"](target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys$1(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}const constants$1=Object.freeze({className:'vdt-menu',menuClassName:'menu',subLvlClassName:'sub-level',menuItemClassName:'menu-item',animationLength:300,defaults:{bgColor:'rgba(0,0,0,.8)',textColor:'#999',textColorDark:'#333',textColorLight:'rgba(255,255,255)',bgColorLight:'rgba(255,255,255,.2)',bgColorSelected:'rgba(255,255,255,.1)'}});const CSS$1=()=>"\n .".concat(constants$1.menuClassName,"{\n position: relative;\n height: 100%;\n width: 200%;\n // min-width: 200px;\n right: 0px;\n bottom: 0px;\n background: ").concat(constants$1.defaults.bgColor,";\n z-index: 1px;\n transform: translate3d(100%, 0px, 0px);\n transition: all 300ms ease-in-out;\n box-shadow: 0px 0px 30px rgb;\n -webkit-backdrop-filter: blur(10px);\n overflow: hidden;\n }\n\n .").concat(constants$1.menuClassName," .level-1{\n float: left;\n }\n\n .").concat(constants$1.menuClassName," div h3{\n padding: 16px 24px;\n font-size: 12px;\n border-bottom: 1px solid ").concat(constants$1.defaults.bgColorLight,"\n }\n\n .").concat(constants$1.menuClassName," .level-2 h3{\n cursor: pointer;\n position: relative;\n }\n .").concat(constants$1.menuClassName," .level-2 h3:before{\n content: '\u25C2';\n margin-left: -12px;\n width: 12px;\n display: inline-block;\n position: absolute;\n margin-top: -1px;\n }\n\n .").concat(constants$1.menuClassName," .level-1,\n .").concat(constants$1.menuClassName," .level-2{\n transform: translate3d(0px, 0px, 0px);\n transition: all 300ms ease-in-out;\n width: 50%;\n height: 100%;\n float: left;\n }\n\n .").concat(constants$1.menuClassName,".sub-level .level-1,\n .").concat(constants$1.menuClassName,".sub-level .level-2{\n transform: translate3d(-100%, 0px, 0px);\n }\n\n .").concat(constants$1.menuClassName," table{\n border-collapse: collapse;\n width: 100%;\n }\n\n .").concat(constants$1.menuClassName,".open{\n transform: translate3d(0px, 0px, 0px);\n }\n\n .").concat(constants$1.menuClassName," tr{\n cursor: pointer;\n height: 40px;\n }\n\n .").concat(constants$1.menuClassName," tr.selected{\n background: ").concat(constants$1.defaults.bgColorSelected,";\n }\n\n\n .").concat(constants$1.menuClassName," tr td{\n color: white;\n font-size: 15px;\n vertical-align: middle;\n }\n\n \n .").concat(constants$1.menuClassName," tr:hover td{\n color: white;\n background: ").concat(constants$1.defaults.bgColorLight,";\n }\n\n .").concat(constants$1.menuClassName," tr td.title{\n padding-top: 12px;\n padding-bottom: 12px;\n font-weight: 300;\n font-family: Helvetica, Arial, sans-serif; \n }\n\n .").concat(constants$1.menuClassName," tr td.caret{\n font-size: 12px;\n }\n\n .").concat(constants$1.menuClassName," tr td:first-child{\n padding-left: 24px;\n }\n\n .").concat(constants$1.menuClassName," tr td:last-child{\n padding-right: 16px;\n }\n\n .").concat(constants$1.menuClassName," tr.has-items td:last-child{\n text-align: right;\n }\n\n .").concat(constants$1.menuClassName," tr.has-items td.subtitle{\n font-size: 12px;\n text-align: right;\n color: ").concat(constants$1.defaults.textColorLight,";\n }\n");class MenuDisplayItem{constructor(props){this.props=props;const classNames=[constants$1.menuItemClassName,this.props.items&&'has-items',this.props.selected&&'selected'];this.container=document.createElement('tr');this.container.className=classNames.join(' ');if(this.props.target)this.props.target.appendChild(this.container);
|
|
123
|
-
this.container.onclick=event=>{if(this.props.onClick)this.props.onClick(event);};this.render();}render(){if(this.props.items){
|
|
124
|
-
this.container.innerHTML="\n <td class=\"title\"></td>\n <td class=\"subtitle\"></td>\n <td class=\"caret\">\u25B7</td>\n ";}else {this.container.innerHTML="\n <td class=\"title\"></td>\n ";}const titleNode=this.container.getElementsByClassName('title')[0];const subtitleNode=this.props.items?this.container.getElementsByClassName('subtitle')[0]:false;titleNode.textContent=this.props.title;if(subtitleNode)subtitleNode.textContent=this.props.subtitle;}}class Menu{constructor(props){this.props=props;this.container=document.createElement('div');this.container.className="".concat(constants$1.className);this.state={opened:false,selectedItem:0,items:[],subItems:[]};this.mount();this.draw();}mount(){
|
|
125
|
-
if(this.props.target){
|
|
126
|
-
this.container.style.position='absolute';this.container.style.bottom=this.container.style.right='0px';this.container.style.height='100%';this.container.style.overflow='hidden';this.container.style.width='30%';this.container.style.minWidth='250px';this.container.style.maxWidth='320px';
|
|
127
|
-
this.shadow=this.container.attachShadow({mode:'open'});if(this.props.target)this.props.target.appendChild(this.container);
|
|
128
|
-
this.menuContainer=document.createElement('div');this.menuContainer.className='menu';this.shadow.appendChild(this.menuContainer);
|
|
129
|
-
this.style=document.createElement('style');this.style.type='text/css';this.style.innerHTML=CSS$1();this.shadow.appendChild(this.style);}}draw(){
|
|
130
|
-
const mainDiv=document.createElement('div');mainDiv.className='level-1';this.mainLevel=document.createElement('table');mainDiv.innerHTML='<h3>Settings</h3>';mainDiv.appendChild(this.mainLevel);const subDiv=document.createElement('div');subDiv.className='level-2';this.subLvlTitle=document.createElement('h3');this.subLvlTitle.onclick=()=>{this.up();};subDiv.appendChild(this.subLvlTitle);this.secondaryLevel=document.createElement('table');subDiv.appendChild(this.secondaryLevel);this.menuContainer.appendChild(mainDiv);this.menuContainer.appendChild(subDiv);this.props.items.forEach(menuItem=>{
|
|
131
|
-
const activeTitle=menuItem.items[menuItem.getActiveIndex(menuItem.items)].title||'';const displayItem=new MenuDisplayItem(_objectSpread$1({target:this.mainLevel,subtitle:activeTitle,onClick:()=>{this.handleSupItemSelected(menuItem);}},menuItem));this.state.items.push(displayItem);});}open(){this.render();this.menuContainer.classList.add('open');if(this.props.onOpen)this.props.onOpen();this.state.opened=true;
|
|
132
|
-
if(!this.handleClicksWhenMenuOpened){
|
|
133
|
-
this.handleClicksWhenMenuOpened=function(event){if(this.state.opened){event.stopPropagation();const isClickInside=this.container.contains(event.target);if(!isClickInside){this.close();}}}.bind(this);}this.handleClicksWhenMenuOpenedTimeout=setTimeout(()=>{document.addEventListener('click',this.handleClicksWhenMenuOpened);mousetrap__default["default"].bind('esc',this.close.bind(this));
|
|
134
|
-
},constants$1.animationLength);}close(){this.menuContainer.classList.remove('open');this.state.opened=false;if(this.handleClicksWhenMenuOpenedTimeout)clearTimeout(this.handleClicksWhenMenuOpenedTimeout);document.removeEventListener('click',this.handleClicksWhenMenuOpened);if(this.props.onClose)this.props.onClose();mousetrap__default["default"].unbind('esc');}toggle(){if(this.state.opened){this.close();}else {this.open();}}up(){
|
|
135
|
-
this.menuContainer.classList.remove(constants$1.subLvlClassName);this.render();}handleSupItemSelected(item){this.subLvlTitle.textContent=item.title;this.renderSubItems(item.items,item.getActiveIndex(item.items));this.menuContainer.classList.add(constants$1.subLvlClassName);}renderSubItems(items){let activeIndex=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;this.secondaryLevel.innerHTML='';const subItemRefs=[];items.forEach((menuItem,index)=>{const displayItem=new MenuDisplayItem(_objectSpread$1(_objectSpread$1({target:this.secondaryLevel},menuItem),{},{onClick:event=>{this.handleSubItemSelected(event,menuItem);},selected:index===activeIndex
|
|
136
|
-
}));subItemRefs.push(displayItem);});this.state.subItems=subItemRefs;}handleSubItemSelected(event,item){this.close();if(item.onClick)item.onClick(event,item);this.up();}get opened(){return this.state.opened;}set opened(bool){this.state.opened=bool;}render(){
|
|
137
|
-
this.state.items.forEach((menuDisplayItem,index)=>{const{items}=this.props;const activeIndex=items[index].getActiveIndex(items[index].items);const activeTitle=items[index].items[activeIndex].title;menuDisplayItem.props.subtitle=activeTitle;menuDisplayItem.render();});}}
|
|
138
|
-
|
|
139
|
-
class OSD{constructor(props){this.props=props;this.state={enabled:true};this.container=document.createElement('div');this.container.className='vdt-player-osd';
|
|
140
|
-
this.container.innerHTML="\n <table>\n <tbody>\n <td>\n <div class=\"osd-feedback-icon\"></div>\n </td>\n </tbody>\n </table>\n ";
|
|
141
|
-
this.iconEl=this.container.getElementsByClassName('osd-feedback-icon')[0];if(this.props.target)this.props.target.appendChild(this.container);}feedback(feedbackType){let details=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;
|
|
142
|
-
if(!this.state.enabled){return;}let className;switch(feedbackType){case osd.pause:className='pause';break;case osd.play:className='play';break;case osd.volchange:
|
|
143
|
-
const currentVolumeLevel=details.volume;
|
|
144
|
-
let perceivedVolumeLevel;
|
|
145
|
-
if(currentVolumeLevel===0){perceivedVolumeLevel='null';}else if(currentVolumeLevel>0.65){perceivedVolumeLevel='high';}else if(currentVolumeLevel<0.35){perceivedVolumeLevel='low';}else {perceivedVolumeLevel='mid';}className="volchange ".concat(perceivedVolumeLevel);break;case osd.jumpForward:className='forward-jump';break;case osd.jumpBackward:className='backward-jump';break;}if(this.osdTimeout){
|
|
146
|
-
this.container.classList.remove('active');clearTimeout(this.osdTimeout);}
|
|
147
|
-
this.container.classList.add('active');this.osdTimeout=setTimeout(()=>{this.container.classList.remove('active');},200);
|
|
148
|
-
this.iconEl.className="osd-feedback-icon ".concat(className);
|
|
149
|
-
}disable(){this.state.enabled=false;}enable(){this.state.enabled=true;}}
|
|
150
|
-
|
|
151
|
-
const constants=Object.freeze({className:'vdt-seekbar',defaults:{bgColor:'#fafafa',fillColor:'#f00',regionColor:'#f6e58d',
|
|
152
|
-
markerWidth:16,regionAccentColor:'#00a8ff',transitionTime:300
|
|
153
|
-
},markerTypes:{in:'in',out:'out'}});const CSS=(bgColor,fillColor)=>"\n .".concat(constants.className,"{\n user-select: none;\n background: ").concat(colors.light,";\n height: 6px;\n width: 100%;\n position: relative;\n cursor: pointer;\n z-index: 5;\n }\n\n .").concat(classNames.onDark,".").concat(constants.className,"{\n background: ").concat(colors.gray,";\n }\n\n .fill, .load-indicator{\n height: 100%;\n display: inline-block;\n position: absolute;\n left: 0px;\n top: 0px;\n background: ").concat(fillColor,";\n transition: width ").concat(constants.defaults.transitionTime,"ms linear;\n z-index: 2;\n }\n\n .load-indicator{\n background: #e1e1e1;\n z-index: 1;\n opacity: .2;\n transition: none;\n }\n\n .").concat(classNames.onDark,".").concat(constants.className," .load-indicator{\n background: white;\n }\n\n .").concat(constants.className,".dragging .fill{\n transition: none;\n }\n\n\n .marker, .region{\n position: absolute;\n top: 0px;\n height: 100%;\n background: cyan;\n width: 1px;\n display: inline-block;\n z-index: 4;\n }\n\n .marker{\n transition: opacity ").concat(constants.defaults.transitionTime,"ms linear;\n }\n\n .marker{ display: none; }\n .marker.active{ display: initial; }\n\n .marker .handle{\n position: absolute;\n bottom: 10px; right: 0px;\n width: ").concat(constants.defaults.markerWidth,"px;\n height: 28px;\n background: #999;\n border-radius: 3px;\n cursor: col-resize;\n z-index: 3;\n box-sizing: border-box;\n }\n\n .marker.regional .handle{\n background: ").concat(constants.defaults.regionAccentColor,";\n box-shadow: -2px 1px 1px rgba(0,0,0,.1);\n }\n\n .marker.regional.in .handle{\n box-shadow: 2px 1px 1px rgba(0,0,0,.1);\n }\n\n .marker.in .handle{\n border-bottom-left-radius: 40px;\n }\n\n .marker.out .handle{\n left: 1px;\n right: initial;\n border-bottom-right-radius: 20px;\n }\n\n .handle:active{\n background: ").concat(constants.defaults.regionColor,";\n }\n\n .region{\n position: absolute;\n width: auto;\n background: ").concat(constants.defaults.regionColor,";\n opacity: .7;\n }\n\n .region.nav{\n background: transparent;\n opacity: 1;\n border-left: 1px solid cyan;\n }\n\n .region.nav .bubble,\n .region.nav:after{\n content: \" \";\n height: 16px;\n bottom: 10px;\n width: 16px;\n border-radius: 16px;\n background: ").concat(constants.defaults.regionAccentColor,";\n position: absolute;\n margin-left: -8px;\n transition: transform 200ms ease-out;\n transform: translate3d(0px, 0px, 0px);\n transform-origin: bottom center;\n }\n\n .region.nav .popout{\n width: 160px;\n z-index: 4;\n background: rgba(28, 28, 28, .7);\n color: white;\n font-size: 14px;\n min-height: 100px;\n bottom: 16px;\n left: -80px;\n position: absolute;\n border-radius: 8px;\n -webkit-backdrop-filter: blur(10px);\n font-family: Arial, Helvetica, sans-serif;\n overflow: hidden;\n opacity: 0;\n visibility: hidden;\n }\n\n .region.nav.right-aligned .popout{\n right: 0px;\n left: initial;\n }\n\n .region.nav.left-aligned .popout{\n left: -32px;\n } \n\n .region.nav .popout .title{\n padding: 4px 14px;\n text-align: center;\n color: black;\n background: white;\n }\n\n .region.nav .popout .annotation{\n padding: 8px 12px;\n font-weight: light;\n color: rgba(255,255,255,.9);\n }\n\n .region.nav:after{\n width: 1px;\n left: 8px;\n height: 10px;\n bottom: 0px;\n background: #00a8ff;\n }\n\n .region.nav:hover{\n background: rgba(28, 28, 28, .5);\n }\n\n .region.nav.has-popout:hover .bubble{\n background: rgba(28, 28, 28, .8);\n opacity: 1;\n z-index: 3;\n }\n\n .region.nav:hover:after,\n .region.nav:hover:before{\n background: rgba(28, 28, 28, .8);\n }\n\n .region.nav:hover .popout{\n opacity: 1;\n visibility: visible;\n }\n\n .").concat(constants.className,".dragging .bubble{\n transform: scale3d(.75,.75,.75);\n }\n\n .").concat(constants.className,".hide-markers .marker{\n opacity: 0;\n }\n\n");class Region{constructor(props){const regionDefaultProps={in:null,out:null,title:'',annotation:'',el:null
|
|
154
|
-
};Object.assign(this,regionDefaultProps,props);
|
|
155
|
-
}}class SeekBar{constructor(props){this.props=props;reactiveSetters.apply(this);
|
|
156
|
-
this.container=document.createElement('div');this.container.className="".concat(constants.className,"-wrapper");this.state={in:null,
|
|
157
|
-
out:null,markersEnabled:this.props.markersEnabled===undefined?true:this.props.markersEnabled,regions:[],
|
|
158
|
-
dragging:false};this.markers={};if(this.props.target){this.shadow=this.container.attachShadow({mode:'open'});this.props.target.appendChild(this.container);
|
|
159
|
-
this.style=document.createElement('style');this.style.type='text/css';
|
|
160
|
-
const bgColor=this.props.bgColor?this.props.bgColor:constants.defaults.bgColor;const fillColor=this.props.fillColor?this.props.fillColor:constants.defaults.fillColor;this.style.innerHTML=CSS(sanitize(bgColor),sanitize(fillColor));this.shadow.appendChild(this.style);}this.bindEvents();this.draw();this.bindHotkeys();
|
|
161
|
-
const{player}=this.props;if(player){player.videojs.on('loadedmetadata',()=>{this.handleNewProps(this.props);});}}
|
|
162
|
-
bindEvents(){
|
|
163
|
-
if(this.props.player){const{player}=this.props;player.videojs.on('timeupdate',()=>{const progressFraction=player.videojs.currentTime()/player.videojs.duration();this.fill.style.width="".concat(100*progressFraction,"%");});player.videojs.on('progress',()=>{this.percentLoaded=player.percentLoaded;});}}bindHotkeys(){this.bindings=[];
|
|
164
|
-
if(this.props.player){const{player}=this.props;this.bindings=[{key:['i'],method:()=>{if(this.markersEnabled)this.in=player.videojs.currentTime();}},{key:['o'],method:()=>{if(this.markersEnabled)this.out=player.videojs.currentTime();}},{key:['shift+i'],method:()=>{if(this.markersEnabled)this.navigateToIn();}},{key:['shift+o'],method:()=>{if(this.markersEnabled)this.navigateToOut();}}];}if(this.props.player){const{player}=this.props;mousetrap__default["default"].bind('i',()=>{if(this.markersEnabled)this.in=player.videojs.currentTime();});mousetrap__default["default"].bind('o',()=>{if(this.markersEnabled)this.out=player.videojs.currentTime();});mousetrap__default["default"].bind('shift+i',()=>{if(this.markersEnabled)this.navigateToIn();});mousetrap__default["default"].bind('shift+o',()=>{if(this.markersEnabled)this.navigateToOut();});}
|
|
165
|
-
this.bindings.forEach(binding=>{mousetrap__default["default"].bind(binding.key,e=>{binding.method(e);});});}unbindHotKeys(){this.bindings&&this.bindings.forEach(binding=>{mousetrap__default["default"].unbind(binding.key);});}handleSeek(event){
|
|
166
|
-
if(this.props.player){const{player}=this.props;if(this.state.regions){let clickedOnRegion=false;let preventSeek=false;
|
|
167
|
-
this.state.regions.forEach(region=>{if(region.el.contains(event.target)){
|
|
168
|
-
if(this.props.onRegionClick){preventSeek=this.props.onRegionClick(region);if(!preventSeek){player.seekTo(region.in);}}else {player.seekTo(region.in);}clickedOnRegion=true;}});
|
|
169
|
-
if(clickedOnRegion)return;}const seekFractionX=(event.clientX-this.bar.getBoundingClientRect().left)/this.bar.offsetWidth;
|
|
170
|
-
const timeToSeek=seekFractionX*player.videojs.duration();
|
|
171
|
-
player.seekTo(timeToSeek);}
|
|
172
|
-
}handleSeekDrag(mouseDownEvent){const barOffset=this.bar.getBoundingClientRect().left;
|
|
173
|
-
const barWidth=this.bar.getBoundingClientRect().width;
|
|
174
|
-
const duration=this.props.player.videojs.duration();
|
|
175
|
-
let left;const drag=e=>{left=e.clientX-barOffset;const pxDragged=Math.abs(mouseDownEvent.clientX-e.clientX);if(left>=0&&left<barWidth&&pxDragged>1){
|
|
176
|
-
this.dragging=true;const fractionFromStart=parseFloat(left)/barWidth;const seconds=fractionFromStart*duration;this.props.player.videojs.currentTime(seconds);}e.preventDefault();};const stopDrag=e=>{this.dragging=false;
|
|
177
|
-
document.removeEventListener('mousemove',drag,false);document.removeEventListener('mouseup',stopDrag,false);const fractionFromStart=parseFloat(left)/barWidth;const seconds=fractionFromStart*duration;this.props.player.videojs.currentTime(seconds);e.stopPropagation();};
|
|
178
|
-
document.addEventListener('mousemove',drag,false);document.addEventListener('mouseup',stopDrag,false);}draw(){this.bar=document.createElement('div');this.bar.className=constants.className;this.bar.onclick=e=>{if(!e.target.classList.contains('marker')&&!e.target.classList.contains('handle')){this.handleSeek(e);}};
|
|
179
|
-
this.bar.addEventListener('mousedown',e=>{e.preventDefault();
|
|
180
|
-
if(!this.dragging){
|
|
181
|
-
this.handleSeekDrag(e);}},false);this.fill=document.createElement('div');this.fill.className='fill';this.loadIndicator=document.createElement('div');this.loadIndicator.className='load-indicator';this.region=document.createElement('div');this.region.className='region';this.bar.appendChild(this.fill);this.bar.appendChild(this.loadIndicator);this.bar.appendChild(this.region);this.shadow.appendChild(this.bar);this.drawMarkers();}drawMarkers(){
|
|
182
|
-
if(this.markersEnabled){const markerIn=this.markers[constants.markerTypes.in]=document.createElement('div');const markerOut=this.markers[constants.markerTypes.out]=document.createElement('div');markerIn.className="marker ".concat(constants.markerTypes.in);markerOut.className="marker ".concat(constants.markerTypes.out);const handleIn=document.createElement('div');const handleOut=document.createElement('div');handleIn.className=handleOut.className='handle';handleIn.addEventListener('mousedown',e=>{e.preventDefault();
|
|
183
|
-
e.stopPropagation();
|
|
184
|
-
this.handleMarkerDrag(markerIn,constants.markerTypes.in,e);},false);handleOut.addEventListener('mousedown',e=>{e.preventDefault();
|
|
185
|
-
e.stopPropagation();
|
|
186
|
-
this.handleMarkerDrag(markerOut,constants.markerTypes.out,e);},false);markerIn.appendChild(handleIn);markerOut.appendChild(handleOut);this.bar.appendChild(markerIn);this.bar.appendChild(markerOut);}}updateMarkers(marker){this.markers[marker.type].style.left="".concat(marker.value*100,"%");this.markers[marker.type].classList.add('active');
|
|
187
|
-
if(this.state.regions){
|
|
188
|
-
const matchingRegions=[];const isRegional=matchingRegions.length>0;if(isRegional){this.markers[marker.type].classList.add('regional');}else {this.markers[marker.type].classList.remove('regional');}}this.drawInAndOutRegion();}drawInAndOutRegion(){
|
|
189
|
-
if(this.state.in!==null&&this.state.out!==null){this.region.style.left=this.markers[constants.markerTypes.in].style.left;this.region.style.right="".concat(100-parseFloat(this.markers[constants.markerTypes.out].style.left.replace('%','')),"%");}}
|
|
190
|
-
handleMarkerDrag(markerNode,type,mouseDownEvent){
|
|
191
|
-
const barOffset=this.bar.getBoundingClientRect().left;
|
|
192
|
-
const barWidth=this.bar.getBoundingClientRect().width;
|
|
193
|
-
const duration=this.props.player.videojs.duration();
|
|
194
|
-
let dragHappened=false;const drag=e=>{const pxDragged=Math.abs(mouseDownEvent.clientX-e.clientX);const markerOffset=type===constants.markerTypes.in?constants.defaults.markerWidth/2:-(constants.defaults.markerWidth/2);const left=e.clientX-barOffset+markerOffset;if(left>=0&&left<barWidth&&pxDragged>1){
|
|
195
|
-
dragHappened=this.dragging=true;markerNode.style.left="".concat(left,"px");markerNode.classList.add('active');const fractionFromStart=parseFloat(markerNode.getBoundingClientRect().left-barOffset)/barWidth;const seconds=fractionFromStart*duration;this.props.player.videojs.currentTime(seconds);}e.preventDefault();};const stopDrag=e=>{this.dragging=false;
|
|
196
|
-
document.removeEventListener('mousemove',drag,false);document.removeEventListener('mouseup',stopDrag,false);const fractionFromStart=parseFloat(markerNode.getBoundingClientRect().left-barOffset)/barWidth;const seconds=fractionFromStart*duration;this[type]=seconds;this.props.player.videojs.currentTime(seconds);
|
|
197
|
-
if(!dragHappened){if(type===constants.markerTypes.in){this.navigateToIn();}else {this.navigateToOut();}}this.props.onDragFinish&&this.props.onDragFinish({type,seconds});e.stopPropagation();};
|
|
198
|
-
document.addEventListener('mousemove',drag,false);document.addEventListener('mouseup',stopDrag,false);}
|
|
199
|
-
cleanupMarkers(){let removedMarker=false;if(this.state.in===null){this.markers[constants.markerTypes.in].classList.remove('active');removedMarker=true;}if(this.state.out===null){this.markers[constants.markerTypes.out].classList.remove('active');removedMarker=true;}if(removedMarker){
|
|
200
|
-
this.region.style.left='initial';this.region.style.right='initial';}}clearMarkers(){this.in=null;this.out=null;}
|
|
201
|
-
setInFromCurrent(){this.in=this.props.player.videojs.currentTime();}setOutFromCurrent(){this.out=this.props.player.videojs.currentTime();}navigateToIn(){const{player}=this.props;player.seekTo(this.in);}navigateToOut(){const{player}=this.props;player.seekTo(this.out);}
|
|
202
|
-
set in(val){if(!this.state.markersEnabled)return;this.state.in=val;if(val!==null&&val!==undefined){const{player}=this.props;this.updateMarkers({type:constants.markerTypes.in,value:val/player.videojs.duration()});
|
|
203
|
-
if(this.state.out!==null&&val>this.state.out){this.out=null;}this.props.onIn&&this.props.onIn(this.state.in);}else {this.cleanupMarkers();}}get in(){return this.state.in;}set out(val){if(!this.state.markersEnabled)return;this.state.out=val;if(val!==null&&val!==undefined){const{player}=this.props;this.updateMarkers({type:constants.markerTypes.out,value:val/player.videojs.duration()});
|
|
204
|
-
if(this.state.in!=null&&val<this.state.in){this.in=null;}this.props.onOut&&this.props.onOut(this.state.out);}else {this.cleanupMarkers();}}get out(){return this.state.out;}get markersEnabled(){return this.state.markersEnabled;}set markersEnabled(bool){if(typeof bool==='boolean'){if(!bool){this.clearMarkers();this.state.markersEnabled=false;}else {!this.markersEnabled&&this.drawMarkers();this.state.markersEnabled=true;}}}set regions(regionArray){
|
|
205
|
-
if(this.state.regions.length<1){
|
|
206
|
-
regionArray&®ionArray.forEach(region=>{this.addRegion(region);});}else {
|
|
207
|
-
this.state.regions.forEach((region,index)=>{this.removeRegion(index);});this.state.regions=[];this.regions=regionArray;
|
|
208
|
-
}}get regions(){return this.state.regions;}set dragging(bool){
|
|
209
|
-
if(bool&&!this.state.dragging){this.state.dragging=true;this.bar.classList.add('dragging');}else if(!bool&&this.state.dragging){this.state.dragging=false;this.bar.classList.remove('dragging');}}get dragging(){return this.state.dragging;}addRegion(regionObj){if(regionObj.constructor.name===Region.name){this.state.regions.push(regionObj);this.drawRegion(regionObj);}else {
|
|
210
|
-
this.addRegion(new Region(regionObj));}}removeRegion(param){if(typeof param===typeof Region);else {
|
|
211
|
-
this.state.regions[param].el.remove();this.state.regions[param]=null;delete this.state.regions[param];}}drawRegion(region){const duration=this.props.player.videojs.duration();
|
|
212
|
-
const inPoint=region.in;const leftPercentage=inPoint/duration*100;const rightPercentage=(duration-region.out)/duration*100;const regionEl=document.createElement('div');regionEl.className='region nav ';regionEl.innerHTML='<div class="bubble"></div>';if(region.title&®ion.annotation){let alignmentClassName='';if(leftPercentage>70)alignmentClassName='right-aligned';if(leftPercentage<30)alignmentClassName='left-aligned';regionEl.className+=" has-popout ".concat(alignmentClassName);const popout=document.createElement('div');popout.className='popout';popout.innerHTML="\n <div class=\"title\">\n ".concat(sanitize(region.title),"\n </div>\n <div class=\"annotation\">\n ").concat(truncate(sanitize(region.annotation),72),"\n </div>\n ");regionEl.appendChild(popout);}regionEl.style.left="".concat(leftPercentage,"%");regionEl.style.right="".concat(rightPercentage,"%");region.el=regionEl;this.bar.appendChild(regionEl);}set onDark(bool){if(bool){this.bar.classList.add(classNames.onDark);}else {this.bar.classList.remove(classNames.onDark);}}get onDark(){return this.container.classList.contains(classNames.onDark);}set percentLoaded(val){this.loadIndicator.style.width="".concat(val,"%");}destroy(){this.unbindHotKeys();}toggleMarkers(){if(this.bar.classList.contains('hide-markers')){this.showMarkers();}else {this.hideMarkers();}}hideMarkers(){this.bar.classList.add('hide-markers');}showMarkers(){this.bar.classList.remove('hide-markers');}}SeekBar.Region=Region;
|
|
213
|
-
|
|
214
|
-
const timeCodeNodeNames=['hours','minutes','seconds','frame'];class TimeCodeDisplay{
|
|
215
|
-
constructor(props){this.props=props;this.state={selectedNode:null
|
|
216
|
-
};const classNames=['vdt-timecode','vjs-time-control',
|
|
217
|
-
!this.props.onInput?'duration':''
|
|
218
|
-
];this.container=document.createElement('div');this.container.className=classNames.join(' ');this.nodeNames=[].concat(timeCodeNodeNames);
|
|
219
|
-
this.nodes={};
|
|
220
|
-
this.nodeNames.forEach((nodeName,index)=>{const node=document.createElement('input');node.className=nodeName;node.tabIndex=-1;
|
|
221
|
-
if(this.props.onInput){
|
|
222
|
-
node.maxLength=2;node.onfocus=e=>{this.handleInputFocus(e,nodeName);};node.onblur=e=>{this.handleInputBlur(e,nodeName);};node.onmouseup=e=>{e.preventDefault();e.currentTarget.select();};node.onkeydown=e=>{this.handleTimeCodeInput(e,nodeName);};node.onkeyup=e=>{this.handleTimeCodeInputOnKeyUp(e,nodeName);};}else {node.readOnly=true;
|
|
223
|
-
}this.nodes[nodeName]=node;const colon=document.createElement('span');colon.innerHTML=':';this.container.appendChild(node);index!==this.nodeNames.length-1&&this.container.appendChild(colon);});if(this.props.target){if(this.props.appendAfter){
|
|
224
|
-
this.props.target.parentNode.insertBefore(this.container,this.props.target.nextSibling);}else {this.props.target.appendChild(this.container);}
|
|
225
|
-
this.reset();}else {
|
|
226
|
-
console.error("Unable to instantiate a new ".concat(this.constructor.name," without target DOM node"));
|
|
227
|
-
}}update(valuesObj){
|
|
228
|
-
const startCount=this.nodeNames.length-1;let i;for(i=startCount;i>-1;i--){
|
|
229
|
-
const key=this.nodeNames[i];if(typeof valuesObj[key]!=='undefined'&&valuesObj[key]!==parseInt(this.nodes[key].value,10)&&key!==this.state.selectedNode){
|
|
230
|
-
const str=valuesObj[key].toString();this.nodes[key].value=this.toDigitPairStr(str);}}}reset(){this.update({hours:0,minutes:0,seconds:0,frame:0});}handleInputFocus(e,nodeName){this.state.selectedNode=nodeName;
|
|
231
|
-
this.nodes[nodeName].select();this.props.onInputFocus&&this.props.onInputFocus(nodeName);}handleInputBlur(e,nodeName){this.state.selectedNode=null;
|
|
232
|
-
this.props.onInputBlur&&this.props.onInputBlur(nodeName);}sanitize(input){const output=input.replace(/[^0-9]/g,'');return output;}toDigitPairStr(strValue){return strValue.length<2?"0".concat(strValue):strValue;}handleTimeCodeInput(e,nodeName){const nodeIndex=this.nodeNames.indexOf(nodeName);switch(e.code){case'Enter':
|
|
233
|
-
this.checkAndNormalizeAllInputs();this.props.onInput&&this.props.onInput(e,nodeName,{hours:this.hours,minutes:this.minutes,seconds:this.seconds,frame:this.frame});this[nodeName]=e.currentTarget.value;e.currentTarget.blur();
|
|
234
|
-
break;case'Tab':
|
|
235
|
-
e.preventDefault();
|
|
236
|
-
if(!e.shiftKey){if(nodeIndex+1<=this.nodeNames.length-1){this.nodes[this.nodeNames[nodeIndex+1]].focus();
|
|
237
|
-
}else {this.nodes[this.nodeNames[0]].focus();
|
|
238
|
-
}}else if(nodeIndex-1>=0){this.nodes[this.nodeNames[nodeIndex-1]].focus();
|
|
239
|
-
}else {this.nodes[this.nodeNames[this.nodeNames.length-1]].focus();
|
|
240
|
-
}break;}}handleTimeCodeInputOnKeyUp(e,nodeName){
|
|
241
|
-
if(this.nodes[nodeName].value.length===2&&!isNaN(e.key)){const nodeIndex=this.nodeNames.indexOf(nodeName);
|
|
242
|
-
if(nodeIndex+1<=this.nodeNames.length-1){
|
|
243
|
-
this.nodes[this.nodeNames[nodeIndex+1]].focus();
|
|
244
|
-
}}}checkAndNormalizeAllInputs(){this.nodeNames.forEach(nodeName=>{if(this.nodes[nodeName].value.length<1){
|
|
245
|
-
this.nodes[nodeName].value='00';}
|
|
246
|
-
this.nodes[nodeName].value=this.toDigitPairStr(this.sanitize(this.nodes[nodeName].value));});}
|
|
247
|
-
set frame(val){this.nodes.frame.value=this.toDigitPairStr(val);}get frame(){return parseInt(this.nodes.frame.value,10);}set seconds(val){this.nodes.seconds.value=this.toDigitPairStr(val);}get seconds(){return parseInt(this.nodes.seconds.value,10);}set minutes(val){this.nodes.minutes.value=this.toDigitPairStr(val);}get minutes(){return parseInt(this.nodes.minutes.value,10);}set hours(val){this.nodes.hours.value=this.toDigitPairStr(val);}get hours(){return parseInt(this.nodes.hours.value,10);}getFormatted(key){return this.toDigitPairStr(this[key].toString());}get smpte(){return {hours:this.hours,minutes:this.minutes,seconds:this.seconds,frame:this.frame};}set smpte(o){this.update(o);}get smpteString(){return "".concat(this.getFormatted('hours'),":").concat(this.getFormatted('minutes'),":").concat(this.getFormatted('seconds'),":").concat(this.getFormatted('frame'));}set external(bool){if(bool){this.container.classList.add('external');}else {this.container.classList.remove('external');}}get external(){return this.container.classList.contains('external');}}
|
|
248
|
-
|
|
249
|
-
class VideoTime{constructor(props){if(props.frameRate===undefined){delete this;throw new Error('No "frameRate" option provided, refer to docs.');}else {this.props=props;}}secondsToFramesFromStart(seconds){let frame=seconds*this.props.frameRate;frame=Math.round(frame);return frame;
|
|
250
|
-
}currentTimeToFramesFromStart(currentTime){return this.secondsToFramesFromStart(currentTime);}secondsToFrame(seconds){let frame=this.secondsToFramesFromStart(seconds)%this.props.frameRate;frame=Math.round(frame);return frame;}currentFrame(currentTime){return Math.round(this.secondsToFrame(currentTime));}frameToCurrentTimeFromStart(frame){return frame/this.props.frameRate;
|
|
251
|
-
}smpteToCurrentTimeFromStart(values){return values.hours*3600+values.minutes*60+values.seconds+values.frame/this.props.frameRate;}secondsFromStartToSMPTE(secondsFromStart){let secondsFS=secondsFromStart;const hours=Math.floor(secondsFS/3600);const minutesWithoutHours=secondsFS/60-60*hours;
|
|
252
|
-
secondsFS%=3600;const minutes=Math.floor(minutesWithoutHours);const seconds=Math.floor(secondsFS%60);const frame=this.secondsToFrame(secondsFS);return {hours,minutes,seconds,frame};}}
|
|
253
|
-
|
|
254
|
-
function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty__default["default"](target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}
|
|
255
|
-
const correctMimeTypes={'audio/x-aac':'audio/aac'};const sanitizeMimeType=mimeType=>correctMimeTypes[mimeType]||mimeType;class Player{constructor(props){this.props=props;
|
|
256
|
-
reactiveSetters.apply(this);
|
|
257
|
-
const classNames=[
|
|
258
|
-
'video-js','vjs-big-play-centered',this.props.posterUrl?constants$2.classNames.poster:'',this.props.subtitles&&this.props.subtitles.length>0?constants$2.classNames.subtitles:'','init'
|
|
259
|
-
];this.externalTimecodes={
|
|
260
|
-
duration:[],playback:[]};this.timeConverter=new VideoTime({frameRate:this.props.frameRate||constants$2.defaults.frameRate});
|
|
261
|
-
this.videoEl=document.createElement('video');this.videoEl.crossOrigin=this.props.crossOrigin;this.videoEl.id='vdt-video';this.videoEl.className=classNames.join(' ');this.videoEl.controls=true;
|
|
262
|
-
if(this.props.sources){
|
|
263
|
-
if(this.props.sources.length>1){this.props.sources.sort(a=>a.type.indexOf('mp4')>0?1:-1);}
|
|
264
|
-
this.props.sources.forEach(source=>{const aSource=document.createElement('source');aSource.src=source.src;aSource.type=sanitizeMimeType(source.type);this.videoEl.appendChild(aSource);});}
|
|
265
|
-
this.videoEl.onloadedmetadata=()=>{
|
|
266
|
-
if(this.durationTimeCode){this.setDurationTimeCode();}if(this.videojs.el_)this.videojs.el_.classList.remove('init');};
|
|
267
|
-
setTimeout(()=>{if(this.videojs.el_)this.videojs.el_.classList.remove('init');},2000);
|
|
268
|
-
if(this.props.subtitles){this.props.subtitles.forEach(sub=>{const subtitleTag=document.createElement('track');subtitleTag.kind='subtitles';subtitleTag.srclang=sub.lang;subtitleTag.label=sub.label;
|
|
269
|
-
if(typeof sub.src==='string'){subtitleTag.src=sub.src;
|
|
270
|
-
}else {subtitleTag.src=window.URL.createObjectURL(sub.src);
|
|
271
|
-
}this.videoEl.appendChild(subtitleTag);});}
|
|
272
|
-
if(this.props.target)this.props.target.appendChild(this.videoEl);const showDefaultTimeDisplay=this.props.timecode!==true;const controlsEnabled=this.props.controls!==false;const options=this.props.options||{};
|
|
273
|
-
this.videojs=new videojs__default["default"]('vdt-video',_objectSpread({responsive:true,fluid:true,controls:controlsEnabled,alwaysCaptureHotkeys:false,controlBar:{RemainingTimeDisplay:false,timeDivider:showDefaultTimeDisplay,
|
|
274
|
-
durationDisplay:showDefaultTimeDisplay,currentTimeDisplay:showDefaultTimeDisplay},inactivityTimeout:this.audioOnly?constants$2.defaults.audioInactivityTimeout:constants$2.defaults.inactivityTimeout,preload:'auto',captionsButton:false,subsCapsButton:false,subtitlesButton:false,textTrackSettings:false,html5:{nativeTextTracks:false},languages:{en:{'captions off':'off','subtitles off':'off'}}},options));
|
|
275
|
-
if(this.props.posterUrl)this.videojs.poster(this.props.posterUrl);
|
|
276
|
-
this.handleNewProps(this.props);
|
|
277
|
-
this.videojs.ready(()=>{this.bindHotkeys();this.bindEvents();if(this.props.onReady)this.props.onReady(this.videojs);this.restoreSettings();this.setupTimeCode();this.doEsothericWork();this.setupMenu();this.setupCustomSeekbar();});}setupCustomSeekbar(){if(this.props.seekBar){
|
|
278
|
-
this.videojs.controlBar.progressControl.disable();this.videojs.controlBar.progressControl.hide();const target=this.container.getElementsByClassName('vjs-control-bar')[0];const props=_objectSpread({target,player:this,onDark:this.props.onDark},this.props.seekBar);this.seekBar=new SeekBar(props);
|
|
279
|
-
this.videojs.on('userinactive',()=>{if(!this.controlsBelowPlayer){var _this$seekBar$hideMar,_this$seekBar;if(this.seekBar)(_this$seekBar$hideMar=(_this$seekBar=this.seekBar).hideMarkers)===null||_this$seekBar$hideMar===void 0?void 0:_this$seekBar$hideMar.call(_this$seekBar);}else {var _this$seekBar2,_this$seekBar2$showMa;(_this$seekBar2=this.seekBar)===null||_this$seekBar2===void 0?void 0:(_this$seekBar2$showMa=_this$seekBar2.showMarkers)===null||_this$seekBar2$showMa===void 0?void 0:_this$seekBar2$showMa.call(_this$seekBar2);}});this.videojs.on('useractive',()=>{if(this.seekBar)this.seekBar.showMarkers();});}}setupTimeCode(){let externalTimecodeInstance=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;const props={onInput:(e,nodeName,values)=>{
|
|
280
|
-
this.seekTo(this.timeConverter.smpteToCurrentTimeFromStart(values));},onInputFocus:()=>{
|
|
281
|
-
this.videojs.options_.inactivityTimeout=0;this.videojs.cache_.inactivityTimeout=0;this.videojs.reportUserActivity();
|
|
282
|
-
this.videojs.pause();},onInputBlur:()=>{this.videojs.options().inactivityTimeout=constants$2.defaults.inactivityTimeout;this.videojs.cache_.inactivityTimeout=constants$2.defaults.inactivityTimeout;}};if(externalTimecodeInstance!==null){
|
|
283
|
-
externalTimecodeInstance.props=Object.assign(externalTimecodeInstance.props,props);this.externalTimecodes.playback.push(externalTimecodeInstance);}else if(this.props.timecode===true){
|
|
284
|
-
if(this.props.controls!==false){const target=document.getElementsByClassName('vjs-volume-panel')[0];
|
|
285
|
-
this.timeCode=new TimeCodeDisplay(Object.assign(props,{target,appendAfter:true}));
|
|
286
|
-
this.durationTimeCode=new TimeCodeDisplay({target:this.timeCode.container,appendAfter:true});}}if(this.timeCode||this.externalTimecodes.playback.length>0){
|
|
287
|
-
this.videojs.on('timeupdate',()=>{this.updateTimeCode();});this.videojs.on('play',()=>{this.updateTimeCodeFrame();});}}updateTimeCode(){
|
|
288
|
-
const currentSecond=this.videojs.currentTime();const props=this.timeConverter.secondsFromStartToSMPTE(currentSecond);if(this.timeCode)this.timeCode.update(props);if(this.externalTimecodes.playback.length>0){this.externalTimecodes.playback.forEach(timecode=>{timecode.update(props);});}}updateTimeCodeFrame(){
|
|
289
|
-
const frame=this.timeConverter.currentFrame(this.videojs.currentTime());
|
|
290
|
-
if(this.timeCode)this.timeCode.update({frame});
|
|
291
|
-
if(this.externalTimecodes.playback.length>0){this.externalTimecodes.playback.forEach(timecode=>{timecode.update({frame});});}
|
|
292
|
-
if(!this.videojs.paused()){this.rafID=requestAnimationFrame(()=>{this.updateTimeCodeFrame();});}}setDurationTimeCode(){
|
|
293
|
-
const durationInSeconds=this.videojs.duration();const props=this.timeConverter.secondsFromStartToSMPTE(durationInSeconds);props.frame=this.timeConverter.secondsToFrame(durationInSeconds);this.durationTimeCode.update(props);this.durationTimeCode.container.classList.add('duration');}bindHotkeys(){
|
|
294
|
-
this.bindings=[{key:['space','k'],method:e=>{
|
|
295
|
-
if(e.preventDefault)e.preventDefault();this.togglePlayback();}},{key:'j',method:()=>{if(this.videojs.hasStarted_)this.jumpBackward();}},{key:'l',method:()=>{if(this.videojs.hasStarted_)this.jumpForward();}},{key:['.','right'],method:()=>{this.frameForward();}},{key:[',','left'],method:()=>{this.frameBackward();}},{key:'f',method:()=>{this.toggleFullscreen();}},{key:'m',method:()=>{this.toggleMute();}},{key:'up',method:e=>{if(e.preventDefault)e.preventDefault();
|
|
296
|
-
this.volumeUp();}},{key:'down',method:e=>{if(e.preventDefault)e.preventDefault();
|
|
297
|
-
this.volumeDown();}},{key:'h',method:()=>{this.help.toggle();}},{key:'n',method:()=>{if(this.menu)this.menu.toggle();}}];if(this.props.subtitles){this.bindings.push({key:'c',method:()=>{this.toggleSubs();}});}
|
|
298
|
-
this.bindings.forEach(binding=>{mousetrap__default["default"].bind(binding.key,e=>{binding.method(e);this.onHotkeyPressed(binding.key);});});}unbindHotKeys(){if(this.bindings)this.bindings.forEach(binding=>{mousetrap__default["default"].unbind(binding.key);});}bindEvents(){this.videojs.on('volumechange',()=>{
|
|
299
|
-
this.persistSetting(constants$2.settings.volume,this.volume);});this.videojs.textTracks().on('change',()=>{
|
|
300
|
-
const tracks=this.videojs.textTracks().tracks_;const selected=tracks.filter(track=>track.mode==='showing');const areAnyTxtTracksActive=selected.length>0;
|
|
301
|
-
if(areAnyTxtTracksActive){
|
|
302
|
-
this.videojs.el_.classList.add(constants$2.classNames.subtitlesActive);this.persistSetting(constants$2.settings.subs,true);this.persistSetting(constants$2.settings.subLang,selected[0].language);}else {this.videojs.el_.classList.remove(constants$2.classNames.subtitlesActive);this.persistSetting(constants$2.settings.subs,false);}});}volumeUp(){this.videojs.controlBar.volumePanel.volumeControl.volumeBar.stepForward();this.osd.feedback(constants$2.osd.volchange,{volume:this.volume});}volumeDown(){this.videojs.controlBar.volumePanel.volumeControl.volumeBar.stepBack();this.osd.feedback(constants$2.osd.volchange,{volume:this.volume});}toggleMute(){if(!this.videojs.muted()){this.videojs.muted(true);this.osd.feedback(constants$2.osd.volchange,{volume:this.volume});}else {this.videojs.muted(false);this.osd.feedback(constants$2.osd.volchange,{volume:this.volume});}}toggleFullscreen(){if(this.videojs.isFullscreen()){this.videojs.exitFullscreen();}else {this.videojs.requestFullscreen();}}seek(secs){
|
|
303
|
-
let time=this.videojs.currentTime()+secs;if(time<0){time=0;}this.videojs.currentTime(time);}seekTo(sec){if(!this.videojs.hasStarted())this.videojs.hasStarted(true);this.videojs.currentTime(sec);}jumpForward(){this.seek(constants$2.defaults.jumpSeconds);this.osd.feedback(constants$2.osd.jumpForward);}jumpBackward(){this.seek(-constants$2.defaults.jumpSeconds);this.osd.feedback(constants$2.osd.jumpBackward);}frameForward(){const thisFrame=this.timeConverter.secondsToFramesFromStart(this.videojs.currentTime());const nextFrame=Math.round(thisFrame)+1;this.videojs.currentTime(this.timeConverter.frameToCurrentTimeFromStart(nextFrame));}frameBackward(){const thisFrame=this.timeConverter.secondsToFramesFromStart(this.videojs.currentTime());const previousFrame=Math.round(thisFrame)-1;this.videojs.currentTime(this.timeConverter.frameToCurrentTimeFromStart(previousFrame));}secondsToFramesFromStart(seconds){const frameRate=this.props.frameRate||constants$2.defaults.frameRate;let frame=seconds*frameRate;frame=Math.round(frame);return frame;
|
|
304
|
-
}doEsothericWork(){
|
|
305
|
-
if(this.props.color){
|
|
306
|
-
document.getElementsByClassName('vjs-play-progress')[0].style.backgroundColor=this.props.color;}
|
|
307
|
-
this.osd=new OSD({target:this.videoEl.parentElement});
|
|
308
|
-
if(this.props.onCinema){this.videoEl.parentElement.classList.add('has-cinema-button');this.cinema=false;this.addButtonToControlBar({onClick:()=>{this.props.onCinema(!this.cinema);this.cinema=!this.cinema;},componentName:'CinemaButton',className:'vdt-cinema-button',title:'Cinema-mode'});}
|
|
309
|
-
if(this.props.onScreenshot){this.videoEl.parentElement.classList.add('has-screenshot-button');this.addButtonToControlBar({onClick:()=>{this.props.onScreenshot(this.videojs.currentTime());},componentName:'ScreenshotButton',className:'vdt-screenshot-button',title:'Screenshot'});}
|
|
310
|
-
this.help=new HelpOverlay({target:this.videoEl.parentElement,onToggle:willShow=>{if(this.menu&&this.menu.opened){this.menu.close();}if(willShow&&!this.controlsBelowPlayer){this.hideControls();}else {this.showControls();}}});}restoreSettings(){
|
|
311
|
-
const volume=localStorage.getItem(constants$2.settings.volume);const subsEnabled=localStorage.getItem(constants$2.settings.subs);const subLang=localStorage.getItem(constants$2.settings.subLang);
|
|
312
|
-
this.settings={
|
|
313
|
-
[constants$2.settings.volume]:volume!==null?Math.round(volume*100)/100:1,[constants$2.settings.subLang]:subLang!==null?subLang:'en',[constants$2.settings.subs]:subsEnabled!==null?JSON.parse(subsEnabled):false};
|
|
314
|
-
this.volume=this.settings[constants$2.settings.volume];
|
|
315
|
-
if(this.settings[constants$2.settings.subs]){
|
|
316
|
-
this.enableSubs();}}persistSetting(key,val){this.settings[key]=val;localStorage.setItem(key,val);}enableSubs(){const subs=this.videojs.textTracks();for(let i=0;i<subs.length;i+=1){const sub=subs[i];if(sub.language===this.settings[constants$2.settings.subLang]){sub.mode='showing';}else {sub.mode='hidden';}}}disableSubs(){const subs=this.videojs.textTracks();for(let i=0;i<subs.length;i+=1){const sub=subs[i];sub.mode='hidden';}}toggleSubs(){if(this.videojs.textTracks().length>0){
|
|
317
|
-
if(this.videojs.textTracks().tracks_.filter(track=>track.mode==='showing').length>0){
|
|
318
|
-
this.disableSubs();}else {this.enableSubs();}}}
|
|
319
|
-
addButtonToControlBar(options){const Button=videojs__default["default"].getComponent('Button');const CustomButton=videojs__default["default"].extend(Button,{constructor:function constructor(){
|
|
320
|
-
Button.apply(this,arguments);if(options.className)this.el_.classList.add(options.className);if(options.title){this.el_.title=options.title;}},handleClick:()=>{if(options.onClick)options.onClick();}});videojs__default["default"].registerComponent(options.componentName,CustomButton);this.videojs.getChild('controlBar').addChild(options.componentName,{},7);}
|
|
321
|
-
get volume(){return this.videojs.controlBar.volumePanel.volumeControl.volumeBar.getPercent();}set volume(floatVal){if(floatVal===0){this.videojs.muted(true);}else {this.videojs.muted(false);this.videojs.volume(floatVal);}}setupMenu(){const menuItems=this.props.menuItems||[];const sourcesMenuItems=[];if(this.props.sources.length>1){
|
|
322
|
-
this.props.sources.forEach(source=>{if(source.label){sourcesMenuItems.push({title:source.label,onClick:()=>{this.src=source;}});}});menuItems.push({title:'Sources',getActiveIndex:()=>{const matchingSource=this.props.sources.find(source=>source.src===this.videojs.src());return sourcesMenuItems.indexOf(sourcesMenuItems.find(menuItem=>menuItem.title===matchingSource.label));},items:sourcesMenuItems});}
|
|
323
|
-
if(this.props.subtitles&&this.props.subtitles.length>0){
|
|
324
|
-
const subtitleMenuItems=[{title:'Off',onClick:()=>{this.disableSubs();}}];
|
|
325
|
-
this.props.subtitles.forEach((subtitle,index)=>{subtitleMenuItems.push({title:subtitle.label,onClick:()=>{const subs=this.videojs.textTracks();for(let i=0;i<subs.length;i+=1){const sub=subs[i];if(i===index){sub.mode='showing';}else {sub.mode='hidden';}}}});});menuItems.push({title:'Subtitles',getActiveIndex:()=>{const subs=this.videojs.textTracks();for(let i=0;i<subs.length;i+=1){const sub=subs[i];if(sub.mode==='showing'){return i+1;
|
|
326
|
-
}}return 0;
|
|
327
|
-
},items:subtitleMenuItems});}if(menuItems.length>0){const target=this.videojs.el_;this.menu=new Menu({target,items:menuItems,onOpen:()=>{if(!this.controlsBelowPlayer)this.hideControls();},onClose:()=>{if(!this.controlsBelowPlayer)this.videojs.controls(true);}});
|
|
328
|
-
this.videoEl.parentElement.classList.add('has-vdt-menu');this.addButtonToControlBar({onClick:()=>{this.menu.toggle();},componentName:'SettingsMenuButton',className:'vdt-settings-menu-button',title:'Settings'});}}hideControls(){this.videojs.userActive(false);this.videojs.controls(false);this.videojs.fluid(true);this.videoEl.parentElement.classList.remove('vjs-user-active');this.videojs.userActive(false);}showControls(){this.videojs.fluid(!this.controlsBelowPlayer);this.videojs.controls(true);this.videojs.userActive(true);}toggleControls(){if(this.videojs.controls()){this.hideControls();}else {this.showControls();}}onHotkeyPressed(key){if(key!=='h'&&this.help.state.active){this.help.hide();}}
|
|
329
|
-
triggerHotkey(key){mousetrap__default["default"].trigger(key);}toStart(){this.videojs.currentTime(0);}toEnd(){this.videojs.currentTime(this.videojs.duration());}replay(){this.toStart();this.videojs.play();}play(){this.videojs.play();}pause(){if(!this.videojs.paused())this.videojs.pause();}togglePlayback(){if(this.videojs.paused()){this.play();if(this.videojs.hasStarted_)this.osd.feedback(constants$2.osd.play);}else {this.pause();this.osd.feedback(constants$2.osd.pause);}}updateSmpte(valuesObj){
|
|
330
|
-
const startCount=this.nodeNames.length-1;let i;for(i=startCount;i>-1;i-=1){
|
|
331
|
-
const key=this.nodeNames[i];if(typeof valuesObj[key]!=='undefined'&&valuesObj[key]!==parseInt(this.nodes[key].value,10)&&key!==this.state.selectedNode){
|
|
332
|
-
const str=valuesObj[key].toString();this.nodes[key].value=this.toDigitPairStr(str);}}}destroy(){
|
|
333
|
-
this.videojs.paused(true);if(this.rafID)cancelAnimationFrame(this.rafID);this.videojs.dispose();this.unbindHotKeys();if(this.seekBar)this.seekBar.destroy();}get container(){return this.videoEl.parentElement;}set onDark(bool){if(bool){this.container.classList.add('on-dark');}else {this.container.classList.remove('on-dark');}if(this.seekBar){this.seekBar.onDark=bool;}}get onDark(){return this.container.classList.contains('on-dark');}set controlsBelowPlayer(bool){if(this.videojs.controls()){if(bool){this.container.classList.add('controls-below-player');this.videojs.fluid(false);}else {this.container.classList.remove('controls-below-player');this.videojs.fluid(true);}}}get controlsBelowPlayer(){return this.container.classList.contains('controls-below-player');}get smpte(){const currentSecond=this.videojs.currentTime();return this.timeConverter.secondsFromStartToSMPTE(currentSecond);}set smpte(o){this.updateSmpte(o);}set src(_ref){let{src,type='video/mp4',label=null}=_ref;const currentTime=this.videojs.currentTime();
|
|
334
|
-
const source=this.props.sources.find(aSource=>aSource.src===src);
|
|
335
|
-
const onReady=()=>{let initdone=false;
|
|
336
|
-
this.videojs.on('loadedmetadata',()=>{this.videojs.currentTime(currentTime);});
|
|
337
|
-
this.videojs.on('canplaythrough',()=>{if(!initdone){this.videojs.currentTime(currentTime);initdone=true;this.videojs.play();}});};if(source&&Array.isArray(source)&&source.length>0){
|
|
338
|
-
this.videojs.addClass('vjs-waiting');this.videojs.src(_objectSpread({},source[0]));onReady();}else {this.videojs.addClass('vjs-waiting');this.videojs.src(this.addSrc(src,type,label));onReady();}}get src(){return this.videojs.src();}addSrc(src,type,label){const newSource={src,type,label};const index=this.props.sources.push(newSource)-1;return this.props.sources[index];}
|
|
339
|
-
removeSrc(url){
|
|
340
|
-
}set controls(bool){if(bool){this.showControls();}else {this.hideControls();}}get percentLoaded(){const r=this.videojs.buffered();const percentLoaded=r.end(0)/this.videojs.duration()*100;return percentLoaded;}}
|
|
341
|
-
const button=videojs__default["default"].prototype.constructor.getComponent('Button');
|
|
342
|
-
button.prototype.handleKeyDown=function(e){if(e.keyCode===32){e.preventDefault();}};videojs__default["default"].prototype.constructor.registerComponent('Button',button);
|
|
343
|
-
const subsButton=videojs__default["default"].prototype.constructor.getComponent('SubsCapsButton');class CustomSubsCapsButton extends subsButton{constructor(player){let options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};super(player,options);this.menuButton_.off('mouseenter');this.menuButton_.off('mouseleave');}}
|
|
344
|
-
videojs__default["default"].prototype.constructor.registerComponent('SubsCapsButton',CustomSubsCapsButton);
|
|
345
|
-
|
|
346
|
-
exports.ExternalControls = ExternalControls;
|
|
347
|
-
exports.Player = Player;
|
|
348
|
-
exports.SeekBar = SeekBar;
|
|
349
|
-
exports.TimeCodeDisplay = TimeCodeDisplay;
|
|
350
|
-
exports.VideoTime = VideoTime;
|