shaka-player 4.1.2 → 4.1.3

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.
Files changed (45) hide show
  1. package/.github/workflows/build-and-test.yaml +67 -15
  2. package/.github/workflows/compute-incremental-coverage.py +251 -0
  3. package/.github/workflows/report-incremental-coverage.yaml +39 -0
  4. package/.github/workflows/selenium-lab-tests.yaml +44 -1
  5. package/AUTHORS +1 -0
  6. package/CHANGELOG.md +16 -0
  7. package/CONTRIBUTORS +1 -0
  8. package/demo/index.html +1 -1
  9. package/dist/controls.css +1 -1
  10. package/dist/locales.js +30 -30
  11. package/dist/shaka-player.compiled.d.ts +1 -1
  12. package/dist/shaka-player.compiled.debug.d.ts +1 -1
  13. package/dist/shaka-player.compiled.debug.externs.js +1 -1
  14. package/dist/shaka-player.compiled.debug.js +79 -76
  15. package/dist/shaka-player.compiled.debug.map +3 -3
  16. package/dist/shaka-player.compiled.externs.js +1 -1
  17. package/dist/shaka-player.compiled.js +771 -769
  18. package/dist/shaka-player.compiled.map +3 -3
  19. package/dist/shaka-player.ui.d.ts +1 -1
  20. package/dist/shaka-player.ui.debug.d.ts +1 -1
  21. package/dist/shaka-player.ui.debug.externs.js +1 -1
  22. package/dist/shaka-player.ui.debug.js +92 -90
  23. package/dist/shaka-player.ui.debug.map +3 -3
  24. package/dist/shaka-player.ui.externs.js +1 -1
  25. package/dist/shaka-player.ui.js +905 -903
  26. package/dist/shaka-player.ui.map +3 -3
  27. package/docs/tutorials/ui.md +6 -6
  28. package/karma.conf.js +3 -11
  29. package/lib/ads/client_side_ad_manager.js +1 -1
  30. package/lib/media/drm_engine.js +1 -1
  31. package/lib/media/streaming_engine.js +1 -0
  32. package/lib/player.js +1 -6
  33. package/lib/polyfill/media_capabilities.js +6 -0
  34. package/lib/text/cue.js +0 -5
  35. package/lib/text/simple_text_displayer.js +21 -9
  36. package/lib/text/ui_text_displayer.js +83 -19
  37. package/lib/util/buffer_utils.js +3 -0
  38. package/lib/util/object_utils.js +1 -0
  39. package/lib/util/stream_utils.js +23 -3
  40. package/lib/util/string_utils.js +63 -16
  41. package/package.json +2 -2
  42. package/test/text/simple_text_displayer_unit.js +27 -0
  43. package/test/text/ui_text_displayer_unit.js +65 -0
  44. package/test/util/string_utils_unit.js +46 -8
  45. 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
- // This array contains the first half of a 2-byte UTF8 character, stranded
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
- // For reasons I don't know, it seems like 0xE9 cannot be the start of a
26
- // UTF8 character. Perhaps it is a reserved number?
27
- const arr2 = [0x4a, 0x6f, 0x73, 0xE9, 0x33, 0x33, 0x20, 0x53, 0x61, 0x6e];
28
- expect(StringUtils.fromUTF8(new Uint8Array(arr2)))
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
+ }
@@ -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.CLOSED_CAPTIONS_OFF;
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.CLOSED_CAPTIONS;
118
+ shaka.ui.Enums.MaterialDesignIcons.CLOSED_CAPTIONS_OFF;
119
119
  this.button.ariaPressed = 'false';
120
120
  }
121
121