shaka-player 3.2.0 → 3.2.4

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 (162) hide show
  1. package/.github/workflows/build_and_test.yaml +73 -0
  2. package/.github/workflows/release.yaml +53 -0
  3. package/AUTHORS +3 -0
  4. package/CHANGELOG.md +182 -1
  5. package/CONTRIBUTORS +3 -0
  6. package/README.md +4 -4
  7. package/build/checkversion.py +1 -1
  8. package/build/generateExterns.js +1 -1
  9. package/build/misspellings.txt +1 -0
  10. package/build/shakaBuildHelpers.py +6 -5
  11. package/build/subprocessWindowsPatch.py +103 -0
  12. package/build/test.py +6 -0
  13. package/demo/common/assets.js +1 -1
  14. package/demo/index.html +1 -1
  15. package/dist/controls.css +2 -2
  16. package/dist/controls.css.map +1 -1
  17. package/dist/demo.compiled.debug.js +1 -1
  18. package/dist/demo.compiled.js +1 -1
  19. package/dist/deps.js +8 -8
  20. package/dist/locales.js +37 -37
  21. package/dist/receiver.compiled.debug.js +1 -1
  22. package/dist/receiver.compiled.js +1 -1
  23. package/dist/shaka-player.compiled.d.ts +195 -5
  24. package/dist/shaka-player.compiled.debug.d.ts +195 -5
  25. package/dist/shaka-player.compiled.debug.externs.js +226 -14
  26. package/dist/shaka-player.compiled.debug.js +424 -399
  27. package/dist/shaka-player.compiled.debug.map +4 -4
  28. package/dist/shaka-player.compiled.externs.js +226 -14
  29. package/dist/shaka-player.compiled.js +826 -812
  30. package/dist/shaka-player.compiled.map +4 -4
  31. package/dist/shaka-player.ui.d.ts +197 -16
  32. package/dist/shaka-player.ui.debug.d.ts +197 -16
  33. package/dist/shaka-player.ui.debug.externs.js +230 -27
  34. package/dist/shaka-player.ui.debug.js +466 -442
  35. package/dist/shaka-player.ui.debug.map +4 -4
  36. package/dist/shaka-player.ui.externs.js +230 -27
  37. package/dist/shaka-player.ui.js +946 -932
  38. package/dist/shaka-player.ui.map +4 -4
  39. package/docs/tutorials/fairplay.md +1 -1
  40. package/docs/tutorials/faq.md +14 -0
  41. package/docs/tutorials/ui.md +5 -5
  42. package/externs/ima.js +4 -0
  43. package/externs/shaka/ads.js +25 -0
  44. package/externs/shaka/player.js +8 -0
  45. package/externs/shaka/text.js +10 -0
  46. package/karma.conf.js +20 -15
  47. package/lib/ads/ad_manager.js +46 -26
  48. package/lib/ads/client_side_ad_manager.js +82 -88
  49. package/lib/ads/server_side_ad_manager.js +45 -13
  50. package/lib/cast/cast_proxy.js +6 -2
  51. package/lib/cast/cast_receiver.js +5 -1
  52. package/lib/cast/cast_sender.js +2 -2
  53. package/lib/cea/sei_processor.js +24 -17
  54. package/lib/dash/dash_parser.js +131 -24
  55. package/lib/dash/segment_list.js +1 -1
  56. package/lib/dash/segment_template.js +1 -1
  57. package/lib/hls/hls_parser.js +74 -17
  58. package/lib/hls/manifest_text_parser.js +1 -0
  59. package/lib/media/closed_caption_parser.js +3 -1
  60. package/lib/media/content_workarounds.js +12 -0
  61. package/lib/media/drm_engine.js +20 -1
  62. package/lib/media/gap_jumping_controller.js +8 -4
  63. package/lib/media/media_source_engine.js +1 -2
  64. package/lib/media/playhead.js +1 -1
  65. package/lib/media/region_observer.js +39 -33
  66. package/lib/media/region_timeline.js +17 -19
  67. package/lib/media/segment_index.js +2 -1
  68. package/lib/media/segment_reference.js +19 -1
  69. package/lib/media/streaming_engine.js +8 -4
  70. package/lib/net/networking_engine.js +6 -1
  71. package/lib/offline/download_manager.js +1 -2
  72. package/lib/offline/storage.js +8 -9
  73. package/lib/player.js +129 -59
  74. package/lib/polyfill/aria.js +12 -2
  75. package/lib/polyfill/encryption_scheme.js +2 -0
  76. package/lib/polyfill/fullscreen.js +2 -0
  77. package/lib/polyfill/mathround.js +2 -0
  78. package/lib/polyfill/media_capabilities.js +73 -21
  79. package/lib/polyfill/mediasource.js +8 -0
  80. package/lib/polyfill/orientation.js +3 -1
  81. package/lib/polyfill/patchedmediakeys_apple.js +6 -4
  82. package/lib/polyfill/patchedmediakeys_ms.js +6 -4
  83. package/lib/polyfill/patchedmediakeys_nop.js +2 -0
  84. package/lib/polyfill/patchedmediakeys_webkit.js +6 -4
  85. package/lib/polyfill/pip_webkit.js +2 -0
  86. package/lib/polyfill/storage_estimate.js +2 -0
  87. package/lib/polyfill/video_play_promise.js +2 -0
  88. package/lib/polyfill/videoplaybackquality.js +2 -0
  89. package/lib/polyfill/vttcue.js +2 -0
  90. package/lib/text/cue.js +6 -0
  91. package/lib/text/mp4_ttml_parser.js +3 -0
  92. package/lib/text/text_engine.js +14 -2
  93. package/lib/text/ttml_text_parser.js +135 -87
  94. package/lib/text/ui_text_displayer.js +213 -80
  95. package/lib/text/vtt_text_parser.js +4 -2
  96. package/lib/text/web_vtt_generator.js +21 -12
  97. package/lib/util/fake_event.js +53 -7
  98. package/lib/util/fake_event_target.js +21 -1
  99. package/lib/util/mp4_box_parsers.js +1 -1
  100. package/lib/util/periods.js +4 -1
  101. package/lib/util/platform.js +13 -1
  102. package/lib/util/stream_utils.js +105 -13
  103. package/lib/util/xml_utils.js +50 -12
  104. package/package.json +3 -6
  105. package/roadmap.md +24 -22
  106. package/test/cast/cast_proxy_unit.js +12 -6
  107. package/test/cast/cast_receiver_integration.js +1 -1
  108. package/test/cast/cast_utils_unit.js +1 -1
  109. package/test/cea/mp4_cea_parser_unit.js +26 -0
  110. package/test/dash/dash_parser_live_unit.js +43 -0
  111. package/test/dash/dash_parser_manifest_unit.js +222 -3
  112. package/test/hls/hls_parser_unit.js +79 -1
  113. package/test/media/closed_caption_parser_unit.js +20 -0
  114. package/test/media/drm_engine_integration.js +86 -2
  115. package/test/media/drm_engine_unit.js +57 -0
  116. package/test/media/playhead_unit.js +27 -1
  117. package/test/media/region_observer_unit.js +40 -5
  118. package/test/media/region_timeline_unit.js +40 -22
  119. package/test/media/streaming_engine_integration.js +2 -1
  120. package/test/media/streaming_engine_unit.js +145 -0
  121. package/test/player_integration.js +79 -8
  122. package/test/player_src_equals_integration.js +41 -8
  123. package/test/player_unit.js +14 -4
  124. package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
  125. package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
  126. package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
  127. package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
  128. package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
  129. package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
  130. package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
  131. package/test/test/assets/3675/dash_0.mpd +30 -0
  132. package/test/test/assets/3675/dash_1.mpd +30 -0
  133. package/test/test/assets/3675/dash_2.mpd +30 -0
  134. package/test/test/assets/3675/dash_3.mpd +30 -0
  135. package/test/test/assets/3675/dash_4.mpd +30 -0
  136. package/test/test/assets/3675/dash_5.mpd +26 -0
  137. package/test/test/assets/3675/init-stream0.m4s +0 -0
  138. package/test/test/assets/chapters.vtt +2 -2
  139. package/test/test/assets/chapters2.vtt +10 -0
  140. package/test/test/assets/empty_caption_video_init.mp4 +0 -0
  141. package/test/test/assets/empty_caption_video_segment.mp4 +0 -0
  142. package/test/test/util/fake_ad_manager.js +11 -1
  143. package/test/test/util/ttml_utils.js +81 -0
  144. package/test/test/util/util.js +10 -7
  145. package/test/text/mp4_ttml_parser_unit.js +11 -18
  146. package/test/text/ttml_text_parser_unit.js +542 -220
  147. package/test/text/ui_text_displayer_unit.js +93 -20
  148. package/test/text/vtt_text_parser_unit.js +17 -1
  149. package/test/text/web_vtt_generator_unit.js +58 -3
  150. package/test/ui/localization_unit.js +15 -14
  151. package/test/ui/text_displayer_layout_unit.js +21 -8
  152. package/test/util/mp4_box_parsers_unit.js +28 -0
  153. package/test/util/stream_utils_unit.js +60 -3
  154. package/ui/cast_button.js +2 -3
  155. package/ui/controls.js +11 -6
  156. package/ui/less/buttons.less +0 -4
  157. package/ui/less/containers.less +6 -7
  158. package/ui/locales/ru.json +6 -6
  159. package/ui/localization.js +40 -87
  160. package/ui/pip_button.js +2 -3
  161. package/ui/seek_bar.js +1 -2
  162. package/ui/text_selection.js +1 -0
@@ -157,6 +157,9 @@
157
157
  /* 32px tall controls. */
158
158
  height: 32px;
159
159
 
160
+ /* Consistent alignment of buttons. */
161
+ line-height: 0.5;
162
+
160
163
  /* Consistent margins (external) and padding (internal) between controls. */
161
164
  .bottom-panels-elements-margin();
162
165
 
@@ -226,13 +229,9 @@
226
229
  transition-delay: 500ms;
227
230
 
228
231
  /* These are defaults which are overridden by JS or cue styles. */
229
- span:not(.shaka-text-wrapper) {
230
- display: inline;
231
- font-size: 20px;
232
- line-height: 1.4; // relative to font size.
233
- background-color: rgba(0, 0, 0, 0.8);
234
- color: rgb(255, 255, 255);
235
- }
232
+ font-size: 20px;
233
+ line-height: 1.4; // relative to font size.
234
+ color: rgb(255, 255, 255);
236
235
 
237
236
  span.shaka-text-wrapper {
238
237
  display: inline;
@@ -1,10 +1,10 @@
1
1
  {
2
- "AD_DURATION": "Продолжительность объявления",
3
- "AD_PROGRESS": "Объявление [AD_ON] из [NUM_ADS]",
4
- "AD_TIME": "Объявление: [AD_TIME]",
2
+ "AD_DURATION": "Продолжительность рекламы",
3
+ "AD_PROGRESS": "Реклама [AD_ON] из [NUM_ADS]",
4
+ "AD_TIME": "Реклама: [AD_TIME]",
5
5
  "AUTO_QUALITY": "Авто",
6
6
  "BACK": "Назад",
7
- "CAPTIONS": "Титры",
7
+ "CAPTIONS": "Субтитры",
8
8
  "CAST": "Транслировать...",
9
9
  "ENTER_LOOP_MODE": "Зациклить текущее видео",
10
10
  "ENTER_PICTURE_IN_PICTURE": "Перейти в режим \"Картинка в картинке\"",
@@ -20,8 +20,8 @@
20
20
  "MULTIPLE_LANGUAGES": "Несколько языков",
21
21
  "MUTE": "Отключить звук",
22
22
  "NOT_APPLICABLE": "Неприменимо",
23
- "OFF": "Включить",
24
- "ON": "Отключить",
23
+ "OFF": "Выкл.",
24
+ "ON": "Вкл.",
25
25
  "PAUSE": "Пауза",
26
26
  "PICTURE_IN_PICTURE": "Картинка в картинке",
27
27
  "PLAY": "Воспроизвести",
@@ -23,17 +23,18 @@ goog.require('shaka.util.LanguageUtils');
23
23
  * If a string is not available, it will return the localized
24
24
  * form in the closest related locale.
25
25
  *
26
- * @implements {EventTarget}
27
26
  * @final
28
27
  * @export
29
28
  */
30
- shaka.ui.Localization = class {
29
+ shaka.ui.Localization = class extends shaka.util.FakeEventTarget {
31
30
  /**
32
31
  * @param {string} fallbackLocale
33
32
  * The fallback locale that should be used. It will be assumed that this
34
33
  * locale should have entries for just about every request.
35
34
  */
36
35
  constructor(fallbackLocale) {
36
+ super();
37
+
37
38
  /** @private {string} */
38
39
  this.fallbackLocale_ = shaka.util.LanguageUtils.normalize(fallbackLocale);
39
40
 
@@ -62,41 +63,16 @@ shaka.ui.Localization = class {
62
63
  * @private {!Map.<string, !Map.<string, string>>}
63
64
  */
64
65
  this.localizations_ = new Map();
65
-
66
- /**
67
- * The event target that we will wrap so that we can fire events
68
- * without having to manage the listeners directly.
69
- *
70
- * @private {!EventTarget}
71
- */
72
- this.events_ = new shaka.util.FakeEventTarget();
73
- }
74
-
75
- /**
76
- * @override
77
- * @export
78
- */
79
- addEventListener(type, listener, options) {
80
- this.events_.addEventListener(type, listener, options);
81
- }
82
-
83
- /**
84
- * @override
85
- * @export
86
- */
87
- removeEventListener(type, listener, options) {
88
- // Apparently Closure says we can be passed a null |option|, but we can't
89
- // pass a null option, so if we get have a null-like |option|, force it to
90
- // be undefined.
91
- this.events_.removeEventListener(type, listener, options || undefined);
92
66
  }
93
67
 
94
68
  /**
95
69
  * @override
96
70
  * @export
97
71
  */
98
- dispatchEvent(event) {
99
- return this.events_.dispatchEvent(event);
72
+ release() {
73
+ // Placeholder so that readers know this implements IReleasable (via
74
+ // FakeEventTarget)
75
+ super.release();
100
76
  }
101
77
 
102
78
  /**
@@ -130,28 +106,20 @@ shaka.ui.Localization = class {
130
106
  (locale) => !this.localizations_.has(locale));
131
107
 
132
108
  if (missing.length) {
133
- /** @type {shaka.ui.Localization.UnknownLocalesEvent} */
134
- const eMissing = {
135
- 'locales': missing,
136
- };
137
-
138
- this.events_.dispatchEvent(new shaka.util.FakeEvent(
109
+ this.dispatchEvent(new shaka.util.FakeEvent(
139
110
  Class.UNKNOWN_LOCALES,
140
- eMissing));
111
+ (new Map()).set('locales', missing)));
141
112
  }
142
113
 
143
114
  const found = shaka.util.Iterables.filter(
144
115
  this.currentLocales_,
145
116
  (locale) => this.localizations_.has(locale));
146
117
 
147
- /** @type {shaka.ui.Localization.LocaleChangedEvent} */
148
- const eFound = {
149
- 'locales': found.length ? found : [this.fallbackLocale_],
150
- };
151
-
152
- this.events_.dispatchEvent(new shaka.util.FakeEvent(
118
+ const data = (new Map()).set(
119
+ 'locales', found.length ? found : [this.fallbackLocale_]);
120
+ this.dispatchEvent(new shaka.util.FakeEvent(
153
121
  Class.LOCALE_CHANGED,
154
- eFound));
122
+ data));
155
123
  }
156
124
 
157
125
  /**
@@ -201,7 +169,7 @@ shaka.ui.Localization = class {
201
169
  // data from.
202
170
  this.updateCurrentMap_();
203
171
 
204
- this.events_.dispatchEvent(new FakeEvent(Class.LOCALE_UPDATED));
172
+ this.dispatchEvent(new FakeEvent(Class.LOCALE_UPDATED));
205
173
 
206
174
  return this;
207
175
  }
@@ -253,14 +221,11 @@ shaka.ui.Localization = class {
253
221
  // number of locales. Since we don't know which ones we actually checked,
254
222
  // just tell them the preferred locale.
255
223
 
256
- /** @type {shaka.ui.Localization.UnknownLocalizationEvent} */
257
- const e = {
258
- // Make a copy to avoid leaking references.
259
- 'locales': Array.from(this.currentLocales_),
260
- 'missing': id,
261
- };
262
-
263
- this.events_.dispatchEvent(new FakeEvent(Class.UNKNOWN_LOCALIZATION, e));
224
+ const data = new Map()
225
+ // Make a copy to avoid leaking references.
226
+ .set('locales', Array.from(this.currentLocales_))
227
+ .set('missing', id);
228
+ this.dispatchEvent(new FakeEvent(Class.UNKNOWN_LOCALIZATION, data));
264
229
 
265
230
  return '';
266
231
  }
@@ -381,18 +346,16 @@ shaka.ui.Localization = class {
381
346
  }
382
347
 
383
348
  if (missing.size > 0) {
384
- /** @type {shaka.ui.Localization.MissingLocalizationsEvent} */
385
- const e = {
386
- // Make a copy of the preferred locales to avoid leaking references.
387
- 'locales': Array.from(preferredLocales),
388
- // Because most people like arrays more than sets, convert the set to
389
- // an array.
390
- 'missing': Array.from(missing),
391
- };
392
-
393
- this.events_.dispatchEvent(new shaka.util.FakeEvent(
349
+ const data = new Map()
350
+ // Make a copy of the preferred locales to avoid leaking references.
351
+ .set('locales', Array.from(preferredLocales))
352
+ // Because more people like arrays more than sets, convert the set to
353
+ // an array.
354
+ .set('missing', Array.from(missing));
355
+
356
+ this.dispatchEvent(new shaka.util.FakeEvent(
394
357
  shaka.ui.Localization.MISSING_LOCALIZATIONS,
395
- e));
358
+ data));
396
359
  }
397
360
  }
398
361
 
@@ -478,52 +441,42 @@ shaka.ui.Localization.LOCALE_CHANGED = 'locale-changed';
478
441
  shaka.ui.Localization.LOCALE_UPDATED = 'locale-updated';
479
442
 
480
443
  /**
481
- * @typedef {{
482
- * 'locales': !Array.<string>
483
- * }}
484
- *
444
+ * @event shaka.ui.Localization.UnknownLocalesEvent
445
+ * @property {string} type
446
+ * 'unknown-locales'
485
447
  * @property {!Array.<string>} locales
486
448
  * The locales that the user wanted but could not be found.
487
449
  * @exportDoc
488
450
  */
489
- shaka.ui.Localization.UnknownLocalesEvent;
490
451
 
491
452
  /**
492
- * @typedef {{
493
- * 'locales': !Array.<string>,
494
- * 'missing': string
495
- * }}
496
- *
453
+ * @event shaka.ui.Localization.MissingLocalizationsEvent
454
+ * @property {string} type
455
+ * 'unknown-localization'
497
456
  * @property {!Array.<string>} locales
498
457
  * The locales that the user wanted.
499
458
  * @property {string} missing
500
459
  * The id of the unknown entry.
501
460
  * @exportDoc
502
461
  */
503
- shaka.ui.Localization.UnknownLocalizationEvent;
504
462
 
505
463
  /**
506
- * @typedef {{
507
- * 'locales': !Array.<string>,
508
- * 'missing': !Array.<string>
509
- * }}
510
- *
464
+ * @event shaka.ui.Localization.MissingLocalizationsEvent
465
+ * @property {string} type
466
+ * 'missing-localizations'
511
467
  * @property {string} locale
512
468
  * The locale that the user wanted.
513
469
  * @property {!Array.<string>} missing
514
470
  * The ids of the missing entries.
515
471
  * @exportDoc
516
472
  */
517
- shaka.ui.Localization.MissingLocalizationsEvent;
518
473
 
519
474
  /**
520
- * @typedef {{
521
- * 'locales': !Array.<string>
522
- * }}
523
- *
475
+ * @event shaka.ui.Localization.LocaleChangedEvent
476
+ * @property {string} type
477
+ * 'locale-changed'
524
478
  * @property {!Array.<string>} locales
525
479
  * The new set of locales that user wanted,
526
480
  * and that were successfully found.
527
481
  * @exportDoc
528
482
  */
529
- shaka.ui.Localization.LocaleChangedEvent;
package/ui/pip_button.js CHANGED
@@ -130,9 +130,8 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
130
130
  await document.exitPictureInPicture();
131
131
  }
132
132
  } catch (error) {
133
- this.controls.dispatchEvent(new shaka.util.FakeEvent('error', {
134
- detail: error,
135
- }));
133
+ this.controls.dispatchEvent(new shaka.util.FakeEvent(
134
+ 'error', (new Map()).set('detail', error)));
136
135
  }
137
136
  }
138
137
 
package/ui/seek_bar.js CHANGED
@@ -15,7 +15,6 @@ goog.require('shaka.ui.RangeElement');
15
15
  goog.require('shaka.ui.Utils');
16
16
  goog.require('shaka.util.Dom');
17
17
  goog.require('shaka.util.Timer');
18
- goog.requireType('shaka.ads.CuePoint');
19
18
  goog.requireType('shaka.ui.Controls');
20
19
 
21
20
 
@@ -83,7 +82,7 @@ shaka.ui.SeekBar = class extends shaka.ui.RangeElement {
83
82
  */
84
83
  this.wasPlaying_ = false;
85
84
 
86
- /** @private {!Array.<!shaka.ads.CuePoint>} */
85
+ /** @private {!Array.<!shaka.extern.AdCuePoint>} */
87
86
  this.adCuePoints_ = [];
88
87
 
89
88
  this.eventManager.listen(this.localization,
@@ -64,6 +64,7 @@ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu {
64
64
 
65
65
  this.eventManager.listen(this.player, 'texttrackvisibility', () => {
66
66
  this.onCaptionStateChange_();
67
+ this.updateTextLanguages_();
67
68
  });
68
69
 
69
70
  this.eventManager.listen(this.player, 'textchanged', () => {