shaka-player 4.5.0 → 4.6.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.
Files changed (214) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  2. package/AUTHORS +2 -0
  3. package/CHANGELOG.md +109 -0
  4. package/CODE_OF_CONDUCT.md +1 -1
  5. package/CONTRIBUTORS +2 -0
  6. package/README.md +38 -32
  7. package/demo/common/asset.js +11 -17
  8. package/demo/common/assets.js +117 -11
  9. package/demo/config.js +28 -1
  10. package/demo/custom.js +52 -38
  11. package/demo/main.js +11 -3
  12. package/demo/search.js +7 -0
  13. package/dist/controls.css +1 -1
  14. package/dist/controls.css.map +1 -1
  15. package/dist/demo.compiled.debug.js +133 -124
  16. package/dist/demo.compiled.debug.map +3 -3
  17. package/dist/demo.compiled.js +133 -124
  18. package/dist/demo.compiled.map +3 -3
  19. package/dist/deps.js +20 -18
  20. package/dist/locales.js +34 -30
  21. package/dist/receiver.compiled.debug.js +58 -50
  22. package/dist/receiver.compiled.debug.map +3 -3
  23. package/dist/receiver.compiled.js +58 -50
  24. package/dist/receiver.compiled.map +3 -3
  25. package/dist/shaka-player.compiled.d.ts +440 -390
  26. package/dist/shaka-player.compiled.debug.d.ts +440 -390
  27. package/dist/shaka-player.compiled.debug.externs.js +162 -77
  28. package/dist/shaka-player.compiled.debug.js +789 -738
  29. package/dist/shaka-player.compiled.debug.map +4 -4
  30. package/dist/shaka-player.compiled.externs.js +162 -77
  31. package/dist/shaka-player.compiled.js +1147 -1113
  32. package/dist/shaka-player.compiled.map +4 -4
  33. package/dist/shaka-player.ui.d.ts +491 -437
  34. package/dist/shaka-player.ui.debug.d.ts +491 -437
  35. package/dist/shaka-player.ui.debug.externs.js +167 -77
  36. package/dist/shaka-player.ui.debug.js +857 -791
  37. package/dist/shaka-player.ui.debug.map +4 -4
  38. package/dist/shaka-player.ui.externs.js +167 -77
  39. package/dist/shaka-player.ui.js +1359 -1314
  40. package/dist/shaka-player.ui.map +4 -4
  41. package/docs/tutorials/ad_monetization.md +54 -0
  42. package/docs/tutorials/basic-usage.md +2 -1
  43. package/docs/tutorials/errors.md +2 -1
  44. package/docs/tutorials/offline.md +10 -8
  45. package/docs/tutorials/plugins.md +5 -0
  46. package/docs/tutorials/ui-customization.md +13 -0
  47. package/docs/tutorials/ui.md +2 -1
  48. package/docs/tutorials/upgrade.md +3 -0
  49. package/externs/managedmediasource.js +24 -0
  50. package/externs/shaka/abr_manager.js +6 -2
  51. package/externs/shaka/cea.js +7 -0
  52. package/externs/shaka/codecs.js +5 -3
  53. package/externs/shaka/manifest.js +21 -5
  54. package/externs/shaka/manifest_parser.js +17 -0
  55. package/externs/shaka/net.js +2 -2
  56. package/externs/shaka/offline.js +9 -2
  57. package/externs/shaka/player.js +53 -7
  58. package/externs/shaka/text.js +3 -1
  59. package/externs/shaka/transmuxer.js +1 -1
  60. package/lib/abr/simple_abr_manager.js +25 -8
  61. package/lib/ads/media_tailor_ad_manager.js +14 -3
  62. package/lib/cast/cast_receiver.js +1 -1
  63. package/lib/cea/cea_decoder.js +28 -0
  64. package/lib/cea/dummy_caption_decoder.js +5 -0
  65. package/lib/dash/dash_parser.js +251 -84
  66. package/lib/dash/mpd_utils.js +52 -31
  67. package/lib/dash/segment_base.js +4 -5
  68. package/lib/dash/segment_list.js +5 -4
  69. package/lib/dash/segment_template.js +92 -29
  70. package/lib/hls/hls_classes.js +28 -43
  71. package/lib/hls/hls_parser.js +770 -652
  72. package/lib/hls/hls_utils.js +64 -5
  73. package/lib/hls/manifest_text_parser.js +7 -11
  74. package/lib/media/adaptation_set.js +20 -13
  75. package/lib/media/adaptation_set_criteria.js +70 -18
  76. package/lib/media/closed_caption_parser.js +13 -0
  77. package/lib/media/content_workarounds.js +6 -0
  78. package/lib/media/drm_engine.js +8 -13
  79. package/lib/media/manifest_parser.js +8 -113
  80. package/lib/media/media_source_capabilities.js +10 -3
  81. package/lib/media/media_source_engine.js +75 -21
  82. package/lib/media/play_rate_controller.js +8 -38
  83. package/lib/media/presentation_timeline.js +7 -1
  84. package/lib/media/quality_observer.js +1 -1
  85. package/lib/media/segment_index.js +5 -5
  86. package/lib/media/segment_prefetch.js +92 -24
  87. package/lib/media/segment_reference.js +67 -1
  88. package/lib/media/segment_utils.js +343 -0
  89. package/lib/media/stall_detector.js +0 -3
  90. package/lib/media/streaming_engine.js +72 -44
  91. package/lib/mss/mss_parser.js +18 -2
  92. package/lib/net/networking_engine.js +66 -12
  93. package/lib/net/networking_utils.js +95 -0
  94. package/lib/offline/indexeddb/v1_storage_cell.js +2 -0
  95. package/lib/offline/indexeddb/v2_storage_cell.js +2 -0
  96. package/lib/offline/manifest_converter.js +2 -0
  97. package/lib/offline/offline_manifest_parser.js +10 -0
  98. package/lib/offline/storage.js +11 -7
  99. package/lib/player.js +998 -1503
  100. package/lib/polyfill/mediasource.js +22 -1
  101. package/lib/text/mp4_ttml_parser.js +2 -2
  102. package/lib/text/srt_text_parser.js +2 -2
  103. package/lib/text/stub_text_displayer.js +51 -0
  104. package/lib/text/text_engine.js +3 -2
  105. package/lib/text/ttml_text_parser.js +28 -5
  106. package/lib/text/ui_text_displayer.js +4 -0
  107. package/lib/text/vtt_text_parser.js +7 -2
  108. package/lib/transmuxer/aac_transmuxer.js +1 -1
  109. package/lib/transmuxer/ac3_transmuxer.js +1 -1
  110. package/lib/transmuxer/ec3_transmuxer.js +1 -1
  111. package/lib/transmuxer/h264.js +5 -4
  112. package/lib/transmuxer/h265.js +5 -4
  113. package/lib/transmuxer/mp3_transmuxer.js +1 -1
  114. package/lib/transmuxer/mpeg_ts_transmuxer.js +1 -1
  115. package/lib/transmuxer/mss_transmuxer.js +1 -1
  116. package/lib/transmuxer/ts_transmuxer.js +33 -13
  117. package/lib/util/buffer_utils.js +26 -4
  118. package/lib/util/content_steering_manager.js +358 -0
  119. package/lib/util/error.js +2 -6
  120. package/lib/util/fairplay_utils.js +1 -1
  121. package/lib/util/fake_event.js +5 -1
  122. package/lib/util/id3_utils.js +50 -1
  123. package/lib/util/manifest_parser_utils.js +12 -8
  124. package/lib/util/mp4_generator.js +2 -4
  125. package/lib/util/mutex.js +59 -0
  126. package/lib/util/object_utils.js +1 -1
  127. package/lib/util/periods.js +154 -179
  128. package/lib/util/platform.js +4 -3
  129. package/lib/util/player_configuration.js +35 -6
  130. package/lib/util/stream_utils.js +105 -98
  131. package/lib/util/ts_parser.js +124 -73
  132. package/lib/util/uint8array_utils.js +5 -1
  133. package/lib/util/xml_utils.js +5 -0
  134. package/maintained-branches.md +2 -2
  135. package/package.json +1 -1
  136. package/roadmap.md +15 -5
  137. package/shaka-player.uncompiled.js +0 -1
  138. package/test/abr/simple_abr_manager_unit.js +33 -33
  139. package/test/ads/ad_manager_unit.js +3 -2
  140. package/test/cast/cast_receiver_integration.js +3 -4
  141. package/test/cast/cast_utils_unit.js +2 -0
  142. package/test/cea/cea_decoder_unit.js +7 -0
  143. package/test/codec_switching/codec_switching_integration.js +2 -1
  144. package/test/dash/dash_parser_integration.js +2 -1
  145. package/test/dash/dash_parser_live_unit.js +0 -19
  146. package/test/dash/dash_parser_manifest_unit.js +494 -2
  147. package/test/dash/mpd_utils_unit.js +61 -30
  148. package/test/hls/hls_live_unit.js +12 -3
  149. package/test/hls/hls_parser_unit.js +417 -27
  150. package/test/hls/manifest_text_parser_unit.js +32 -99
  151. package/test/media/adaptation_set_criteria_unit.js +172 -21
  152. package/test/media/adaptation_set_unit.js +1 -0
  153. package/test/media/content_workarounds_unit.js +1 -1
  154. package/test/media/drm_engine_unit.js +3 -3
  155. package/test/media/media_source_engine_unit.js +1 -1
  156. package/test/media/play_rate_controller_unit.js +0 -48
  157. package/test/media/segment_index_unit.js +2 -1
  158. package/test/mss/mss_player_integration.js +3 -2
  159. package/test/net/networking_engine_unit.js +3 -3
  160. package/test/{media/manifest_parser_unit.js → net/networking_utils_unit.js} +2 -2
  161. package/test/offline/manifest_convert_unit.js +9 -0
  162. package/test/offline/offline_integration.js +2 -1
  163. package/test/offline/storage_integration.js +21 -9
  164. package/test/player_external.js +4 -2
  165. package/test/player_integration.js +15 -4
  166. package/test/player_load_graph_integration.js +47 -151
  167. package/test/player_src_equals_external.js +1 -0
  168. package/test/player_src_equals_integration.js +71 -4
  169. package/test/player_unit.js +80 -27
  170. package/test/test/util/fake_media_source_engine.js +5 -0
  171. package/test/test/util/fake_networking_engine.js +9 -1
  172. package/test/test/util/fake_segment_prefetch.js +3 -0
  173. package/test/test/util/manifest_generator.js +4 -0
  174. package/test/test/util/manifest_parser_util.js +14 -2
  175. package/test/test/util/offline_utils.js +1 -0
  176. package/test/test/util/simple_fakes.js +2 -2
  177. package/test/test/util/streaming_engine_util.js +3 -0
  178. package/test/test/util/test_scheme.js +6 -0
  179. package/test/test/util/ui_utils.js +4 -3
  180. package/test/text/mp4_ttml_parser_unit.js +4 -4
  181. package/test/text/srt_text_parser_unit.js +1 -1
  182. package/test/text/text_displayer_layout_unit.js +1 -1
  183. package/test/text/text_engine_unit.js +6 -0
  184. package/test/text/ttml_text_parser_unit.js +33 -2
  185. package/test/transmuxer/transmuxer_engine_integration.js +9 -0
  186. package/test/transmuxer/transmuxer_integration.js +33 -3
  187. package/test/ui/ad_ui_unit.js +2 -2
  188. package/test/ui/ui_customization_unit.js +17 -16
  189. package/test/ui/ui_integration.js +30 -20
  190. package/test/ui/ui_unit.js +25 -19
  191. package/test/util/buffer_utils_unit.js +1 -1
  192. package/test/util/content_steering_manager_unit.js +427 -0
  193. package/test/util/id3_utils_unit.js +52 -0
  194. package/test/util/stream_utils_unit.js +17 -113
  195. package/test/util/ts_parser_unit.js +3 -3
  196. package/third_party/closure-uri/uri.js +13 -1
  197. package/ui/audio_language_selection.js +9 -2
  198. package/ui/externs/ui.js +17 -2
  199. package/ui/language_utils.js +43 -8
  200. package/ui/less/range_elements.less +33 -0
  201. package/ui/locales/en.json +1 -0
  202. package/ui/locales/es-419.json +1 -0
  203. package/ui/locales/es.json +1 -0
  204. package/ui/locales/source.json +4 -0
  205. package/ui/localization.js +10 -0
  206. package/ui/remote_button.js +3 -1
  207. package/ui/resolution_selection.js +47 -10
  208. package/ui/seek_bar.js +296 -3
  209. package/ui/text_selection.js +2 -1
  210. package/ui/ui.js +6 -2
  211. package/lib/routing/node.js +0 -23
  212. package/lib/routing/payload.js +0 -47
  213. package/lib/routing/walker.js +0 -587
  214. package/test/routing/walker_unit.js +0 -505
@@ -36,9 +36,9 @@ describe('UI Customization', () => {
36
36
  container.appendChild(video);
37
37
  });
38
38
 
39
- it('only the specified controls are created', () => {
39
+ it('only the specified controls are created', async () => {
40
40
  const config = {controlPanelElements: ['time_and_duration', 'mute']};
41
- UiUtils.createUIThroughAPI(container, video, config);
41
+ await UiUtils.createUIThroughAPI(container, video, config);
42
42
 
43
43
  // Only current time and mute button should've been created
44
44
  UiUtils.confirmElementFound(container, 'shaka-current-time');
@@ -49,9 +49,9 @@ describe('UI Customization', () => {
49
49
  UiUtils.confirmElementMissing(container, 'shaka-overflow-menu-button');
50
50
  });
51
51
 
52
- it('only the specified overflow menu buttons are created', () => {
52
+ it('only the specified overflow menu buttons are created', async () => {
53
53
  const config = {overflowMenuButtons: ['cast']};
54
- UiUtils.createUIThroughAPI(container, video, config);
54
+ await UiUtils.createUIThroughAPI(container, video, config);
55
55
 
56
56
  UiUtils.confirmElementFound(container, 'shaka-cast-button');
57
57
 
@@ -59,30 +59,31 @@ describe('UI Customization', () => {
59
59
  });
60
60
 
61
61
  it('seek bar only created when configured', async () => {
62
- const ui =
63
- UiUtils.createUIThroughAPI(container, video, {addSeekBar: false});
62
+ const ui = await UiUtils.createUIThroughAPI(
63
+ container, video, {addSeekBar: false});
64
64
  UiUtils.confirmElementMissing(container, 'shaka-seek-bar');
65
65
  await ui.destroy();
66
66
 
67
- UiUtils.createUIThroughAPI(container, video, {addSeekBar: true});
67
+ await UiUtils.createUIThroughAPI(container, video, {addSeekBar: true});
68
68
  UiUtils.confirmElementFound(container, 'shaka-seek-bar');
69
69
  });
70
70
 
71
71
  it('big play button only created when configured', async () => {
72
- const ui =
73
- UiUtils.createUIThroughAPI(container, video, {addBigPlayButton: false});
72
+ const ui = await UiUtils.createUIThroughAPI(
73
+ container, video, {addBigPlayButton: false});
74
74
  UiUtils.confirmElementMissing(container, 'shaka-play-button-container');
75
75
  UiUtils.confirmElementMissing(container, 'shaka-play-button');
76
76
  await ui.destroy();
77
77
 
78
- UiUtils.createUIThroughAPI(container, video, {addBigPlayButton: true});
78
+ await UiUtils.createUIThroughAPI(
79
+ container, video, {addBigPlayButton: true});
79
80
  UiUtils.confirmElementFound(container, 'shaka-play-button-container');
80
81
  UiUtils.confirmElementFound(container, 'shaka-play-button');
81
82
  });
82
83
 
83
- it('settings menus are positioned lower when seek bar is absent', () => {
84
+ it('settings menus are lower when seek bar is absent', async () => {
84
85
  const config = {addSeekBar: false};
85
- UiUtils.createUIThroughAPI(container, video, config);
86
+ await UiUtils.createUIThroughAPI(container, video, config);
86
87
 
87
88
  function confirmLowPosition(className) {
88
89
  const elements =
@@ -101,7 +102,7 @@ describe('UI Customization', () => {
101
102
  confirmLowPosition('shaka-playback-rates');
102
103
  });
103
104
 
104
- it('controls are created in specified order', () => {
105
+ it('controls are created in specified order', async () => {
105
106
  const config = {
106
107
  controlPanelElements: [
107
108
  'mute',
@@ -110,7 +111,7 @@ describe('UI Customization', () => {
110
111
  ],
111
112
  };
112
113
 
113
- UiUtils.createUIThroughAPI(container, video, config);
114
+ await UiUtils.createUIThroughAPI(container, video, config);
114
115
 
115
116
  const controlsButtonPanels =
116
117
  container.getElementsByClassName('shaka-controls-button-panel');
@@ -131,7 +132,7 @@ describe('UI Customization', () => {
131
132
 
132
133
  it('layout can be re-configured after the creation', async () => {
133
134
  const config = {controlPanelElements: ['time_and_duration', 'mute']};
134
- const ui = UiUtils.createUIThroughAPI(container, video, config);
135
+ const ui = await UiUtils.createUIThroughAPI(container, video, config);
135
136
 
136
137
  // Only current time and mute button should've been created
137
138
  UiUtils.confirmElementFound(container, 'shaka-current-time');
@@ -177,7 +178,7 @@ describe('UI Customization', () => {
177
178
  it('cast proxy and controls are unchanged by reconfiguration', async () => {
178
179
  const config = {controlPanelElements: ['time_and_duration', 'mute']};
179
180
  /** @type {!shaka.ui.Overlay} */
180
- const ui = UiUtils.createUIThroughAPI(container, video, config);
181
+ const ui = await UiUtils.createUIThroughAPI(container, video, config);
181
182
 
182
183
  const eventManager = new shaka.util.EventManager();
183
184
  const waiter = new shaka.test.Waiter(eventManager);
@@ -45,7 +45,8 @@ describe('UI', () => {
45
45
  videoContainer = shaka.util.Dom.createHTMLElement('div');
46
46
  videoContainer.appendChild(video);
47
47
  document.body.appendChild(videoContainer);
48
- player = new compiledShaka.Player(video);
48
+ player = new compiledShaka.Player();
49
+ await player.attach(video);
49
50
 
50
51
  // Create UI
51
52
  // Add all of the buttons we have
@@ -313,8 +314,6 @@ describe('UI', () => {
313
314
  describe('resolution selection', () => {
314
315
  /** @type {!Map.<number, !HTMLElement>} */
315
316
  let resolutionsToButtons;
316
- /** @type {!Array.<number>} */
317
- let resolutionsFromContent;
318
317
  /** @type {!Array.<!HTMLElement>} */
319
318
  let resolutionButtons;
320
319
  /** @type {!Element} */
@@ -329,6 +328,8 @@ describe('UI', () => {
329
328
  let preferredLanguage;
330
329
  /** @type {!shaka.extern.Track} */
331
330
  let oldResolutionTrack;
331
+ /** @type {number} */
332
+ let newResolutionTrackId;
332
333
 
333
334
  beforeEach(async () => {
334
335
  oldResolution = 182;
@@ -353,6 +354,7 @@ describe('UI', () => {
353
354
  updateResolutionButtonsAndMap();
354
355
 
355
356
  oldResolutionTrack = findTrackWithHeight(tracks, oldResolution);
357
+ newResolutionTrackId = findTrackWithHeight(tracks, newResolution).id;
356
358
 
357
359
  const selectedResolution =
358
360
  getSelectedTrack(player.getVariantTracks()).height;
@@ -363,9 +365,8 @@ describe('UI', () => {
363
365
  });
364
366
 
365
367
  it('contains all the relevant resolutions', () => {
366
- const formattedResolutions = resolutionsFromContent.map((res) => {
367
- return formatResolution(res);
368
- });
368
+ const formattedResolutions =
369
+ tracks.map((t) => formatResolution(t.id, tracks));
369
370
  verifyItems(formattedResolutions, resolutionButtons);
370
371
  });
371
372
 
@@ -374,7 +375,7 @@ describe('UI', () => {
374
375
  tracks = player.getVariantTracks();
375
376
  expect(getSelectedTrack(tracks).height).toBe(oldResolution);
376
377
 
377
- const button = resolutionsToButtons.get(newResolution);
378
+ const button = resolutionsToButtons.get(newResolutionTrackId);
378
379
  button.click();
379
380
 
380
381
  // Wait for the change to take effect
@@ -400,7 +401,7 @@ describe('UI', () => {
400
401
 
401
402
  expect(getSelectedTrack(tracks).height).toBe(newResolution);
402
403
 
403
- const button = resolutionsToButtons.get(newResolution);
404
+ const button = resolutionsToButtons.get(newResolutionTrackId);
404
405
  const isChosen = button.querySelector('.shaka-chosen-item');
405
406
 
406
407
  expect(isChosen).not.toBe(null);
@@ -427,7 +428,7 @@ describe('UI', () => {
427
428
  const p = waiter.waitForEvent(controls, 'resolutionselectionupdated');
428
429
 
429
430
  // Any resolution would works
430
- const button = resolutionsToButtons.get(newResolution);
431
+ const button = resolutionsToButtons.get(newResolutionTrackId);
431
432
  button.click();
432
433
 
433
434
  await p;
@@ -467,13 +468,26 @@ describe('UI', () => {
467
468
 
468
469
  /**
469
470
  * Gets the resolution to the same format it
470
- * appears in the UI: height + 'p'.
471
+ * appears in the UI
471
472
  *
472
- * @param {number} height
473
+ * @param {number} id
474
+ * @param {!Array.<!shaka.extern.Track>} tracks
473
475
  * @return {string}
474
476
  */
475
- function formatResolution(height) {
476
- return height.toString() + 'p';
477
+ function formatResolution(id, tracks) {
478
+ const track = tracks.find((t) => t.id == id);
479
+ const trackHeight = track.height || 0;
480
+ const trackWidth = track.width || 0;
481
+ let height = trackHeight;
482
+ const aspectRatio = trackWidth / trackHeight;
483
+ if (aspectRatio > (16 / 9)) {
484
+ height = Math.round(trackWidth * 9 / 16);
485
+ }
486
+ let text = height + 'p';
487
+ if (height == 2160) {
488
+ text = '4K';
489
+ }
490
+ return text;
477
491
  }
478
492
 
479
493
  /**
@@ -500,10 +514,6 @@ describe('UI', () => {
500
514
  return track.language == preferredLanguage;
501
515
  });
502
516
 
503
- resolutionsFromContent = tracks.map((track) => {
504
- return track.height;
505
- });
506
-
507
517
  resolutionButtons = filterButtons(
508
518
  /* buttons= */ resolutionsMenu.childNodes,
509
519
  /* excludeClasses= */ [
@@ -513,8 +523,8 @@ describe('UI', () => {
513
523
 
514
524
  resolutionsToButtons = mapChoicesToButtons(
515
525
  /* buttons= */ resolutionButtons,
516
- /* choices= */ resolutionsFromContent,
517
- /* modifier= */ formatResolution);
526
+ /* choices= */ tracks.map((track) => track.id),
527
+ /* modifier= */ (id) => formatResolution(id, tracks));
518
528
  }
519
529
  }); // describe('resolution selection')
520
530
 
@@ -598,7 +608,7 @@ describe('UI', () => {
598
608
 
599
609
  /**
600
610
  * @param {!Array.<!HTMLElement>} buttons
601
- * @param {!Array.<string>} choices
611
+ * @param {!Array.<string>|!Array.<number>} choices
602
612
  * @param {function(string):string|function(number):string} modifier
603
613
  * @return {!Map.<string, !HTMLElement>|!Map.<number, !HTMLElement>}
604
614
  */
@@ -36,14 +36,14 @@ describe('UI', () => {
36
36
  /** @type {!HTMLVideoElement} */
37
37
  let video;
38
38
 
39
- beforeEach(() => {
39
+ beforeEach(async () => {
40
40
  videoContainer =
41
41
  /** @type {!HTMLElement} */ (document.createElement('div'));
42
42
  document.body.appendChild(videoContainer);
43
43
 
44
44
  video = shaka.test.UiUtils.createVideoElement();
45
45
  videoContainer.appendChild(video);
46
- UiUtils.createUIThroughAPI(videoContainer, video);
46
+ await UiUtils.createUIThroughAPI(videoContainer, video);
47
47
  });
48
48
 
49
49
  it('has all the basic elements', () => {
@@ -193,7 +193,8 @@ describe('UI', () => {
193
193
  ],
194
194
  doubleClickForFullscreen: false,
195
195
  };
196
- const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
196
+ const ui = await UiUtils.createUIThroughAPI(
197
+ videoContainer, video, config);
197
198
  const controls = ui.getControls();
198
199
 
199
200
  const spy = spyOn(controls, 'toggleFullScreen');
@@ -216,8 +217,8 @@ describe('UI', () => {
216
217
  /** @type {!HTMLElement} */
217
218
  let controlsContainer;
218
219
 
219
- beforeEach(() => {
220
- const ui = UiUtils.createUIThroughAPI(videoContainer, video);
220
+ beforeEach(async () => {
221
+ const ui = await UiUtils.createUIThroughAPI(videoContainer, video);
221
222
  player = ui.getControls().getLocalPlayer();
222
223
  const controlsContainers =
223
224
  videoContainer.getElementsByClassName('shaka-controls-container');
@@ -246,13 +247,14 @@ describe('UI', () => {
246
247
  /** @type {!HTMLElement} */
247
248
  let overflowMenu;
248
249
 
249
- beforeEach(() => {
250
+ beforeEach(async () => {
250
251
  const config = {
251
252
  controlPanelElements: [
252
253
  'overflow_menu',
253
254
  ],
254
255
  };
255
- const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
256
+ const ui = await UiUtils.createUIThroughAPI(
257
+ videoContainer, video, config);
256
258
  player = ui.getControls().getLocalPlayer();
257
259
 
258
260
  const overflowMenus =
@@ -323,8 +325,8 @@ describe('UI', () => {
323
325
  /** @type {!HTMLElement} */
324
326
  let controlsButtonPanel;
325
327
 
326
- it('has default elements', () => {
327
- UiUtils.createUIThroughAPI(videoContainer, video);
328
+ it('has default elements', async () => {
329
+ await UiUtils.createUIThroughAPI(videoContainer, video);
328
330
  const controlsButtonPanels = videoContainer.getElementsByClassName(
329
331
  'shaka-controls-button-panel');
330
332
 
@@ -357,7 +359,7 @@ describe('UI', () => {
357
359
  }
358
360
  });
359
361
 
360
- it('is accessible', () => {
362
+ it('is accessible', async () => {
361
363
  function confirmAriaLabel(className) {
362
364
  const elements =
363
365
  controlsButtonPanel.getElementsByClassName(className);
@@ -376,7 +378,7 @@ describe('UI', () => {
376
378
  ],
377
379
  };
378
380
 
379
- UiUtils.createUIThroughAPI(videoContainer, video, config);
381
+ await UiUtils.createUIThroughAPI(videoContainer, video, config);
380
382
  const controlsButtonPanels = videoContainer.getElementsByClassName(
381
383
  'shaka-controls-button-panel');
382
384
  expect(controlsButtonPanels.length).toBe(1);
@@ -403,14 +405,15 @@ describe('UI', () => {
403
405
  /** @type {!Element} */
404
406
  let languageMenuButton;
405
407
 
406
- beforeEach(() => {
408
+ beforeEach(async () => {
407
409
  const config = {
408
410
  controlPanelElements: [
409
411
  'quality',
410
412
  'language',
411
413
  ],
412
414
  };
413
- const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
415
+ const ui = await UiUtils.createUIThroughAPI(
416
+ videoContainer, video, config);
414
417
  player = ui.getControls().getLocalPlayer();
415
418
 
416
419
  const resolutionsMenus =
@@ -473,7 +476,7 @@ describe('UI', () => {
473
476
  /** @type {shaka.ui.Controls} */
474
477
  let controls;
475
478
 
476
- beforeEach(() => {
479
+ beforeEach(async () => {
477
480
  const config = {
478
481
  controlPanelElements: [
479
482
  'overflow_menu',
@@ -482,7 +485,8 @@ describe('UI', () => {
482
485
  'quality',
483
486
  ],
484
487
  };
485
- const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
488
+ const ui = await UiUtils.createUIThroughAPI(
489
+ videoContainer, video, config);
486
490
  controls = ui.getControls();
487
491
  player = controls.getLocalPlayer();
488
492
 
@@ -696,7 +700,7 @@ describe('UI', () => {
696
700
  /** @type {!HTMLElement} */
697
701
  let contextMenu;
698
702
 
699
- beforeEach(() => {
703
+ beforeEach(async () => {
700
704
  const config = {
701
705
  customContextMenu: true,
702
706
  contextMenuElements: [
@@ -705,7 +709,8 @@ describe('UI', () => {
705
709
  'fakeElement',
706
710
  ],
707
711
  };
708
- const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
712
+ const ui = await UiUtils.createUIThroughAPI(
713
+ videoContainer, video, config);
709
714
 
710
715
  controlsContainer = ui.getControls().getControlsContainer();
711
716
 
@@ -745,7 +750,7 @@ describe('UI', () => {
745
750
  /** @type {!HTMLElement} */
746
751
  let statisticsContainer;
747
752
 
748
- beforeEach(() => {
753
+ beforeEach(async () => {
749
754
  const config = {
750
755
  customContextMenu: true,
751
756
  contextMenuElements: [
@@ -753,7 +758,8 @@ describe('UI', () => {
753
758
  ],
754
759
  statisticsList: Object.keys(new shaka.util.Stats().getBlob()),
755
760
  };
756
- const ui = UiUtils.createUIThroughAPI(videoContainer, video, config);
761
+ const ui = await UiUtils.createUIThroughAPI(
762
+ videoContainer, video, config);
757
763
  player = ui.getControls().getLocalPlayer();
758
764
 
759
765
  const statisticsButtons =
@@ -42,7 +42,7 @@ describe('BufferUtils', () => {
42
42
 
43
43
  it('compares with same buffer', () => {
44
44
  const a = new Uint8Array([0, 1, 2, 3]);
45
- const b = new Uint16Array(a.buffer);
45
+ const b = BufferUtils.toUint16(a);
46
46
  expect(BufferUtils.equal(a, b)).toBe(true);
47
47
  });
48
48