shaka-player 3.1.1 → 3.1.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.
Files changed (151) hide show
  1. package/AUTHORS +7 -2
  2. package/CHANGELOG.md +199 -0
  3. package/CONTRIBUTORS +9 -3
  4. package/build/generateExterns.js +1 -1
  5. package/build/misspellings.txt +1 -0
  6. package/build/shakaBuildHelpers.py +6 -5
  7. package/build/subprocessWindowsPatch.py +103 -0
  8. package/demo/common/assets.js +1 -1
  9. package/dist/controls.css +2 -2
  10. package/dist/controls.css.map +1 -1
  11. package/dist/demo.compiled.debug.js +1 -1
  12. package/dist/demo.compiled.js +1 -1
  13. package/dist/deps.js +7 -7
  14. package/dist/locales.js +35 -33
  15. package/dist/receiver.compiled.debug.js +1 -1
  16. package/dist/receiver.compiled.js +1 -1
  17. package/dist/shaka-player.compiled.d.ts +171 -3
  18. package/dist/shaka-player.compiled.debug.d.ts +171 -3
  19. package/dist/shaka-player.compiled.debug.externs.js +179 -1
  20. package/dist/shaka-player.compiled.debug.js +365 -344
  21. package/dist/shaka-player.compiled.debug.map +3 -3
  22. package/dist/shaka-player.compiled.externs.js +179 -1
  23. package/dist/shaka-player.compiled.js +806 -798
  24. package/dist/shaka-player.compiled.map +3 -3
  25. package/dist/shaka-player.ui.d.ts +171 -3
  26. package/dist/shaka-player.ui.debug.d.ts +171 -3
  27. package/dist/shaka-player.ui.debug.externs.js +181 -3
  28. package/dist/shaka-player.ui.debug.js +458 -435
  29. package/dist/shaka-player.ui.debug.map +4 -4
  30. package/dist/shaka-player.ui.externs.js +181 -3
  31. package/dist/shaka-player.ui.js +927 -918
  32. package/dist/shaka-player.ui.map +4 -4
  33. package/docs/tutorials/fairplay.md +1 -1
  34. package/docs/tutorials/faq.md +14 -0
  35. package/docs/tutorials/index.json +2 -2
  36. package/docs/tutorials/upgrade-v3.md +38 -0
  37. package/docs/tutorials/upgrade.md +3 -3
  38. package/externs/ima.js +4 -0
  39. package/externs/shaka/ads.js +2 -0
  40. package/externs/shaka/player.js +6 -0
  41. package/externs/shaka/text.js +10 -0
  42. package/karma.conf.js +1 -0
  43. package/lib/ads/ad_manager.js +29 -11
  44. package/lib/ads/client_side_ad_manager.js +76 -86
  45. package/lib/ads/server_side_ad_manager.js +26 -11
  46. package/lib/cast/cast_proxy.js +3 -2
  47. package/lib/cast/cast_receiver.js +2 -1
  48. package/lib/cast/cast_sender.js +2 -2
  49. package/lib/cea/sei_processor.js +24 -17
  50. package/lib/dash/dash_parser.js +100 -5
  51. package/lib/dash/segment_list.js +1 -1
  52. package/lib/dash/segment_template.js +7 -4
  53. package/lib/hls/hls_parser.js +44 -17
  54. package/lib/media/closed_caption_parser.js +3 -1
  55. package/lib/media/content_workarounds.js +12 -0
  56. package/lib/media/drm_engine.js +20 -1
  57. package/lib/media/gap_jumping_controller.js +8 -4
  58. package/lib/media/media_source_engine.js +1 -2
  59. package/lib/media/playhead.js +1 -1
  60. package/lib/media/presentation_timeline.js +3 -1
  61. package/lib/media/segment_reference.js +8 -0
  62. package/lib/media/streaming_engine.js +28 -19
  63. package/lib/net/networking_engine.js +2 -1
  64. package/lib/player.js +108 -54
  65. package/lib/polyfill/encryption_scheme.js +2 -0
  66. package/lib/polyfill/fullscreen.js +2 -0
  67. package/lib/polyfill/mathround.js +2 -0
  68. package/lib/polyfill/media_capabilities.js +76 -22
  69. package/lib/polyfill/mediasource.js +8 -0
  70. package/lib/polyfill/orientation.js +3 -1
  71. package/lib/polyfill/patchedmediakeys_apple.js +6 -4
  72. package/lib/polyfill/patchedmediakeys_ms.js +6 -4
  73. package/lib/polyfill/patchedmediakeys_nop.js +2 -0
  74. package/lib/polyfill/patchedmediakeys_webkit.js +6 -4
  75. package/lib/polyfill/pip_webkit.js +2 -0
  76. package/lib/polyfill/storage_estimate.js +2 -0
  77. package/lib/polyfill/video_play_promise.js +2 -0
  78. package/lib/polyfill/videoplaybackquality.js +2 -0
  79. package/lib/polyfill/vttcue.js +2 -0
  80. package/lib/text/cue.js +17 -0
  81. package/lib/text/mp4_ttml_parser.js +3 -0
  82. package/lib/text/text_engine.js +14 -2
  83. package/lib/text/ttml_text_parser.js +135 -87
  84. package/lib/text/ui_text_displayer.js +233 -83
  85. package/lib/text/vtt_text_parser.js +4 -2
  86. package/lib/util/fake_event.js +53 -7
  87. package/lib/util/mp4_box_parsers.js +1 -1
  88. package/lib/util/periods.js +111 -35
  89. package/lib/util/platform.js +13 -1
  90. package/lib/util/stream_utils.js +79 -10
  91. package/lib/util/xml_utils.js +19 -0
  92. package/package.json +2 -2
  93. package/test/cast/cast_proxy_unit.js +12 -6
  94. package/test/cast/cast_receiver_integration.js +1 -1
  95. package/test/cast/cast_utils_unit.js +1 -1
  96. package/test/cea/mp4_cea_parser_unit.js +26 -0
  97. package/test/dash/dash_parser_live_unit.js +1 -0
  98. package/test/dash/dash_parser_manifest_unit.js +220 -2
  99. package/test/dash/dash_parser_segment_template_unit.js +3 -3
  100. package/test/hls/hls_parser_unit.js +5 -1
  101. package/test/media/closed_caption_parser_unit.js +20 -0
  102. package/test/media/drm_engine_unit.js +56 -0
  103. package/test/media/playhead_unit.js +27 -1
  104. package/test/media/presentation_timeline_unit.js +19 -0
  105. package/test/media/streaming_engine_integration.js +2 -1
  106. package/test/media/streaming_engine_unit.js +148 -3
  107. package/test/player_integration.js +38 -0
  108. package/test/player_unit.js +101 -0
  109. package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
  110. package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
  111. package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
  112. package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
  113. package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
  114. package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
  115. package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
  116. package/test/test/assets/3675/dash_0.mpd +30 -0
  117. package/test/test/assets/3675/dash_1.mpd +30 -0
  118. package/test/test/assets/3675/dash_2.mpd +30 -0
  119. package/test/test/assets/3675/dash_3.mpd +30 -0
  120. package/test/test/assets/3675/dash_4.mpd +30 -0
  121. package/test/test/assets/3675/dash_5.mpd +26 -0
  122. package/test/test/assets/3675/init-stream0.m4s +0 -0
  123. package/test/test/assets/empty_caption_video_init.mp4 +0 -0
  124. package/test/test/assets/empty_caption_video_segment.mp4 +0 -0
  125. package/test/test/util/fake_ad_manager.js +4 -1
  126. package/test/test/util/simple_fakes.js +5 -3
  127. package/test/test/util/ttml_utils.js +81 -0
  128. package/test/text/mp4_ttml_parser_unit.js +11 -18
  129. package/test/text/ttml_text_parser_unit.js +542 -220
  130. package/test/text/ui_text_displayer_unit.js +95 -18
  131. package/test/text/vtt_text_parser_unit.js +17 -1
  132. package/test/ui/localization_unit.js +15 -14
  133. package/test/ui/text_displayer_layout_unit.js +52 -1
  134. package/test/util/mp4_box_parsers_unit.js +28 -0
  135. package/test/util/periods_unit.js +190 -2
  136. package/test/util/stream_utils_unit.js +59 -2
  137. package/ui/airplay_button.js +5 -0
  138. package/ui/big_play_button.js +10 -0
  139. package/ui/cast_button.js +2 -3
  140. package/ui/controls.js +8 -6
  141. package/ui/less/buttons.less +0 -4
  142. package/ui/less/containers.less +10 -5
  143. package/ui/locales/en.json +1 -0
  144. package/ui/locales/ru.json +6 -6
  145. package/ui/locales/source.json +4 -0
  146. package/ui/localization.js +28 -51
  147. package/ui/pip_button.js +2 -3
  148. package/ui/play_button.js +10 -10
  149. package/ui/small_play_button.js +12 -0
  150. package/ui/text_selection.js +1 -0
  151. package/docs/tutorials/upgrade-v2-4.md +0 -481
@@ -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": "Воспроизвести",
@@ -113,6 +113,10 @@
113
113
  "message": "Playback speed",
114
114
  "description": "Label for a button used to navigate to a submenu to choose the playback speed in the video player."
115
115
  },
116
+ "REPLAY": {
117
+ "description": "Label for a button used to replay the video in a video player.",
118
+ "message": "Replay"
119
+ },
116
120
  "RESOLUTION": {
117
121
  "description": "Label for a button used to open a submenu to choose a video resolution in the video player.",
118
122
  "meaning": "Visual quality",
@@ -130,28 +130,20 @@ shaka.ui.Localization = class {
130
130
  (locale) => !this.localizations_.has(locale));
131
131
 
132
132
  if (missing.length) {
133
- /** @type {shaka.ui.Localization.UnknownLocalesEvent} */
134
- const eMissing = {
135
- 'locales': missing,
136
- };
137
-
138
133
  this.events_.dispatchEvent(new shaka.util.FakeEvent(
139
134
  Class.UNKNOWN_LOCALES,
140
- eMissing));
135
+ (new Map()).set('locales', missing)));
141
136
  }
142
137
 
143
138
  const found = shaka.util.Iterables.filter(
144
139
  this.currentLocales_,
145
140
  (locale) => this.localizations_.has(locale));
146
141
 
147
- /** @type {shaka.ui.Localization.LocaleChangedEvent} */
148
- const eFound = {
149
- 'locales': found.length ? found : [this.fallbackLocale_],
150
- };
151
-
142
+ const data = (new Map()).set(
143
+ 'locales', found.length ? found : [this.fallbackLocale_]);
152
144
  this.events_.dispatchEvent(new shaka.util.FakeEvent(
153
145
  Class.LOCALE_CHANGED,
154
- eFound));
146
+ data));
155
147
  }
156
148
 
157
149
  /**
@@ -253,14 +245,11 @@ shaka.ui.Localization = class {
253
245
  // number of locales. Since we don't know which ones we actually checked,
254
246
  // just tell them the preferred locale.
255
247
 
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));
248
+ const data = new Map()
249
+ // Make a copy to avoid leaking references.
250
+ .set('locales', Array.from(this.currentLocales_))
251
+ .set('missing', id);
252
+ this.events_.dispatchEvent(new FakeEvent(Class.UNKNOWN_LOCALIZATION, data));
264
253
 
265
254
  return '';
266
255
  }
@@ -381,18 +370,16 @@ shaka.ui.Localization = class {
381
370
  }
382
371
 
383
372
  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
- };
373
+ const data = new Map()
374
+ // Make a copy of the preferred locales to avoid leaking references.
375
+ .set('locales', Array.from(preferredLocales))
376
+ // Because more people like arrays more than sets, convert the set to
377
+ // an array.
378
+ .set('missing', Array.from(missing));
392
379
 
393
380
  this.events_.dispatchEvent(new shaka.util.FakeEvent(
394
381
  shaka.ui.Localization.MISSING_LOCALIZATIONS,
395
- e));
382
+ data));
396
383
  }
397
384
  }
398
385
 
@@ -478,52 +465,42 @@ shaka.ui.Localization.LOCALE_CHANGED = 'locale-changed';
478
465
  shaka.ui.Localization.LOCALE_UPDATED = 'locale-updated';
479
466
 
480
467
  /**
481
- * @typedef {{
482
- * 'locales': !Array.<string>
483
- * }}
484
- *
468
+ * @event shaka.ui.Localization.UnknownLocalesEvent
469
+ * @property {string} type
470
+ * 'unknown-locales'
485
471
  * @property {!Array.<string>} locales
486
472
  * The locales that the user wanted but could not be found.
487
473
  * @exportDoc
488
474
  */
489
- shaka.ui.Localization.UnknownLocalesEvent;
490
475
 
491
476
  /**
492
- * @typedef {{
493
- * 'locales': !Array.<string>,
494
- * 'missing': string
495
- * }}
496
- *
477
+ * @event shaka.ui.Localization.MissingLocalizationsEvent
478
+ * @property {string} type
479
+ * 'unknown-localization'
497
480
  * @property {!Array.<string>} locales
498
481
  * The locales that the user wanted.
499
482
  * @property {string} missing
500
483
  * The id of the unknown entry.
501
484
  * @exportDoc
502
485
  */
503
- shaka.ui.Localization.UnknownLocalizationEvent;
504
486
 
505
487
  /**
506
- * @typedef {{
507
- * 'locales': !Array.<string>,
508
- * 'missing': !Array.<string>
509
- * }}
510
- *
488
+ * @event shaka.ui.Localization.MissingLocalizationsEvent
489
+ * @property {string} type
490
+ * 'missing-localizations'
511
491
  * @property {string} locale
512
492
  * The locale that the user wanted.
513
493
  * @property {!Array.<string>} missing
514
494
  * The ids of the missing entries.
515
495
  * @exportDoc
516
496
  */
517
- shaka.ui.Localization.MissingLocalizationsEvent;
518
497
 
519
498
  /**
520
- * @typedef {{
521
- * 'locales': !Array.<string>
522
- * }}
523
- *
499
+ * @event shaka.ui.Localization.LocaleChangedEvent
500
+ * @property {string} type
501
+ * 'locale-changed'
524
502
  * @property {!Array.<string>} locales
525
503
  * The new set of locales that user wanted,
526
504
  * and that were successfully found.
527
505
  * @exportDoc
528
506
  */
529
- shaka.ui.Localization.LocaleChangedEvent;
package/ui/pip_button.js CHANGED
@@ -131,9 +131,8 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
131
131
  await document.exitPictureInPicture();
132
132
  }
133
133
  } catch (error) {
134
- this.controls.dispatchEvent(new shaka.util.FakeEvent('error', {
135
- detail: error,
136
- }));
134
+ this.controls.dispatchEvent(new shaka.util.FakeEvent(
135
+ 'error', (new Map()).set('detail', error)));
137
136
  }
138
137
  }
139
138
 
package/ui/play_button.js CHANGED
@@ -8,9 +8,7 @@
8
8
  goog.provide('shaka.ui.PlayButton');
9
9
 
10
10
  goog.require('shaka.ads.AdManager');
11
- goog.require('shaka.ui.Constants');
12
11
  goog.require('shaka.ui.Element');
13
- goog.require('shaka.ui.Locales');
14
12
  goog.require('shaka.ui.Localization');
15
13
  goog.require('shaka.util.Dom');
16
14
  goog.requireType('shaka.ui.Controls');
@@ -54,6 +52,11 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
54
52
  this.updateIcon();
55
53
  });
56
54
 
55
+ this.eventManager.listen(this.video, 'seeking', () => {
56
+ this.updateAriaLabel();
57
+ this.updateIcon();
58
+ });
59
+
57
60
  this.eventManager.listen(this.adManager, AdManager.AD_PAUSED, () => {
58
61
  this.updateAriaLabel();
59
62
  this.updateIcon();
@@ -96,14 +99,11 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
96
99
  return this.controls.presentationIsPaused();
97
100
  }
98
101
 
99
- /** @protected */
100
- updateAriaLabel() {
101
- const LocIds = shaka.ui.Locales.Ids;
102
- const label = this.isPaused() ? LocIds.PLAY : LocIds.PAUSE;
103
-
104
- this.button.setAttribute(shaka.ui.Constants.ARIA_LABEL,
105
- this.localization.resolve(label));
106
- }
102
+ /**
103
+ * Called when the button's aria label needs to change.
104
+ * To be overridden by subclasses.
105
+ */
106
+ updateAriaLabel() {}
107
107
 
108
108
  /**
109
109
  * Called when the button's icon needs to change.
@@ -9,6 +9,7 @@ goog.provide('shaka.ui.SmallPlayButton');
9
9
 
10
10
  goog.require('shaka.ui.Controls');
11
11
  goog.require('shaka.ui.Enums');
12
+ goog.require('shaka.ui.Locales');
12
13
  goog.require('shaka.ui.PlayButton');
13
14
 
14
15
 
@@ -42,6 +43,17 @@ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
42
43
  this.button.textContent = this.isPaused() ? Icons.PLAY : Icons.PAUSE;
43
44
  }
44
45
  }
46
+
47
+ /** @override */
48
+ updateAriaLabel() {
49
+ const LocIds = shaka.ui.Locales.Ids;
50
+ if (this.video.ended) {
51
+ this.button.ariaLabel = this.localization.resolve(LocIds.REPLAY);
52
+ } else {
53
+ const label = this.isPaused() ? LocIds.PLAY : LocIds.PAUSE;
54
+ this.button.ariaLabel = this.localization.resolve(label);
55
+ }
56
+ }
45
57
  };
46
58
 
47
59
 
@@ -65,6 +65,7 @@ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu {
65
65
 
66
66
  this.eventManager.listen(this.player, 'texttrackvisibility', () => {
67
67
  this.onCaptionStateChange_();
68
+ this.updateTextLanguages_();
68
69
  });
69
70
 
70
71
  this.eventManager.listen(this.player, 'textchanged', () => {