shaka-player 4.0.4 → 4.0.5
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/workflows/build-and-test.yaml +67 -15
- package/.github/workflows/compute-incremental-coverage.py +251 -0
- package/.github/workflows/report-incremental-coverage.yaml +39 -0
- package/.github/workflows/selenium-lab-tests.yaml +44 -1
- package/AUTHORS +1 -0
- package/CHANGELOG.md +17 -0
- package/CONTRIBUTORS +1 -0
- package/demo/index.html +1 -1
- package/dist/controls.css +1 -1
- package/dist/locales.js +30 -30
- package/dist/shaka-player.compiled.d.ts +1 -1
- package/dist/shaka-player.compiled.debug.d.ts +1 -1
- package/dist/shaka-player.compiled.debug.externs.js +1 -1
- package/dist/shaka-player.compiled.debug.js +80 -77
- package/dist/shaka-player.compiled.debug.map +3 -3
- package/dist/shaka-player.compiled.externs.js +1 -1
- package/dist/shaka-player.compiled.js +763 -761
- package/dist/shaka-player.compiled.map +3 -3
- package/dist/shaka-player.ui.d.ts +1 -1
- package/dist/shaka-player.ui.debug.d.ts +1 -1
- package/dist/shaka-player.ui.debug.externs.js +1 -1
- package/dist/shaka-player.ui.debug.js +93 -90
- package/dist/shaka-player.ui.debug.map +3 -3
- package/dist/shaka-player.ui.externs.js +1 -1
- package/dist/shaka-player.ui.js +910 -908
- package/dist/shaka-player.ui.map +3 -3
- package/docs/tutorials/ui.md +5 -5
- package/karma.conf.js +3 -11
- package/lib/ads/client_side_ad_manager.js +1 -1
- package/lib/media/drm_engine.js +1 -1
- package/lib/media/streaming_engine.js +1 -0
- package/lib/player.js +1 -6
- package/lib/polyfill/media_capabilities.js +6 -0
- package/lib/text/cue.js +0 -5
- package/lib/text/simple_text_displayer.js +21 -9
- package/lib/text/ui_text_displayer.js +83 -19
- package/lib/util/buffer_utils.js +3 -0
- package/lib/util/object_utils.js +1 -0
- package/lib/util/stream_utils.js +23 -3
- package/lib/util/string_utils.js +63 -16
- package/package.json +2 -2
- package/test/text/simple_text_displayer_unit.js +27 -0
- package/test/text/ui_text_displayer_unit.js +65 -0
- package/test/util/string_utils_unit.js +46 -8
- package/ui/text_selection.js +2 -2
|
@@ -50,6 +50,7 @@ describe('UITextDisplayer', () => {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
beforeEach(() => {
|
|
53
|
+
video.currentTime = 0;
|
|
53
54
|
textDisplayer = new shaka.text.UITextDisplayer(video, videoContainer);
|
|
54
55
|
});
|
|
55
56
|
|
|
@@ -396,4 +397,68 @@ describe('UITextDisplayer', () => {
|
|
|
396
397
|
expect(parentCueElements.length).toBe(1);
|
|
397
398
|
expect(parentCueElements[0].textContent).toBe('');
|
|
398
399
|
});
|
|
400
|
+
|
|
401
|
+
it('creates separate elements for cue regions', () => {
|
|
402
|
+
const cueRegion = new shaka.text.CueRegion();
|
|
403
|
+
cueRegion.id = 'regionId';
|
|
404
|
+
cueRegion.height = 80;
|
|
405
|
+
cueRegion.heightUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
406
|
+
cueRegion.width = 80;
|
|
407
|
+
cueRegion.widthUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
408
|
+
cueRegion.viewportAnchorX = 10;
|
|
409
|
+
cueRegion.viewportAnchorY = 10;
|
|
410
|
+
cueRegion.viewportAnchorUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
411
|
+
|
|
412
|
+
// These all attach to the same region, but only one region element should
|
|
413
|
+
// be created.
|
|
414
|
+
const cues = [
|
|
415
|
+
new shaka.text.Cue(0, 100, ''),
|
|
416
|
+
new shaka.text.Cue(0, 100, ''),
|
|
417
|
+
new shaka.text.Cue(0, 100, ''),
|
|
418
|
+
];
|
|
419
|
+
for (const cue of cues) {
|
|
420
|
+
cue.displayAlign = shaka.text.Cue.displayAlign.CENTER;
|
|
421
|
+
cue.region = cueRegion;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
textDisplayer.setTextVisibility(true);
|
|
425
|
+
textDisplayer.append(cues);
|
|
426
|
+
updateCaptions();
|
|
427
|
+
|
|
428
|
+
const textContainer = videoContainer.querySelector('.shaka-text-container');
|
|
429
|
+
const allRegionElements = textContainer.querySelectorAll(
|
|
430
|
+
'.shaka-text-region');
|
|
431
|
+
|
|
432
|
+
// Verify that the nested cues are all attached to a single region element.
|
|
433
|
+
expect(allRegionElements.length).toBe(1);
|
|
434
|
+
const regionElement = allRegionElements[0];
|
|
435
|
+
const children = Array.from(regionElement.childNodes).filter(
|
|
436
|
+
(e) => e.nodeType == Node.ELEMENT_NODE);
|
|
437
|
+
expect(children.length).toBe(3);
|
|
438
|
+
|
|
439
|
+
// Verify styles applied to the region element.
|
|
440
|
+
const regionCssObj = parseCssText(regionElement.style.cssText);
|
|
441
|
+
const expectRegionCssObj = {
|
|
442
|
+
'position': 'absolute',
|
|
443
|
+
'height': '80%',
|
|
444
|
+
'width': '80%',
|
|
445
|
+
'top': '10%',
|
|
446
|
+
'left': '10%',
|
|
447
|
+
'display': 'flex',
|
|
448
|
+
'flex-direction': 'column',
|
|
449
|
+
'align-items': 'center',
|
|
450
|
+
'justify-content': 'center',
|
|
451
|
+
};
|
|
452
|
+
expect(regionCssObj).toEqual(jasmine.objectContaining(expectRegionCssObj));
|
|
453
|
+
|
|
454
|
+
for (const caption of children) {
|
|
455
|
+
// Verify that styles applied to the nested cues _DO NOT_ include region
|
|
456
|
+
// placement.
|
|
457
|
+
const cueCssObj = parseCssText(caption.style.cssText);
|
|
458
|
+
expect(Object.keys(cueCssObj)).not.toContain('height');
|
|
459
|
+
expect(Object.keys(cueCssObj)).not.toContain('width');
|
|
460
|
+
expect(Object.keys(cueCssObj)).not.toContain('top');
|
|
461
|
+
expect(Object.keys(cueCssObj)).not.toContain('left');
|
|
462
|
+
}
|
|
463
|
+
});
|
|
399
464
|
});
|
|
@@ -5,6 +5,29 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
describe('StringUtils', () => {
|
|
8
|
+
describe('with TextDecoder', () => {
|
|
9
|
+
if (window.TextDecoder) {
|
|
10
|
+
defineStringUtilTests();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('without TextDecoder', () => {
|
|
15
|
+
let originalTextDecoder;
|
|
16
|
+
|
|
17
|
+
beforeAll(() => {
|
|
18
|
+
originalTextDecoder = window.TextDecoder;
|
|
19
|
+
window['TextDecoder'] = null;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterAll(() => {
|
|
23
|
+
window.TextDecoder = originalTextDecoder;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
defineStringUtilTests();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function defineStringUtilTests() {
|
|
8
31
|
const StringUtils = shaka.util.StringUtils;
|
|
9
32
|
|
|
10
33
|
it('parses fromUTF8', () => {
|
|
@@ -16,19 +39,34 @@ describe('StringUtils', () => {
|
|
|
16
39
|
});
|
|
17
40
|
|
|
18
41
|
it('won\'t break if given cut-off UTF8 character', () => {
|
|
19
|
-
|
|
20
|
-
// at the very end of the string.
|
|
21
|
-
const arr1 = [0x53, 0x61, 0x6e, 0x20, 0x4a, 0x6f, 0x73, 0x81];
|
|
42
|
+
const arr1 = [0x53, 0x61, 0x6e, 0x20, 0x4a, 0x6f, 0x73, 0xc3, 0xa9];
|
|
22
43
|
expect(StringUtils.fromUTF8(new Uint8Array(arr1)))
|
|
44
|
+
.toBe('San Jos\u00E9');
|
|
45
|
+
|
|
46
|
+
// This array contains the first half of a 2-byte UTF8 character
|
|
47
|
+
// (0xc3 0xa9 = é). The half-character is stranded at the very end of the
|
|
48
|
+
// string.
|
|
49
|
+
const arr = [0x53, 0x61, 0x6e, 0x20, 0x4a, 0x6f, 0x73, 0xc3];
|
|
50
|
+
expect(StringUtils.fromUTF8(new Uint8Array(arr)))
|
|
23
51
|
.toBe('San Jos\uFFFD');
|
|
52
|
+
});
|
|
24
53
|
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
expect(StringUtils.fromUTF8(new Uint8Array(
|
|
54
|
+
it('won\'t break if given an invalid UTF-8 sequence', () => {
|
|
55
|
+
// 0xe9 0x33 0x33 is an invalid UTF-8 sequence.
|
|
56
|
+
const arr = [0x4a, 0x6f, 0x73, 0xE9, 0x33, 0x33, 0x20, 0x53, 0x61, 0x6e];
|
|
57
|
+
expect(StringUtils.fromUTF8(new Uint8Array(arr)))
|
|
29
58
|
.toBe('Jos\uFFFD33 San');
|
|
30
59
|
});
|
|
31
60
|
|
|
61
|
+
it('can handle an 8-byte character', () => {
|
|
62
|
+
// This is the UTF-8 encoding of the US flag emoji.
|
|
63
|
+
// It decodes into two Unicode codepoints, which becomes 4 JavaScript
|
|
64
|
+
// UTF-16 characters.
|
|
65
|
+
const arr = [0xf0, 0x9f, 0x87, 0xba, 0xf0, 0x9f, 0x87, 0xb8];
|
|
66
|
+
expect(StringUtils.fromUTF8(new Uint8Array(arr)))
|
|
67
|
+
.toBe('\uD83C\uDDFA\uD83C\uDDF8');
|
|
68
|
+
});
|
|
69
|
+
|
|
32
70
|
it('strips the BOM in fromUTF8', () => {
|
|
33
71
|
// This is 4 Unicode characters, the last will be split into a surrogate
|
|
34
72
|
// pair.
|
|
@@ -125,4 +163,4 @@ describe('StringUtils', () => {
|
|
|
125
163
|
expect(StringUtils.fromUTF16(buffer, true).length)
|
|
126
164
|
.toBe(buffer.byteLength / 2);
|
|
127
165
|
});
|
|
128
|
-
}
|
|
166
|
+
}
|
package/ui/text_selection.js
CHANGED
|
@@ -111,11 +111,11 @@ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu {
|
|
|
111
111
|
onCaptionStateChange_() {
|
|
112
112
|
if (this.player.isTextTrackVisible()) {
|
|
113
113
|
this.icon.textContent =
|
|
114
|
-
shaka.ui.Enums.MaterialDesignIcons.
|
|
114
|
+
shaka.ui.Enums.MaterialDesignIcons.CLOSED_CAPTIONS;
|
|
115
115
|
this.button.ariaPressed = 'true';
|
|
116
116
|
} else {
|
|
117
117
|
this.icon.textContent =
|
|
118
|
-
shaka.ui.Enums.MaterialDesignIcons.
|
|
118
|
+
shaka.ui.Enums.MaterialDesignIcons.CLOSED_CAPTIONS_OFF;
|
|
119
119
|
this.button.ariaPressed = 'false';
|
|
120
120
|
}
|
|
121
121
|
|