shaka-player 4.2.0 → 4.2.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.
Files changed (88) hide show
  1. package/.github/workflows/build-and-test.yaml +31 -16
  2. package/.github/workflows/custom-actions/set-commit-status/action.yaml +1 -5
  3. package/.github/workflows/deflake.yaml +28 -0
  4. package/.github/workflows/selenium-lab-tests.yaml +168 -54
  5. package/AUTHORS +3 -0
  6. package/CHANGELOG.md +30 -0
  7. package/CONTRIBUTORS +3 -0
  8. package/demo/common/message_ids.js +1 -0
  9. package/demo/config.js +3 -1
  10. package/demo/locales/en.json +1 -0
  11. package/demo/locales/source.json +4 -0
  12. package/dist/controls.css +1 -1
  13. package/dist/controls.css.map +1 -1
  14. package/dist/demo.compiled.debug.js +7 -6
  15. package/dist/demo.compiled.debug.map +3 -3
  16. package/dist/demo.compiled.js +7 -6
  17. package/dist/demo.compiled.map +3 -3
  18. package/dist/deps.js +2 -2
  19. package/dist/locales.js +29 -29
  20. package/dist/receiver.compiled.debug.js +4 -3
  21. package/dist/receiver.compiled.debug.map +3 -3
  22. package/dist/receiver.compiled.js +4 -3
  23. package/dist/receiver.compiled.map +3 -3
  24. package/dist/shaka-player.compiled.d.ts +2 -4
  25. package/dist/shaka-player.compiled.debug.d.ts +2 -4
  26. package/dist/shaka-player.compiled.debug.externs.js +24 -26
  27. package/dist/shaka-player.compiled.debug.js +267 -260
  28. package/dist/shaka-player.compiled.debug.map +4 -4
  29. package/dist/shaka-player.compiled.externs.js +24 -26
  30. package/dist/shaka-player.compiled.js +809 -807
  31. package/dist/shaka-player.compiled.map +4 -4
  32. package/dist/shaka-player.ui.d.ts +2 -4
  33. package/dist/shaka-player.ui.debug.d.ts +2 -4
  34. package/dist/shaka-player.ui.debug.externs.js +24 -26
  35. package/dist/shaka-player.ui.debug.js +244 -236
  36. package/dist/shaka-player.ui.debug.map +4 -4
  37. package/dist/shaka-player.ui.externs.js +24 -26
  38. package/dist/shaka-player.ui.js +973 -971
  39. package/dist/shaka-player.ui.map +4 -4
  40. package/docs/jsdoc-template/publish.js +33 -0
  41. package/docs/jsdoc-template/tmpl/container.tmpl +4 -1
  42. package/docs/jsdoc.conf.json +1 -0
  43. package/externs/shaka/manifest_parser.js +4 -1
  44. package/externs/shaka/player.js +7 -1
  45. package/lib/ads/client_side_ad_manager.js +7 -0
  46. package/lib/cast/cast_sender.js +39 -14
  47. package/lib/cea/cea608_memory.js +4 -0
  48. package/lib/hls/hls_parser.js +54 -82
  49. package/lib/media/drm_engine.js +52 -1
  50. package/lib/media/media_source_engine.js +43 -15
  51. package/lib/media/segment_index.js +4 -1
  52. package/lib/media/streaming_engine.js +79 -14
  53. package/lib/offline/storage.js +1 -0
  54. package/lib/player.js +29 -5
  55. package/lib/text/ttml_text_parser.js +6 -0
  56. package/lib/text/ui_text_displayer.js +8 -0
  57. package/lib/util/error.js +2 -10
  58. package/lib/util/platform.js +24 -0
  59. package/lib/util/player_configuration.js +5 -0
  60. package/lib/util/pssh.js +2 -1
  61. package/lib/util/stream_utils.js +2 -1
  62. package/package.json +1 -1
  63. package/test/cea/cea608_memory_unit.js +88 -0
  64. package/test/dash/dash_parser_content_protection_unit.js +1 -0
  65. package/test/dash/dash_parser_live_unit.js +1 -0
  66. package/test/dash/dash_parser_manifest_unit.js +1 -0
  67. package/test/dash/dash_parser_segment_base_unit.js +1 -0
  68. package/test/dash/dash_parser_segment_list_unit.js +1 -0
  69. package/test/dash/dash_parser_segment_template_unit.js +1 -0
  70. package/test/hls/hls_live_unit.js +169 -247
  71. package/test/hls/hls_parser_unit.js +112 -3
  72. package/test/media/drm_engine_unit.js +90 -0
  73. package/test/media/media_source_engine_integration.js +36 -0
  74. package/test/media/media_source_engine_unit.js +118 -1
  75. package/test/media/segment_index_unit.js +28 -2
  76. package/test/media/streaming_engine_integration.js +9 -7
  77. package/test/media/streaming_engine_unit.js +29 -0
  78. package/test/offline/offline_integration.js +3 -3
  79. package/test/player_integration.js +2 -2
  80. package/test/player_src_equals_integration.js +2 -0
  81. package/test/player_unit.js +39 -1
  82. package/test/test/assets/small.mp4 +0 -0
  83. package/test/test/util/dash_parser_util.js +2 -0
  84. package/test/test/util/ttml_utils.js +0 -2
  85. package/test/text/ttml_text_parser_unit.js +46 -0
  86. package/test/ui/text_displayer_layout_unit.js +17 -2
  87. package/ui/controls.js +0 -7
  88. package/ui/less/ad_controls.less +4 -0
@@ -422,7 +422,6 @@ describe('Player', () => {
422
422
  dispatchEventSpy.calls.reset();
423
423
  player.configure({streaming: {maxDisabledTime}});
424
424
  player.setMaxHardwareResolution(123, 456);
425
- onErrorCallback(httpError);
426
425
  });
427
426
 
428
427
  afterEach(() => {
@@ -434,14 +433,18 @@ describe('Player', () => {
434
433
  });
435
434
 
436
435
  it('handles HTTP_ERROR', () => {
436
+ onErrorCallback(httpError);
437
437
  expect(httpError.handled).toBeTruthy();
438
438
  });
439
439
 
440
440
  it('does not dispatch any error', () => {
441
+ onErrorCallback(httpError);
441
442
  expect(dispatchEventSpy).not.toHaveBeenCalled();
442
443
  });
443
444
 
444
445
  it('disables the current variant and applies restrictions', () => {
446
+ onErrorCallback(httpError);
447
+
445
448
  const foundDisabledVariant =
446
449
  manifest.variants.some(({disabledUntilTime}) =>
447
450
  disabledUntilTime == currentTime + maxDisabledTime);
@@ -453,11 +456,46 @@ describe('Player', () => {
453
456
  });
454
457
 
455
458
  it('switches the variant', () => {
459
+ onErrorCallback(httpError);
460
+
456
461
  expect(chooseVariantSpy).toHaveBeenCalled();
457
462
  expect(getBufferedInfoSpy).toHaveBeenCalled();
458
463
  expect(switchVariantSpy)
459
464
  .toHaveBeenCalledWith(chosenVariant, false, true, 14);
460
465
  });
466
+
467
+ describe('but browser is truly offline', () => {
468
+ /** @type {!Object} */
469
+ let navigatorOnLineDescriptor;
470
+
471
+ // eslint-disable-next-line no-restricted-syntax
472
+ const navigatorPrototype = Navigator.prototype;
473
+
474
+ beforeAll(() => {
475
+ navigatorOnLineDescriptor =
476
+ /** @type {!Object} */(Object.getOwnPropertyDescriptor(
477
+ navigatorPrototype, 'onLine'));
478
+ });
479
+
480
+ beforeEach(() => {
481
+ // Redefine the property, replacing only the getter.
482
+ Object.defineProperty(navigatorPrototype, 'onLine',
483
+ Object.assign(navigatorOnLineDescriptor, {
484
+ get: () => false,
485
+ }));
486
+ });
487
+
488
+ afterEach(() => {
489
+ // Restore the original property definition.
490
+ Object.defineProperty(
491
+ navigatorPrototype, 'onLine', navigatorOnLineDescriptor);
492
+ });
493
+
494
+ it('does not handle HTTP_ERROR', () => {
495
+ onErrorCallback(httpError);
496
+ expect(httpError.handled).toBe(false);
497
+ });
498
+ });
461
499
  });
462
500
  });
463
501
  });
Binary file
@@ -43,6 +43,7 @@ shaka.test.Dash = class {
43
43
  isLowLatencyMode: () => false,
44
44
  isAutoLowLatencyMode: () => false,
45
45
  enableLowLatencyMode: () => {},
46
+ updateDuration: () => {},
46
47
  };
47
48
  const manifest = await dashParser.start('dummy://foo', playerInterface);
48
49
  const stream = manifest.variants[0].video;
@@ -77,6 +78,7 @@ shaka.test.Dash = class {
77
78
  isLowLatencyMode: () => false,
78
79
  isAutoLowLatencyMode: () => false,
79
80
  enableLowLatencyMode: () => {},
81
+ updateDuration: () => {},
80
82
  };
81
83
  const p = dashParser.start('dummy://foo', playerInterface);
82
84
  await expectAsync(p).toBeRejectedWith(
@@ -51,8 +51,6 @@ shaka.test.TtmlUtils = class {
51
51
  region,
52
52
  nestedCues: jasmine.any(Object),
53
53
  payload: '',
54
- startTime: 0,
55
- endTime: Infinity,
56
54
  isContainer: true,
57
55
  });
58
56
  Object.assign(containerCue, properties);
@@ -1535,6 +1535,52 @@ describe('TtmlTextParser', () => {
1535
1535
  {startTime: 1, endTime: 2});
1536
1536
  });
1537
1537
 
1538
+ // Regression test for #4468
1539
+ it('defaults the body background to transparent', () => {
1540
+ verifyHelper(
1541
+ // One cue, don't care about the details
1542
+ [{}],
1543
+ '<tt xmlns:tts="http://www.w3.org/ns/ttml#styling">' +
1544
+ '<head>' +
1545
+ '<styling>' +
1546
+ '<style xml:id="s1" tts:backgroundColor="black" />' +
1547
+ '</styling>' +
1548
+ '</head>' +
1549
+ '<body><div>' +
1550
+ '<p begin="00:01.00" end="00:02.00">' +
1551
+ '<span style="s1">Test</span>' +
1552
+ '</p>' +
1553
+ '</div></body></tt>',
1554
+ {periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0},
1555
+ // The body must have these properties:
1556
+ {backgroundColor: 'transparent'},
1557
+ // The div must have these properties:
1558
+ {}); // don't care
1559
+ });
1560
+
1561
+ // Regression test for #4468
1562
+ it('allows the body background color to be set', () => {
1563
+ verifyHelper(
1564
+ // One cue, don't care about the details
1565
+ [{}],
1566
+ '<tt xmlns:tts="http://www.w3.org/ns/ttml#styling">' +
1567
+ '<head>' +
1568
+ '<styling>' +
1569
+ '<style xml:id="s1" tts:backgroundColor="black" />' +
1570
+ '</styling>' +
1571
+ '</head>' +
1572
+ '<body style="s1"><div>' +
1573
+ '<p begin="00:01.00" end="00:02.00">' +
1574
+ '<span>Test</span>' +
1575
+ '</p>' +
1576
+ '</div></body></tt>',
1577
+ {periodStart: 0, segmentStart: 0, segmentEnd: 0, vttOffset: 0},
1578
+ // The body must have these properties:
1579
+ {backgroundColor: 'black'},
1580
+ // The div must have these properties:
1581
+ {}); // don't care
1582
+ });
1583
+
1538
1584
  it('parses wrapping option', () => {
1539
1585
  verifyHelper(
1540
1586
  [
@@ -219,6 +219,21 @@ filterDescribe('TextDisplayer layout', supportsScreenshots, () => {
219
219
 
220
220
  /** @param {string} prefix Prepended to screenshot names */
221
221
  function defineTests(prefix) {
222
+ // Due to a Safari implementation bug, the browser only does the correct
223
+ // thing for "end-time-edge-case" on Safari 16+. Skip the tests on earlier
224
+ // versions.
225
+ const safariVersion = shaka.util.Platform.safariVersion();
226
+ if (prefix == 'native' && safariVersion && safariVersion < 16) {
227
+ return;
228
+ }
229
+
230
+ // Due to updates in the rendering and/or default styles in Chrome, the
231
+ // screenshots for native rendering only match in Chrome 106+.
232
+ const chromeVersion = shaka.util.Platform.chromeVersion();
233
+ if (prefix == 'native' && chromeVersion && chromeVersion < 106) {
234
+ return;
235
+ }
236
+
222
237
  it('basic cue', async () => {
223
238
  textDisplayer.append([
224
239
  new shaka.text.Cue(0, 1, 'Captain\'s log, stardate 41636.9'),
@@ -262,8 +277,8 @@ filterDescribe('TextDisplayer layout', supportsScreenshots, () => {
262
277
 
263
278
  // Regression test for #3151
264
279
  // Only one cue should be displayed. Note, however, that we don't control
265
- // this in a browser's native display. As of Feb 2021, only Firefox does
266
- // the right thing in native text display. Chrome, Edge, and Safari all
280
+ // this in a browser's native display. As of Sep 2022, both Firefox and
281
+ // Safari>=16 do the right thing in native text display. Chrome and Edge
267
282
  // show both cues in this edge case. When we control the display of text
268
283
  // through the UI & DOM, we can always get the timing right.
269
284
  it('cues ending exactly now', async () => {
package/ui/controls.js CHANGED
@@ -1011,13 +1011,6 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
1011
1011
  await this.onScreenRotation_();
1012
1012
  });
1013
1013
  }
1014
-
1015
- this.eventManager_.listen(document, 'fullscreenchange', () => {
1016
- if (this.ad_) {
1017
- this.ad_.resize(
1018
- this.localVideo_.offsetWidth, this.localVideo_.offsetHeight);
1019
- }
1020
- });
1021
1014
  }
1022
1015
 
1023
1016
 
@@ -71,6 +71,10 @@
71
71
  .ad-text-shadow();
72
72
  }
73
73
 
74
+ .shaka-ad-controls .shaka-ad-position:not(.shaka-hidden) + .shaka-ad-counter {
75
+ margin-left: 0.75em;
76
+ }
77
+
74
78
  .shaka-skip-ad-container {
75
79
  /* Skip button is positioned at the very right edge of the
76
80
  * video container unlike the rest of the bottom controls. */