@vidispine/vdt-videojs 23.1.0 → 23.2.0-pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,53 +0,0 @@
1
- WEBVTT
2
-
3
-
4
- 00:00:00.500 --> 00:00:03.500 line:0%
5
- The birds...
6
-
7
- 00:00:03.800 --> 00:00:05.800 line:0%
8
- They are flying and diving in the ocean.
9
-
10
- 00:00:06.000 --> 00:00:07.000 line:0%
11
- And now...
12
-
13
- 00:00:07.200 --> 00:00:08.000 position:58% line:0%
14
- The birds feast.
15
-
16
- 00:00:08.200 --> 00:00:10.000 line:0%
17
- Yumm, loveley fishes!
18
-
19
- 00:00:10.100 --> 00:00:12.000 line:0%
20
- Fishes have lots of nutrients in them.
21
-
22
- 00:00:12.000 --> 00:00:13.200 line:0%
23
- What if the fish can feel pain?
24
-
25
- 00:00:13.200 --> 00:00:14.500 position:61% line:0%
26
- It's a thought.
27
-
28
- 00:00:14.522 --> 00:00:16.900 line:0%
29
- Do fish speak english?
30
-
31
- 00:00:16.950 --> 00:00:18.200 line:0%
32
- Gulp gulp gl gllllp...
33
-
34
- 00:00:18.300 --> 00:00:20.200 line:0%
35
- We have to stop the rogue fish.
36
-
37
- 00:00:20.333 --> 00:00:25.333 line:0%
38
- Swoosh swooosh; dive or die
39
-
40
- 00:00:26.000 --> 00:00:28.240 line:0%
41
- This looks collosal.
42
-
43
- 00:00:28.951 --> 00:00:30.785 line:0%
44
- Got em!!!
45
-
46
- 00:00:30.900 --> 00:00:32.000 line:0%
47
- O-oh, the big fishes are coming.
48
-
49
- 00:00:33.200 --> 00:00:36.044 line:0%
50
- "We are going to end you"
51
-
52
- 00:00:36.800 --> 00:00:42.547 line:0%
53
- OK, gotta bounce, WHALE this hasn't gooten any worse than it is; check out this long subtitle line!
@@ -1,365 +0,0 @@
1
- /* eslint-disable no-undef */
2
- /* eslint-disable no-console */
3
- import mousetrap from 'mousetrap';
4
-
5
- import constants from '../src/constants';
6
-
7
- // use this to keep logs sane
8
- function logMiddleware(output, type = '') {
9
- // use log events for extra decoupled needs
10
- const evt = new Event('log', {
11
- bubbles: true,
12
- cancelable: false,
13
- });
14
- evt.output = output;
15
- evt.logType = type;
16
- document.dispatchEvent(evt);
17
- }
18
-
19
- export const log = {
20
- title: (str) => {
21
- const output = `----------------------\n${str}\n----------------------`;
22
- logMiddleware(output);
23
- console.log(output);
24
- },
25
- progress: (str) => {
26
- const output = `[ OK ] - ${str}`;
27
- logMiddleware(output);
28
- console.log(output);
29
- },
30
- fail: (str) => {
31
- const output = `[ ERR ] - ${str}`;
32
- logMiddleware(output);
33
- console.error(output);
34
- },
35
- final: (str) => {
36
- const output = `[ DONE ] - ${str}`;
37
- logMiddleware(output, 'final');
38
- console.log(output);
39
- },
40
- };
41
-
42
- // simple assertion method
43
- let allOK = true;
44
- function assert(bool, desc) {
45
- if (bool) {
46
- log.progress(desc);
47
- } else {
48
- allOK = false;
49
- log.fail(desc);
50
- }
51
- }
52
-
53
- // helper methods for doing the work
54
- function getIntInRange(min, max) {
55
- return Math.floor(Math.random() * (max - min + 1)) + min;
56
- }
57
-
58
- async function pressKeys(keysArr) {
59
- return new Promise((resolve) => {
60
- // press like a very fast monkey, max 300ms-ish speed
61
- keysArr.forEach((key, index) => {
62
- setTimeout(() => {
63
- // play key
64
- mousetrap.trigger(key);
65
-
66
- if (index === keysArr.length - 1) {
67
- // last keystroke
68
- resolve();
69
- }
70
- }, 100 * index + getIntInRange(150, 250));
71
- });
72
- });
73
- }
74
-
75
- async function sleep(milis = 50) {
76
- return new Promise((r) => {
77
- setTimeout(r, milis);
78
- });
79
- }
80
-
81
- async function waitForSeek() {
82
- const checkInterval = 300;
83
- let checkIntervalInstance;
84
-
85
- function isSeeking() {
86
- return player.container.classList.contains('vjs-seeking');
87
- }
88
-
89
- return new Promise((resolve) => {
90
- setTimeout(() => {
91
- // wait for 'seeking' to start
92
- checkIntervalInstance = setInterval(() => {
93
- // check every x ms
94
- if (!isSeeking()) {
95
- clearInterval(checkIntervalInstance);
96
- resolve(true);
97
- }
98
- }, checkInterval);
99
- }, 50);
100
- });
101
- }
102
-
103
- // test declarations
104
- const tests = {
105
- unitTests: () => {
106
- console.log('TODO - unit tests');
107
- },
108
- testTimecode: async () => {
109
- log.title('Testing timeCodeDisplay mounted in player');
110
-
111
- player.timeCode.update({
112
- frame: 21,
113
- seconds: 22,
114
- minutes: 23,
115
- hours: 1,
116
- });
117
-
118
- const timeCodeAssertion1 =
119
- player.timeCode.frame === 21 &&
120
- player.timeCode.seconds === 22 &&
121
- player.timeCode.minutes === 23 &&
122
- player.timeCode.hours === 1;
123
- assert(timeCodeAssertion1, 'Numbers with pure timeCode.update(...) method match');
124
-
125
- player.videojs.currentTime(0);
126
- await waitForSeek();
127
- const timeCodeAssertion2 =
128
- player.timeCode.frame === 0 &&
129
- player.timeCode.seconds === 0 &&
130
- player.timeCode.minutes === 0 &&
131
- player.timeCode.hours === 0;
132
- assert(
133
- timeCodeAssertion2,
134
- 'Timecode reacted to player time update, everything should be zeroed out',
135
- );
136
-
137
- let i = 1;
138
- const times = 22;
139
- await new Promise((resolve) => {
140
- while (i <= times) {
141
- player.frameForward();
142
- if (i === times) {
143
- resolve();
144
- }
145
- i += 1;
146
- }
147
- });
148
- await waitForSeek();
149
- assert(
150
- player.timeCode.frame === times,
151
- 'Timecode reacted to frameForward, should be 22nd frame',
152
- );
153
-
154
- await sleep(); // sleep
155
- player.videojs.currentTime(13);
156
- await waitForSeek();
157
- assert(
158
- player.timeCode.seconds === 13 && player.timeCode.minutes === 0,
159
- 'Timecode reacted to player time update, seconds should be 13',
160
- );
161
-
162
- log.progress('Done with timeCodeDisplay tests');
163
- },
164
- testHotKeys: async () => {
165
- player.videojs.currentTime(0);
166
- player.videojs.paused(true);
167
-
168
- log.title('Testing hotkeys');
169
-
170
- await pressKeys(['space']);
171
- assert(!player.videojs.paused(), 'Space key starts player');
172
-
173
- await pressKeys(['space']);
174
- assert(player.videojs.paused(), 'Space key pauses player');
175
-
176
- await pressKeys(['k']);
177
- assert(!player.videojs.paused(), 'K key starts player');
178
-
179
- await pressKeys(['k']);
180
- assert(player.videojs.paused(), 'K key pauses player');
181
-
182
- await sleep();
183
-
184
- const secBeforeJumpForward = Math.round(player.videojs.currentTime());
185
- await pressKeys(['l', 'l']);
186
- await waitForSeek();
187
- const secAfterJumpForward = Math.round(player.videojs.currentTime());
188
- assert(
189
- // eslint-disable-next-line import/no-named-as-default-member
190
- secAfterJumpForward - secBeforeJumpForward >= constants.defaults.jumpSeconds * 2,
191
- 'Jump forward with L key works',
192
- );
193
-
194
- await sleep();
195
- await pressKeys(['l']);
196
- await waitForSeek();
197
-
198
- const secBeforeJumpBackward = Math.round(player.videojs.currentTime());
199
- await pressKeys(['j', 'j']);
200
- await waitForSeek();
201
- const secAfterJumpBackward = Math.round(player.videojs.currentTime());
202
- assert(
203
- // eslint-disable-next-line import/no-named-as-default-member
204
- secBeforeJumpBackward - secAfterJumpBackward >= constants.defaults.jumpSeconds * 2,
205
- 'Jump backward with J key works',
206
- );
207
-
208
- await sleep(100);
209
-
210
- const frameBeforeFF = player.timeConverter.currentFrame(player.videojs.currentTime());
211
- await pressKeys(['right']);
212
- await waitForSeek();
213
- const frameAfterFF = player.timeConverter.currentFrame(player.videojs.currentTime());
214
- assert(frameAfterFF === frameBeforeFF + 1, '→ Frame forward with right arrow key works');
215
-
216
- const frameBeforeFB = player.timeConverter.currentFrame(player.videojs.currentTime());
217
- await pressKeys(['left']);
218
- await waitForSeek();
219
- const frameAfterFB = player.timeConverter.currentFrame(player.videojs.currentTime());
220
- assert(frameAfterFB === frameBeforeFB - 1, '← Frame backward with left arrow key works');
221
-
222
- player.volume = 1.0;
223
- await pressKeys(['down', 'down', 'down', 'down']);
224
- assert(player.volume < 0.8, '↓ Volume adjustment with down arrow works');
225
-
226
- player.volume = 0.2;
227
- await pressKeys(['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up']);
228
- assert(player.volume > 0.8, '↑ Volume adjustment with up arrow works');
229
-
230
- await pressKeys(['m']);
231
- assert(player.volume === 0, 'Mute with m key works');
232
-
233
- await pressKeys(['m']);
234
- assert(player.volume > 0, 'Unmute with m key works');
235
-
236
- log.progress('Done with hotkey tests');
237
- },
238
- seekBar: () => {
239
- seekbar.regions = [
240
- new seekbar.Region({
241
- in: 1,
242
- out: 2.8,
243
- title: 'Cool!',
244
- annotation: 'Lorem ipsum sit dolor atmet my friend...',
245
- }),
246
- new seekbar.Region({ in: 12, out: 16 }),
247
- new seekbar.Region({ in: 22, out: 28 }),
248
- ];
249
-
250
- setTimeout(() => {
251
- seekbar.regions = [
252
- new seekbar.Region({
253
- in: 9.7597499,
254
- out: 14,
255
- title: 'Birds',
256
- annotation:
257
- 'Birds are a group of feathered theropod dinosaurs, and constitute the only living dinosaurs.',
258
- }),
259
- new seekbar.Region({
260
- in: 1,
261
- out: 2.8,
262
- title: 'Cool!',
263
- annotation: 'Lorem ipsum sit dolor atmet my friend...',
264
- }),
265
- new seekbar.Region({
266
- in: 18,
267
- out: 22,
268
- title: 'Dinosaurs',
269
- annotation:
270
- 'Based on fossil and biological evidence, most scientists accept that birds are a specialised subgroup of theropod dinosaurs.',
271
- }),
272
- ];
273
- }, 1500);
274
- },
275
- testInFrameMenu: async () => {
276
- // reduces repeat code for assertions
277
- function isMenuOpen() {
278
- return player.menu.state.opened && player.menu.menuContainer.classList.contains('open');
279
- }
280
-
281
- log.title('Testing in frame menu');
282
- log.progress('Testing open / close functionality...');
283
-
284
- await pressKeys(['n']);
285
- await sleep(400);
286
- assert(isMenuOpen(), 'Menu state is opened upon first N key toggle');
287
-
288
- await pressKeys(['n']);
289
- await sleep(400);
290
- assert(!isMenuOpen(), 'Menu state is closed upon second N key toggle');
291
-
292
- await pressKeys(['n']);
293
- await sleep(400);
294
- await pressKeys(['esc']);
295
- await sleep(400);
296
- assert(!isMenuOpen(), 'Menu state is closed after pressing the ESC key');
297
-
298
- const menuButtonEl = document.getElementsByClassName('vdt-settings-menu-button')[0];
299
- menuButtonEl.click();
300
- await sleep(400);
301
- assert(isMenuOpen(), 'Menu state is opened upon first click event invocation on menu btn');
302
-
303
- menuButtonEl.click();
304
- await sleep(400);
305
- assert(!isMenuOpen(), 'Menu state is closed upon second click event invocation on menu btn');
306
-
307
- menuButtonEl.click();
308
- await sleep(400);
309
- player.container.click();
310
- await sleep(400);
311
- assert(!isMenuOpen(), 'Menu is being closed upon clicking outside the menu area when open');
312
-
313
- log.progress('Testing video source switching and subtitles selection capability');
314
-
315
- const videoSrcBeforeSwitch = player.videojs.src().toString();
316
- player.menu.open();
317
- await sleep(400);
318
-
319
- // find the sources menu item and click it
320
- const sourcesMenuItem = player.menu.state.items.find(
321
- (menuItem) => menuItem.props.title.toLowerCase().indexOf('sources') > -1,
322
- );
323
- if (sourcesMenuItem) sourcesMenuItem.container.click();
324
- await sleep(400);
325
-
326
- // find a subitem that's not the selected one currently and click it
327
- const altSrcMenuItem = player.menu.state.subItems.find((menuItem) => !menuItem.props.selected);
328
-
329
- // avoid sound on playback of the other video src
330
- const playerVolBefore = player.volume;
331
- player.volume = 0;
332
-
333
- if (altSrcMenuItem) altSrcMenuItem.container.click();
334
- await waitForSeek();
335
- sleep();
336
- player.pause();
337
-
338
- const videoSrcAfterSwitch = player.videojs.src().toString();
339
- assert(videoSrcBeforeSwitch !== videoSrcAfterSwitch, 'Video source was changed successfully');
340
- player.volume = playerVolBefore;
341
-
342
- // TODO - test subtitles selection
343
-
344
- log.progress('Done with in frame menu tests');
345
- },
346
- };
347
-
348
- // test runner
349
- async function runTests() {
350
- allOK = true;
351
- await tests.testHotKeys();
352
- await tests.testTimecode();
353
- await tests.testInFrameMenu();
354
-
355
- if (allOK) {
356
- console.log('\n\n'); // space
357
- log.final('All tests passed. :)');
358
- } else {
359
- log.fail('All tests did not pass, check console output...');
360
- }
361
- }
362
-
363
- export { tests };
364
-
365
- export default runTests;