shaka-player 3.2.1 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
- package/.github/ISSUE_TEMPLATE/question.md +1 -1
- package/AUTHORS +9 -5
- package/CHANGELOG.md +358 -0
- package/CONTRIBUTORS +7 -2
- package/build/conformance.textproto +183 -169
- package/build/generateExterns.js +1 -1
- package/build/types/core +3 -0
- package/build/types/offline +1 -0
- package/build/types/polyfill +1 -0
- package/build/types/ui +2 -0
- package/demo/common/assets.js +19 -1
- package/demo/common/message_ids.js +13 -1
- package/demo/config.js +31 -1
- package/demo/index.html +1 -1
- package/demo/locales/en.json +12 -0
- package/demo/locales/source.json +48 -0
- package/dist/controls.css +26 -2
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +20 -17
- package/dist/demo.compiled.debug.map +3 -3
- package/dist/demo.compiled.js +20 -17
- package/dist/demo.compiled.map +3 -3
- package/dist/deps.js +19 -12
- package/dist/locales.js +39 -37
- package/dist/receiver.compiled.debug.js +12 -10
- package/dist/receiver.compiled.debug.map +3 -3
- package/dist/receiver.compiled.js +12 -10
- package/dist/receiver.compiled.map +3 -3
- package/dist/shaka-player.compiled.d.ts +231 -18
- package/dist/shaka-player.compiled.debug.d.ts +231 -18
- package/dist/shaka-player.compiled.debug.externs.js +279 -8
- package/dist/shaka-player.compiled.debug.js +512 -449
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +279 -8
- package/dist/shaka-player.compiled.js +854 -821
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +247 -19
- package/dist/shaka-player.ui.debug.d.ts +247 -19
- package/dist/shaka-player.ui.debug.externs.js +307 -9
- package/dist/shaka-player.ui.debug.js +662 -580
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +307 -9
- package/dist/shaka-player.ui.js +1047 -1000
- package/dist/shaka-player.ui.map +4 -4
- package/docs/design/bg-fetch-after.gv +29 -0
- package/docs/design/bg-fetch-after.gv.png +0 -0
- package/docs/design/bg-fetch-before.gv +18 -0
- package/docs/design/bg-fetch-before.gv.png +0 -0
- package/docs/design/bg-fetch.md +134 -0
- package/docs/tutorials/blob-url.md +15 -0
- package/docs/tutorials/fairplay.md +1 -1
- package/docs/tutorials/index.json +1 -0
- package/docs/tutorials/ui-customization.md +66 -0
- package/docs/tutorials/ui.md +5 -5
- package/externs/cmcd.js +186 -0
- package/externs/ima.js +3 -0
- package/externs/shaka/ads.js +5 -0
- package/externs/shaka/manifest.js +12 -1
- package/externs/shaka/manifest_parser.js +10 -1
- package/externs/shaka/net.js +20 -4
- package/externs/shaka/offline.js +31 -2
- package/externs/shaka/player.js +138 -5
- package/externs/shaka/text.js +24 -0
- package/externs/webcrypto.js +18 -0
- package/karma.conf.js +1 -0
- package/lib/abr/ewma.js +14 -0
- package/lib/abr/ewma_bandwidth_estimator.js +16 -2
- package/lib/abr/simple_abr_manager.js +6 -0
- package/lib/ads/client_side_ad.js +8 -0
- package/lib/ads/client_side_ad_manager.js +54 -90
- package/lib/ads/server_side_ad.js +7 -0
- package/lib/ads/server_side_ad_manager.js +7 -10
- package/lib/cast/cast_proxy.js +3 -2
- package/lib/cast/cast_receiver.js +2 -1
- package/lib/cast/cast_sender.js +2 -2
- package/lib/cast/cast_utils.js +1 -0
- package/lib/dash/dash_parser.js +141 -16
- package/lib/dash/segment_base.js +25 -1
- package/lib/dash/segment_list.js +19 -10
- package/lib/dash/segment_template.js +24 -11
- package/lib/hls/hls_parser.js +146 -40
- package/lib/media/drm_engine.js +7 -0
- package/lib/media/gap_jumping_controller.js +4 -2
- package/lib/media/media_source_engine.js +1 -2
- package/lib/media/quality_observer.js +291 -0
- package/lib/media/segment_index.js +8 -1
- package/lib/media/segment_reference.js +37 -4
- package/lib/media/streaming_engine.js +49 -7
- package/lib/net/http_fetch_plugin.js +31 -11
- package/lib/net/http_plugin_utils.js +1 -0
- package/lib/net/http_xhr_plugin.js +40 -14
- package/lib/net/networking_engine.js +83 -19
- package/lib/offline/download_info.js +68 -0
- package/lib/offline/download_manager.js +13 -5
- package/lib/offline/indexeddb/base_storage_cell.js +35 -0
- package/lib/offline/indexeddb/storage_mechanism.js +1 -1
- package/lib/offline/indexeddb/v5_storage_cell.js +5 -0
- package/lib/offline/storage.js +393 -284
- package/lib/offline/stored_content_utils.js +2 -0
- package/lib/player.js +249 -43
- package/lib/polyfill/media_capabilities.js +36 -15
- package/lib/polyfill/mediasource.js +6 -0
- package/lib/polyfill/orientation.js +1 -1
- package/lib/polyfill/patchedmediakeys_apple.js +4 -4
- package/lib/polyfill/patchedmediakeys_ms.js +4 -4
- package/lib/polyfill/patchedmediakeys_webkit.js +4 -4
- package/lib/polyfill/random_uuid.js +52 -0
- package/lib/text/cue.js +18 -0
- package/lib/text/mp4_ttml_parser.js +3 -0
- package/lib/text/text_engine.js +14 -2
- package/lib/text/ttml_text_parser.js +114 -60
- package/lib/text/ui_text_displayer.js +95 -41
- package/lib/util/cmcd_manager.js +672 -0
- package/lib/util/error.js +6 -0
- package/lib/util/fake_event.js +53 -7
- package/lib/util/language_utils.js +12 -0
- package/lib/util/mutex.js +52 -0
- package/lib/util/periods.js +102 -65
- package/lib/util/platform.js +13 -1
- package/lib/util/player_configuration.js +18 -0
- package/lib/util/stream_utils.js +99 -10
- package/lib/util/xml_utils.js +19 -0
- package/package.json +2 -2
- package/shaka-player.uncompiled.js +3 -0
- package/test/cast/cast_proxy_unit.js +12 -6
- package/test/cast/cast_utils_unit.js +1 -1
- package/test/dash/dash_parser_content_protection_unit.js +2 -0
- package/test/dash/dash_parser_live_unit.js +101 -1
- package/test/dash/dash_parser_manifest_unit.js +222 -2
- package/test/dash/dash_parser_segment_base_unit.js +2 -0
- package/test/dash/dash_parser_segment_list_unit.js +2 -1
- package/test/dash/dash_parser_segment_template_unit.js +2 -1
- package/test/hls/hls_live_unit.js +2 -0
- package/test/hls/hls_parser_unit.js +7 -1
- package/test/media/closed_caption_parser_unit.js +6 -1
- package/test/media/drm_engine_unit.js +47 -3
- package/test/media/quality_observer_unit.js +139 -0
- package/test/media/segment_reference_unit.js +16 -1
- package/test/media/streaming_engine_integration.js +4 -2
- package/test/media/streaming_engine_unit.js +147 -0
- package/test/net/http_plugin_unit.js +20 -15
- package/test/offline/storage_integration.js +108 -4
- package/test/player_integration.js +178 -8
- package/test/player_src_equals_integration.js +41 -8
- package/test/player_unit.js +19 -9
- package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
- package/test/test/assets/3675/dash_0.mpd +30 -0
- package/test/test/assets/3675/dash_1.mpd +30 -0
- package/test/test/assets/3675/dash_2.mpd +30 -0
- package/test/test/assets/3675/dash_3.mpd +30 -0
- package/test/test/assets/3675/dash_4.mpd +30 -0
- package/test/test/assets/3675/dash_5.mpd +26 -0
- package/test/test/assets/3675/init-stream0.m4s +0 -0
- package/test/test/assets/chapters.vtt +2 -2
- package/test/test/assets/chapters2.vtt +10 -0
- package/test/test/util/dash_parser_util.js +4 -0
- package/test/test/util/fake_ad.js +7 -0
- package/test/test/util/fake_ad_manager.js +1 -1
- package/test/test/util/fake_drm_engine.js +9 -2
- package/test/test/util/manifest_generator.js +3 -2
- package/test/test/util/test_scheme.js +14 -1
- package/test/test/util/ttml_utils.js +81 -0
- package/test/text/mp4_ttml_parser_unit.js +11 -18
- package/test/text/ttml_text_parser_unit.js +552 -227
- package/test/text/ui_text_displayer_unit.js +29 -17
- package/test/ui/localization_unit.js +15 -14
- package/test/ui/text_displayer_layout_unit.js +13 -1
- package/test/ui/ui_unit.js +250 -0
- package/test/util/cmcd_manager_unit.js +291 -0
- package/test/util/stream_utils_unit.js +45 -4
- package/third_party/closure-uri/uri.js +21 -0
- package/ui/airplay_button.js +1 -0
- package/ui/audio_language_selection.js +7 -0
- package/ui/cast_button.js +3 -3
- package/ui/context_menu.js +109 -0
- package/ui/controls.js +45 -13
- package/ui/controls.less +1 -0
- package/ui/enums.js +4 -0
- package/ui/externs/ui.js +28 -1
- package/ui/fast_forward_button.js +14 -5
- package/ui/fullscreen_button.js +1 -0
- package/ui/less/buttons.less +0 -4
- package/ui/less/containers.less +77 -7
- package/ui/less/overflow_menu.less +0 -10
- package/ui/less/tooltip.less +97 -0
- package/ui/locales/en.json +1 -0
- package/ui/locales/ru.json +6 -6
- package/ui/locales/source.json +4 -0
- package/ui/localization.js +28 -51
- package/ui/loop_button.js +5 -0
- package/ui/mute_button.js +2 -1
- package/ui/overflow_menu.js +5 -25
- package/ui/pip_button.js +7 -3
- package/ui/play_button.js +2 -2
- package/ui/playback_rate_selection.js +8 -9
- package/ui/resolution_selection.js +7 -0
- package/ui/rewind_button.js +15 -6
- package/ui/seek_bar.js +4 -2
- package/ui/settings_menu.js +36 -4
- package/ui/small_play_button.js +1 -0
- package/ui/statistics_button.js +253 -0
- package/ui/text_selection.js +12 -4
- package/ui/ui.js +30 -0
- package/ui/volume_bar.js +1 -1
- package/externs/media_capabilities.js +0 -16
|
@@ -84,20 +84,16 @@ describe('UITextDisplayer', () => {
|
|
|
84
84
|
// Wait until updateCaptions_() gets called.
|
|
85
85
|
await shaka.test.Util.delay(0.5);
|
|
86
86
|
|
|
87
|
-
const textContainer =
|
|
88
|
-
|
|
89
|
-
const captions =
|
|
90
|
-
textContainer.querySelector('span:not(.shaka-text-wrapper)');
|
|
87
|
+
const textContainer = videoContainer.querySelector('.shaka-text-container');
|
|
88
|
+
const captions = textContainer.querySelector('div');
|
|
91
89
|
const cssObj = parseCssText(captions.style.cssText);
|
|
92
90
|
|
|
93
91
|
const expectCssObj = {
|
|
94
92
|
'color': 'green',
|
|
95
|
-
'background-color': 'black',
|
|
96
93
|
'direction': 'ltr',
|
|
97
94
|
'font-size': '10px',
|
|
98
95
|
'font-style': 'normal',
|
|
99
96
|
'font-weight': 400,
|
|
100
|
-
'line-height': 2,
|
|
101
97
|
'text-align': 'center',
|
|
102
98
|
};
|
|
103
99
|
|
|
@@ -114,6 +110,8 @@ describe('UITextDisplayer', () => {
|
|
|
114
110
|
}
|
|
115
111
|
|
|
116
112
|
expect(cssObj).toEqual(jasmine.objectContaining(expectCssObj));
|
|
113
|
+
expect(parseCssText(textContainer.querySelector('span').style.cssText))
|
|
114
|
+
.toEqual(jasmine.objectContaining({'background-color': 'black'}));
|
|
117
115
|
});
|
|
118
116
|
|
|
119
117
|
it('correctly displays styles for nested cues', async () => {
|
|
@@ -137,15 +135,13 @@ describe('UITextDisplayer', () => {
|
|
|
137
135
|
await shaka.test.Util.delay(0.5);
|
|
138
136
|
|
|
139
137
|
// Verify styles applied to the nested cues.
|
|
140
|
-
const textContainer =
|
|
141
|
-
videoContainer.querySelector('.shaka-text-container');
|
|
138
|
+
const textContainer = videoContainer.querySelector('.shaka-text-container');
|
|
142
139
|
const captions =
|
|
143
140
|
textContainer.querySelector('span:not(.shaka-text-wrapper)');
|
|
144
141
|
const cssObj = parseCssText(captions.style.cssText);
|
|
145
142
|
|
|
146
143
|
const expectCssObj = {
|
|
147
144
|
'color': 'green',
|
|
148
|
-
'background-color': 'black',
|
|
149
145
|
'font-size': '10px',
|
|
150
146
|
'font-style': 'normal',
|
|
151
147
|
'font-weight': 400,
|
|
@@ -165,6 +161,8 @@ describe('UITextDisplayer', () => {
|
|
|
165
161
|
}
|
|
166
162
|
|
|
167
163
|
expect(cssObj).toEqual(jasmine.objectContaining(expectCssObj));
|
|
164
|
+
expect(parseCssText(captions.querySelector('span').style.cssText))
|
|
165
|
+
.toEqual(jasmine.objectContaining({'background-color': 'black'}));
|
|
168
166
|
});
|
|
169
167
|
|
|
170
168
|
it('correctly displays styles for cellResolution units', async () => {
|
|
@@ -191,10 +189,8 @@ describe('UITextDisplayer', () => {
|
|
|
191
189
|
// style.
|
|
192
190
|
const expectedLinePadding = '11.25px';
|
|
193
191
|
|
|
194
|
-
const textContainer =
|
|
195
|
-
|
|
196
|
-
const captions =
|
|
197
|
-
textContainer.querySelector('span:not(.shaka-text-wrapper)');
|
|
192
|
+
const textContainer = videoContainer.querySelector('.shaka-text-container');
|
|
193
|
+
const captions = textContainer.querySelector('div');
|
|
198
194
|
const cssObj = parseCssText(captions.style.cssText);
|
|
199
195
|
expect(cssObj).toEqual(
|
|
200
196
|
jasmine.objectContaining({
|
|
@@ -222,10 +218,8 @@ describe('UITextDisplayer', () => {
|
|
|
222
218
|
// videoContainerHeight=450px and tts:fontSize="90%" on the default style.
|
|
223
219
|
const expectedFontSize = '27px';
|
|
224
220
|
|
|
225
|
-
const textContainer =
|
|
226
|
-
|
|
227
|
-
const captions =
|
|
228
|
-
textContainer.querySelector('span:not(.shaka-text-wrapper)');
|
|
221
|
+
const textContainer = videoContainer.querySelector('.shaka-text-container');
|
|
222
|
+
const captions = textContainer.querySelector('div');
|
|
229
223
|
const cssObj = parseCssText(captions.style.cssText);
|
|
230
224
|
expect(cssObj).toEqual(
|
|
231
225
|
jasmine.objectContaining({'font-size': expectedFontSize}));
|
|
@@ -319,6 +313,24 @@ describe('UITextDisplayer', () => {
|
|
|
319
313
|
expect(captions.length).toBe(3);
|
|
320
314
|
});
|
|
321
315
|
|
|
316
|
+
it('hides currently displayed cue when removed', async () => {
|
|
317
|
+
const cue = new shaka.text.Cue(0, 50, 'One');
|
|
318
|
+
textDisplayer.setTextVisibility(true);
|
|
319
|
+
textDisplayer.append([cue]);
|
|
320
|
+
video.currentTime = 10;
|
|
321
|
+
await shaka.test.Util.delay(0.5);
|
|
322
|
+
const textContainer = videoContainer.querySelector('.shaka-text-container');
|
|
323
|
+
|
|
324
|
+
let cueElements = textContainer.querySelectorAll('div');
|
|
325
|
+
expect(cueElements.length).toBe(1);
|
|
326
|
+
expect(cueElements[0].textContent).toBe('One');
|
|
327
|
+
|
|
328
|
+
textDisplayer.remove(0, 100);
|
|
329
|
+
|
|
330
|
+
cueElements = textContainer.querySelectorAll('div');
|
|
331
|
+
expect(cueElements.length).toBe(0);
|
|
332
|
+
});
|
|
333
|
+
|
|
322
334
|
it('hides and shows nested cues at appropriate times', async () => {
|
|
323
335
|
const parentCue1 = new shaka.text.Cue(0, 100, '');
|
|
324
336
|
const cue1 = new shaka.text.Cue(0, 50, 'One');
|
|
@@ -198,7 +198,7 @@ describe('Localization', () => {
|
|
|
198
198
|
localization.changeLocale([ELVISH_WOODLAND]);
|
|
199
199
|
|
|
200
200
|
expect(events.length).toBe(1);
|
|
201
|
-
expect(events[0]
|
|
201
|
+
expect(events[0]['locales']).toEqual([ELVISH_WOODLAND]);
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
|
|
@@ -214,23 +214,23 @@ describe('Localization', () => {
|
|
|
214
214
|
localization.changeLocale([ELVISH_WOODLAND, DWARFISH_NORTH]);
|
|
215
215
|
|
|
216
216
|
expect(events.length).toBe(1);
|
|
217
|
-
expect(events[0]
|
|
217
|
+
expect(events[0]['locales']).toEqual([ELVISH_WOODLAND, DWARFISH_NORTH]);
|
|
218
218
|
|
|
219
219
|
// We should see an event telling us that dwarfish is still missing.
|
|
220
220
|
localization.insert(ELVISH_WOODLAND, new Map());
|
|
221
221
|
localization.changeLocale([ELVISH_WOODLAND, DWARFISH_NORTH]);
|
|
222
222
|
|
|
223
223
|
expect(events.length).toBe(2);
|
|
224
|
-
expect(events[0]
|
|
225
|
-
expect(events[1]
|
|
224
|
+
expect(events[0]['locales']).toEqual([ELVISH_WOODLAND, DWARFISH_NORTH]);
|
|
225
|
+
expect(events[1]['locales']).toEqual([DWARFISH_NORTH]);
|
|
226
226
|
|
|
227
227
|
// There should be no more events now that we added the last language.
|
|
228
228
|
localization.insert(DWARFISH_NORTH, new Map());
|
|
229
229
|
localization.changeLocale([ELVISH_WOODLAND, DWARFISH_NORTH]);
|
|
230
230
|
|
|
231
231
|
expect(events.length).toBe(2);
|
|
232
|
-
expect(events[0]
|
|
233
|
-
expect(events[1]
|
|
232
|
+
expect(events[0]['locales']).toEqual([ELVISH_WOODLAND, DWARFISH_NORTH]);
|
|
233
|
+
expect(events[1]['locales']).toEqual([DWARFISH_NORTH]);
|
|
234
234
|
});
|
|
235
235
|
});
|
|
236
236
|
|
|
@@ -373,8 +373,8 @@ describe('Localization', () => {
|
|
|
373
373
|
// it was in the fallback (HALFLING) but not our preferred language
|
|
374
374
|
// (EVLISH).
|
|
375
375
|
expect(events.length).toBe(1);
|
|
376
|
-
expect(events[0]
|
|
377
|
-
expect(events[0]
|
|
376
|
+
expect(events[0]['locales']).toEqual([ELVISH_WOODLAND]);
|
|
377
|
+
expect(events[0]['missing']).toEqual(['hello']);
|
|
378
378
|
});
|
|
379
379
|
|
|
380
380
|
it('fires when key/value is missing from preferred but found in base',
|
|
@@ -400,8 +400,8 @@ describe('Localization', () => {
|
|
|
400
400
|
// because it was in the base (ELVISH) but not our preferred language
|
|
401
401
|
// (EVLISH_WOODLAND).
|
|
402
402
|
expect(events.length).toBe(1);
|
|
403
|
-
expect(events[0]
|
|
404
|
-
expect(events[0]
|
|
403
|
+
expect(events[0]['locales']).toEqual([ELVISH_WOODLAND]);
|
|
404
|
+
expect(events[0]['missing']).toEqual(['Best Wishes']);
|
|
405
405
|
});
|
|
406
406
|
|
|
407
407
|
it('fires when key/value is missing from preferred but found in sibling',
|
|
@@ -427,8 +427,8 @@ describe('Localization', () => {
|
|
|
427
427
|
// understand" because it was in a sibling locale (HALFLING_SHIRE)
|
|
428
428
|
// but not our preferred language (HALFLING_COMMON).
|
|
429
429
|
expect(events.length).toBe(1);
|
|
430
|
-
expect(events[0]
|
|
431
|
-
expect(events[0]
|
|
430
|
+
expect(events[0]['locales']).toEqual([HALFLING_COMMON]);
|
|
431
|
+
expect(events[0]['missing']).toEqual(['Do you understand']);
|
|
432
432
|
});
|
|
433
433
|
|
|
434
434
|
it('fires when key/value is missing from some preferred languages',
|
|
@@ -454,8 +454,9 @@ describe('Localization', () => {
|
|
|
454
454
|
|
|
455
455
|
// There should have no missing localization events.
|
|
456
456
|
expect(events.length).toBe(1);
|
|
457
|
-
expect(events[0]
|
|
458
|
-
|
|
457
|
+
expect(events[0]['locales']).toEqual(
|
|
458
|
+
[ELVISH_WOODLAND, DWARFISH_NORTH]);
|
|
459
|
+
expect(events[0]['missing']).toEqual(['may your forge burn bright']);
|
|
459
460
|
});
|
|
460
461
|
});
|
|
461
462
|
|
|
@@ -141,7 +141,9 @@ filterDescribe('TextDisplayer layout', supportsScreenshots, () => {
|
|
|
141
141
|
cue.region.id = '1';
|
|
142
142
|
// Position the cue *explicitly* at the bottom of the screen.
|
|
143
143
|
cue.region.viewportAnchorX = 0; // %
|
|
144
|
-
cue.region.viewportAnchorY =
|
|
144
|
+
cue.region.viewportAnchorY = 90; // %
|
|
145
|
+
cue.region.width = 100; // %
|
|
146
|
+
cue.region.height = 10; // %
|
|
145
147
|
textDisplayer.append([cue]);
|
|
146
148
|
|
|
147
149
|
await checkScreenshot('ui', 'cue-with-controls');
|
|
@@ -314,6 +316,16 @@ filterDescribe('TextDisplayer layout', supportsScreenshots, () => {
|
|
|
314
316
|
await checkScreenshot(prefix, 'nested-cues-with-linebreak');
|
|
315
317
|
});
|
|
316
318
|
|
|
319
|
+
// Regression test for #3600
|
|
320
|
+
it('cue positioning', async () => {
|
|
321
|
+
const cue = new shaka.text.Cue(0, 1, 'Text');
|
|
322
|
+
cue.line = 10;
|
|
323
|
+
cue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE;
|
|
324
|
+
textDisplayer.append([cue]);
|
|
325
|
+
|
|
326
|
+
await checkScreenshot(prefix, 'cue-position');
|
|
327
|
+
});
|
|
328
|
+
|
|
317
329
|
// Regression test for #2157 and #2584
|
|
318
330
|
it('region positioning', async () => {
|
|
319
331
|
const nestedCue = new shaka.text.Cue(
|
package/test/ui/ui_unit.js
CHANGED
|
@@ -409,6 +409,80 @@ describe('UI', () => {
|
|
|
409
409
|
});
|
|
410
410
|
});
|
|
411
411
|
|
|
412
|
+
describe('control panel buttons with submenus', () => {
|
|
413
|
+
/** @type {!HTMLElement} */
|
|
414
|
+
let resolutionMenu;
|
|
415
|
+
/** @type {!Element} */
|
|
416
|
+
let resolutionMenuButton;
|
|
417
|
+
/** @type {!HTMLElement} */
|
|
418
|
+
let languageMenu;
|
|
419
|
+
/** @type {!Element} */
|
|
420
|
+
let languageMenuButton;
|
|
421
|
+
|
|
422
|
+
beforeEach(() => {
|
|
423
|
+
const config = {
|
|
424
|
+
controlPanelElements: [
|
|
425
|
+
'quality',
|
|
426
|
+
'language',
|
|
427
|
+
],
|
|
428
|
+
};
|
|
429
|
+
const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
|
|
430
|
+
player = ui.getControls().getLocalPlayer();
|
|
431
|
+
|
|
432
|
+
const resolutionsMenus =
|
|
433
|
+
videoContainer.getElementsByClassName('shaka-resolutions');
|
|
434
|
+
expect(resolutionsMenus.length).toBe(1);
|
|
435
|
+
resolutionMenu = /** @type {!HTMLElement} */ (resolutionsMenus[0]);
|
|
436
|
+
|
|
437
|
+
const resolutionMenuButtons =
|
|
438
|
+
videoContainer.getElementsByClassName('shaka-resolution-button');
|
|
439
|
+
expect(resolutionMenuButtons.length).toBe(1);
|
|
440
|
+
resolutionMenuButton = resolutionMenuButtons[0];
|
|
441
|
+
|
|
442
|
+
const languageMenus =
|
|
443
|
+
videoContainer.getElementsByClassName('shaka-audio-languages');
|
|
444
|
+
expect(languageMenus.length).toBe(1);
|
|
445
|
+
languageMenu = /** @type {!HTMLElement} */ (languageMenus[0]);
|
|
446
|
+
|
|
447
|
+
const languageMenuButtons =
|
|
448
|
+
videoContainer.getElementsByClassName('shaka-language-button');
|
|
449
|
+
expect(languageMenuButtons.length).toBe(1);
|
|
450
|
+
languageMenuButton = languageMenuButtons[0];
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
it('menus are initially hidden', () => {
|
|
454
|
+
expect(resolutionMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
455
|
+
expect(languageMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it('a menu becomes visible if the button is clicked', () => {
|
|
459
|
+
resolutionMenuButton.click();
|
|
460
|
+
|
|
461
|
+
expect(resolutionMenu.classList.contains('shaka-hidden')).toBe(false);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it('a menu becomes hidden if the "close" button is clicked', () => {
|
|
465
|
+
resolutionMenuButton.click();
|
|
466
|
+
|
|
467
|
+
const backToOverflowButtons =
|
|
468
|
+
videoContainer.getElementsByClassName('shaka-back-to-overflow-button');
|
|
469
|
+
expect(backToOverflowButtons.length).toBe(2);
|
|
470
|
+
const backToOverflowButton =
|
|
471
|
+
/** @type {!HTMLElement} */ (backToOverflowButtons[0]);
|
|
472
|
+
backToOverflowButton.click();
|
|
473
|
+
|
|
474
|
+
expect(resolutionMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('a menu becomes hidden if another one is opened', () => {
|
|
478
|
+
resolutionMenuButton.click();
|
|
479
|
+
languageMenuButton.click();
|
|
480
|
+
|
|
481
|
+
expect(resolutionMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
482
|
+
expect(languageMenu.classList.contains('shaka-hidden')).toBe(false);
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
|
|
412
486
|
describe('resolutions menu', () => {
|
|
413
487
|
/** @type {!HTMLElement} */
|
|
414
488
|
let resolutionsMenu;
|
|
@@ -611,6 +685,182 @@ describe('UI', () => {
|
|
|
611
685
|
goog.asserts.assert(found, 'Unable to find resolution menu');
|
|
612
686
|
}
|
|
613
687
|
});
|
|
688
|
+
|
|
689
|
+
describe('custom context menu', () => {
|
|
690
|
+
/** @type {!HTMLElement} */
|
|
691
|
+
let controlsContainer;
|
|
692
|
+
/** @type {!HTMLElement} */
|
|
693
|
+
let contextMenu;
|
|
694
|
+
|
|
695
|
+
beforeEach(() => {
|
|
696
|
+
const config = {
|
|
697
|
+
customContextMenu: true,
|
|
698
|
+
contextMenuElements: [
|
|
699
|
+
'fakeElement',
|
|
700
|
+
'statistics',
|
|
701
|
+
'fakeElement',
|
|
702
|
+
],
|
|
703
|
+
};
|
|
704
|
+
const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
|
|
705
|
+
|
|
706
|
+
controlsContainer = ui.getControls().getControlsContainer();
|
|
707
|
+
|
|
708
|
+
const contextMenus =
|
|
709
|
+
videoContainer.getElementsByClassName('shaka-context-menu');
|
|
710
|
+
expect(contextMenus.length).toBe(1);
|
|
711
|
+
contextMenu = /** @type {!HTMLElement} */
|
|
712
|
+
(contextMenus[0]);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
it('responds to contextmenu event', () => {
|
|
716
|
+
expect(contextMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
717
|
+
UiUtils.simulateEvent(controlsContainer, 'contextmenu');
|
|
718
|
+
expect(contextMenu.classList.contains('shaka-hidden')).toBe(false);
|
|
719
|
+
UiUtils.simulateEvent(controlsContainer, 'contextmenu');
|
|
720
|
+
expect(contextMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
721
|
+
});
|
|
722
|
+
it('hides on click event', () => {
|
|
723
|
+
UiUtils.simulateEvent(controlsContainer, 'contextmenu');
|
|
724
|
+
UiUtils.simulateEvent(controlsContainer, 'click');
|
|
725
|
+
expect(contextMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
726
|
+
UiUtils.simulateEvent(controlsContainer, 'contextmenu');
|
|
727
|
+
UiUtils.simulateEvent(window, 'click');
|
|
728
|
+
expect(contextMenu.classList.contains('shaka-hidden')).toBe(true);
|
|
729
|
+
});
|
|
730
|
+
it('builds internal elements', () => {
|
|
731
|
+
expect(contextMenu.childNodes.length).toBe(1);
|
|
732
|
+
|
|
733
|
+
expect(contextMenu.childNodes[0]['className'])
|
|
734
|
+
.toBe('shaka-statistics-button');
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
describe('statistics context menu', () => {
|
|
739
|
+
/** @type {!HTMLElement} */
|
|
740
|
+
let statisticsButton;
|
|
741
|
+
/** @type {!HTMLElement} */
|
|
742
|
+
let statisticsContainer;
|
|
743
|
+
|
|
744
|
+
beforeEach(() => {
|
|
745
|
+
const config = {
|
|
746
|
+
customContextMenu: true,
|
|
747
|
+
contextMenuElements: [
|
|
748
|
+
'statistics',
|
|
749
|
+
],
|
|
750
|
+
statisticsList: Object.keys(new shaka.util.Stats().getBlob()),
|
|
751
|
+
};
|
|
752
|
+
const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
|
|
753
|
+
player = ui.getControls().getLocalPlayer();
|
|
754
|
+
|
|
755
|
+
const statisticsButtons =
|
|
756
|
+
videoContainer.getElementsByClassName('shaka-statistics-button');
|
|
757
|
+
expect(statisticsButtons.length).toBe(1);
|
|
758
|
+
statisticsButton = /** @type {!HTMLElement} */
|
|
759
|
+
(statisticsButtons[0]);
|
|
760
|
+
|
|
761
|
+
const statisticsContainers =
|
|
762
|
+
videoContainer.getElementsByClassName('shaka-statistics-container');
|
|
763
|
+
expect(statisticsContainers.length).toBe(1);
|
|
764
|
+
statisticsContainer = /** @type {!HTMLElement} */
|
|
765
|
+
(statisticsContainers[0]);
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
it('appears and disappears on toggle', () => {
|
|
769
|
+
expect(statisticsContainer.classList.contains('shaka-hidden'))
|
|
770
|
+
.toBe(true);
|
|
771
|
+
|
|
772
|
+
statisticsButton.click();
|
|
773
|
+
expect(statisticsContainer.classList.contains('shaka-hidden'))
|
|
774
|
+
.toBe(false);
|
|
775
|
+
|
|
776
|
+
statisticsButton.click();
|
|
777
|
+
expect(statisticsContainer.classList.contains('shaka-hidden'))
|
|
778
|
+
.toBe(true);
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
it('displays all the available statistics', () => {
|
|
782
|
+
const skippedStats = ['stateHistory', 'switchHistory'];
|
|
783
|
+
const nodes = statisticsContainer.childNodes;
|
|
784
|
+
let nodeIndex = 0;
|
|
785
|
+
|
|
786
|
+
for (const statistic in new shaka.util.Stats().getBlob()) {
|
|
787
|
+
if (!skippedStats.includes(statistic)) {
|
|
788
|
+
// Text content of label (without ':') is a valid statistic
|
|
789
|
+
const label = nodes[nodeIndex].childNodes[0].textContent;
|
|
790
|
+
expect(label.replace(':', '')).toBe(statistic);
|
|
791
|
+
|
|
792
|
+
// Value has been parsed and it is not the default 'NaN'
|
|
793
|
+
const value = nodes[nodeIndex].childNodes[1].textContent;
|
|
794
|
+
expect(value).not.toBe('NaN');
|
|
795
|
+
|
|
796
|
+
nodeIndex += 1;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
it('is updated periodically', async () => {
|
|
801
|
+
function getStatsFromContainer() {
|
|
802
|
+
const nodes = statisticsContainer.childNodes;
|
|
803
|
+
width = nodes[0].childNodes[1].textContent.replace(' (px)', '');
|
|
804
|
+
height = nodes[1].childNodes[1].textContent.replace(' (px)', '');
|
|
805
|
+
bufferingTime =
|
|
806
|
+
nodes[13].childNodes[1].textContent.replace(' (s)', '');
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/** @type {!string} */
|
|
810
|
+
let width;
|
|
811
|
+
/** @type {!string} */
|
|
812
|
+
let height;
|
|
813
|
+
/** @type {!string} */
|
|
814
|
+
let bufferingTime;
|
|
815
|
+
/** @type {!string} */
|
|
816
|
+
let lastBufferingTime;
|
|
817
|
+
|
|
818
|
+
const manifest =
|
|
819
|
+
shaka.test.ManifestGenerator.generate((manifest) => {
|
|
820
|
+
manifest.addVariant(/* id= */ 0, (variant) => {
|
|
821
|
+
variant.addVideo(1, (stream) => {
|
|
822
|
+
stream.size(1920, 1080);
|
|
823
|
+
});
|
|
824
|
+
});
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
shaka.media.ManifestParser.registerParserByMime(
|
|
828
|
+
fakeMimeType, () => new shaka.test.FakeManifestParser(manifest));
|
|
829
|
+
|
|
830
|
+
await player.load(
|
|
831
|
+
/* uri= */ 'fake', /* startTime= */ 0, fakeMimeType);
|
|
832
|
+
|
|
833
|
+
// Placeholder statistics are available before toggle
|
|
834
|
+
getStatsFromContainer();
|
|
835
|
+
expect(width).toBe('NaN');
|
|
836
|
+
expect(height).toBe('NaN');
|
|
837
|
+
expect(bufferingTime).toBe('NaN');
|
|
838
|
+
|
|
839
|
+
// Statistics are displayed on toggle
|
|
840
|
+
statisticsButton.click();
|
|
841
|
+
await Util.delay(0.2);
|
|
842
|
+
|
|
843
|
+
getStatsFromContainer();
|
|
844
|
+
expect(width).toBe('1920');
|
|
845
|
+
expect(height).toBe('1080');
|
|
846
|
+
expect(bufferingTime).toBeGreaterThanOrEqual(0.1);
|
|
847
|
+
|
|
848
|
+
// Statistics are updated over time
|
|
849
|
+
lastBufferingTime = bufferingTime;
|
|
850
|
+
await Util.delay(0.2);
|
|
851
|
+
|
|
852
|
+
getStatsFromContainer();
|
|
853
|
+
expect(bufferingTime).toBeGreaterThan(lastBufferingTime);
|
|
854
|
+
|
|
855
|
+
// Statistics stop updating when the container is hidden
|
|
856
|
+
statisticsButton.click();
|
|
857
|
+
lastBufferingTime = bufferingTime;
|
|
858
|
+
await Util.delay(0.2);
|
|
859
|
+
|
|
860
|
+
getStatsFromContainer();
|
|
861
|
+
expect(bufferingTime).toBe(lastBufferingTime);
|
|
862
|
+
});
|
|
863
|
+
});
|
|
614
864
|
});
|
|
615
865
|
|
|
616
866
|
|