shaka-player 4.10.13 → 4.11.0

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 (91) hide show
  1. package/README.md +5 -1
  2. package/dist/controls.css +3 -3
  3. package/dist/controls.css.map +1 -1
  4. package/dist/deps.js +11 -11
  5. package/dist/locales.js +38 -34
  6. package/dist/shaka-player.compiled.d.ts +68 -33
  7. package/dist/shaka-player.compiled.debug.d.ts +68 -33
  8. package/dist/shaka-player.compiled.debug.externs.js +584 -544
  9. package/dist/shaka-player.compiled.debug.js +715 -676
  10. package/dist/shaka-player.compiled.debug.map +4 -4
  11. package/dist/shaka-player.compiled.externs.js +584 -544
  12. package/dist/shaka-player.compiled.js +1394 -1371
  13. package/dist/shaka-player.compiled.map +4 -4
  14. package/dist/shaka-player.ui.d.ts +76 -34
  15. package/dist/shaka-player.ui.debug.d.ts +76 -34
  16. package/dist/shaka-player.ui.debug.externs.js +77 -26
  17. package/dist/shaka-player.ui.debug.js +774 -720
  18. package/dist/shaka-player.ui.debug.map +4 -4
  19. package/dist/shaka-player.ui.externs.js +77 -26
  20. package/dist/shaka-player.ui.js +1649 -1617
  21. package/dist/shaka-player.ui.map +4 -4
  22. package/externs/mediasession.js +10 -1
  23. package/externs/shaka/ads.js +79 -2
  24. package/externs/shaka/manifest.js +6 -1
  25. package/externs/shaka/manifest_parser.js +6 -2
  26. package/externs/shaka/net.js +23 -2
  27. package/externs/shaka/player.js +414 -103
  28. package/externs/shaka/text.js +2 -1
  29. package/lib/abr/simple_abr_manager.js +5 -0
  30. package/lib/ads/ad_manager.js +45 -1
  31. package/lib/ads/ad_utils.js +124 -1
  32. package/lib/ads/interstitial_ad.js +9 -2
  33. package/lib/ads/interstitial_ad_manager.js +216 -101
  34. package/lib/ads/media_tailor_ad.js +1 -39
  35. package/lib/ads/media_tailor_ad_manager.js +32 -16
  36. package/lib/cea/cea608_data_channel.js +40 -8
  37. package/lib/cea/cea608_memory.js +28 -0
  38. package/lib/dash/dash_parser.js +162 -25
  39. package/lib/dash/segment_base.js +3 -2
  40. package/lib/dash/segment_list.js +6 -3
  41. package/lib/dash/segment_template.js +104 -20
  42. package/lib/hls/hls_parser.js +319 -215
  43. package/lib/media/drm_engine.js +11 -3
  44. package/lib/media/media_source_engine.js +0 -8
  45. package/lib/media/preload_manager.js +16 -4
  46. package/lib/media/segment_reference.js +3 -0
  47. package/lib/media/segment_utils.js +8 -1
  48. package/lib/media/streaming_engine.js +10 -6
  49. package/lib/mss/mss_parser.js +14 -2
  50. package/lib/net/http_fetch_plugin.js +12 -5
  51. package/lib/net/http_xhr_plugin.js +7 -3
  52. package/lib/net/networking_engine.js +21 -1
  53. package/lib/offline/manifest_converter.js +1 -0
  54. package/lib/offline/storage.js +1 -0
  55. package/lib/player.js +336 -121
  56. package/lib/text/cue.js +373 -0
  57. package/lib/text/mp4_ttml_parser.js +51 -1
  58. package/lib/text/mp4_vtt_parser.js +2 -5
  59. package/lib/text/sbv_text_parser.js +2 -31
  60. package/lib/text/srt_text_parser.js +1 -1
  61. package/lib/text/text_engine.js +1 -1
  62. package/lib/text/text_utils.js +1 -0
  63. package/lib/text/ttml_text_parser.js +14 -4
  64. package/lib/text/ui_text_displayer.js +0 -4
  65. package/lib/text/vtt_text_parser.js +10 -415
  66. package/lib/util/abortable_operation.js +8 -0
  67. package/lib/util/cmcd_manager.js +38 -0
  68. package/lib/util/error.js +16 -0
  69. package/lib/util/fake_event.js +1 -0
  70. package/lib/util/manifest_parser_utils.js +12 -3
  71. package/lib/util/player_configuration.js +4 -2
  72. package/lib/util/stream_utils.js +57 -2
  73. package/lib/util/tXml.js +2 -1
  74. package/lib/util/text_parser.js +46 -0
  75. package/lib/util/ts_parser.js +32 -3
  76. package/package.json +1 -1
  77. package/shaka-player.uncompiled.js +1 -1
  78. package/ui/chapter_selection.js +179 -0
  79. package/ui/controls.js +151 -0
  80. package/ui/enums.js +1 -0
  81. package/ui/externs/ui.js +7 -1
  82. package/ui/less/containers.less +3 -4
  83. package/ui/less/overflow_menu.less +5 -0
  84. package/ui/less/tooltip.less +1 -1
  85. package/ui/locales/en.json +1 -0
  86. package/ui/locales/es.json +1 -0
  87. package/ui/locales/fr.json +1 -0
  88. package/ui/locales/source.json +4 -0
  89. package/ui/seek_bar.js +3 -2
  90. package/ui/ui.js +2 -0
  91. package/lib/polyfill/abort_controller.js +0 -158
@@ -38,11 +38,12 @@ shaka.extern.TextParser = class {
38
38
  * for each cue.
39
39
  * @param {?(string|undefined)} uri
40
40
  * The media uri.
41
+ * @param {!Array.<string>} images
41
42
  * @return {!Array.<!shaka.text.Cue>}
42
43
  *
43
44
  * @exportDoc
44
45
  */
45
- parseMedia(data, timeContext, uri) {}
46
+ parseMedia(data, timeContext, uri, images) {}
46
47
 
47
48
  /**
48
49
  * Notifies the stream if the manifest is in sequence mode or not.
@@ -344,6 +344,11 @@ shaka.abr.SimpleAbrManager = class {
344
344
  */
345
345
  getBandwidthEstimate() {
346
346
  const defaultBandwidthEstimate = this.getDefaultBandwidth_();
347
+ if (navigator.connection && navigator.connection.downlink &&
348
+ this.config_.useNetworkInformation &&
349
+ this.config_.preferNetworkInformationBandwidth) {
350
+ return defaultBandwidthEstimate;
351
+ }
347
352
  const bandwidthEstimate = this.bandwidthEstimator_.getBandwidthEstimate(
348
353
  defaultBandwidthEstimate);
349
354
  if (this.cmsdManager_) {
@@ -823,7 +823,7 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
823
823
  * @override
824
824
  * @export
825
825
  */
826
- onInterstitialMetadata(basePlayer, baseVideo, interstitial) {
826
+ onHLSInterstitialMetadata(basePlayer, baseVideo, interstitial) {
827
827
  if (!this.interstitialAdManager_) {
828
828
  this.initInterstitial(/* adContainer= */ null, basePlayer, baseVideo);
829
829
  }
@@ -832,6 +832,50 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
832
832
  }
833
833
  }
834
834
 
835
+ /**
836
+ * @override
837
+ * @export
838
+ */
839
+ onDASHInterstitialMetadata(basePlayer, baseVideo, region) {
840
+ if (region.schemeIdUri != 'urn:mpeg:dash:event:alternativeMPD:2022') {
841
+ return;
842
+ }
843
+ if (!this.interstitialAdManager_) {
844
+ this.initInterstitial(/* adContainer= */ null, basePlayer, baseVideo);
845
+ }
846
+ if (this.interstitialAdManager_) {
847
+ this.interstitialAdManager_.addRegion(region);
848
+ }
849
+ }
850
+
851
+ /**
852
+ * @override
853
+ * @export
854
+ */
855
+ addCustomInterstitial(interstitial) {
856
+ if (!this.interstitialAdManager_) {
857
+ throw new shaka.util.Error(
858
+ shaka.util.Error.Severity.RECOVERABLE,
859
+ shaka.util.Error.Category.ADS,
860
+ shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);
861
+ }
862
+ this.interstitialAdManager_.addInterstitials([interstitial]);
863
+ }
864
+
865
+ /**
866
+ * @override
867
+ * @export
868
+ */
869
+ addAdUrlInterstitial(url) {
870
+ if (!this.interstitialAdManager_) {
871
+ throw new shaka.util.Error(
872
+ shaka.util.Error.Severity.RECOVERABLE,
873
+ shaka.util.Error.Category.ADS,
874
+ shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);
875
+ }
876
+ return this.interstitialAdManager_.addAdUrlInterstitial(url);
877
+ }
878
+
835
879
  /**
836
880
  * @param {!shaka.util.FakeEvent} event
837
881
  * @private
@@ -7,13 +7,136 @@
7
7
 
8
8
  goog.provide('shaka.ads.Utils');
9
9
 
10
+ goog.require('shaka.util.TextParser');
11
+ goog.require('shaka.util.TXml');
12
+
10
13
 
11
14
  /**
12
15
  * A class responsible for ad utils.
13
16
  * @export
14
17
  */
15
18
  shaka.ads.Utils = class {
16
-
19
+ /**
20
+ * @param {!shaka.extern.xml.Node} vast
21
+ * @param {?number} currentTime
22
+ * @return {!Array.<shaka.extern.AdInterstitial>}
23
+ */
24
+ static parseVastToInterstitials(vast, currentTime) {
25
+ const TXml = shaka.util.TXml;
26
+ /** @type {!Array.<shaka.extern.AdInterstitial>} */
27
+ const interstitials = [];
28
+
29
+ let startTime = 0;
30
+ if (currentTime != null) {
31
+ startTime = currentTime;
32
+ }
33
+
34
+ for (const ad of TXml.findChildren(vast, 'Ad')) {
35
+ const inline = TXml.findChild(ad, 'InLine');
36
+ if (!inline) {
37
+ continue;
38
+ }
39
+ const creatives = TXml.findChild(inline, 'Creatives');
40
+ if (!creatives) {
41
+ continue;
42
+ }
43
+ for (const creative of TXml.findChildren(creatives, 'Creative')) {
44
+ const linear = TXml.findChild(creative, 'Linear');
45
+ if (!linear) {
46
+ continue;
47
+ }
48
+ let skipOffset = null;
49
+ if (linear.attributes['skipoffset']) {
50
+ skipOffset = shaka.util.TextParser.parseTime(
51
+ linear.attributes['skipoffset']);
52
+ if (isNaN(skipOffset)) {
53
+ skipOffset = null;
54
+ }
55
+ }
56
+ const mediaFiles = TXml.findChild(linear, 'MediaFiles');
57
+ if (!mediaFiles) {
58
+ continue;
59
+ }
60
+ const medias = TXml.findChildren(mediaFiles, 'MediaFile');
61
+ let checkMedias = medias;
62
+ const streamingMedias = medias.filter((media) => {
63
+ return media.attributes['delivery'] == 'streaming';
64
+ });
65
+ if (streamingMedias.length) {
66
+ checkMedias = streamingMedias;
67
+ }
68
+ const sortedMedias = checkMedias.sort((a, b) => {
69
+ const aHeight = parseInt(a.attributes['height'], 10) || 0;
70
+ const bHeight = parseInt(b.attributes['height'], 10) || 0;
71
+ return bHeight - aHeight;
72
+ });
73
+ for (const media of sortedMedias) {
74
+ const adUrl = TXml.getTextContents(media);
75
+ if (!adUrl) {
76
+ continue;
77
+ }
78
+ interstitials.push({
79
+ id: null,
80
+ startTime: startTime,
81
+ endTime: null,
82
+ uri: adUrl,
83
+ isSkippable: skipOffset != null,
84
+ skipOffset,
85
+ canJump: false,
86
+ resumeOffset: 0,
87
+ playoutLimit: null,
88
+ once: true,
89
+ pre: currentTime == null,
90
+ post: currentTime == Infinity,
91
+ timelineRange: false,
92
+ });
93
+ break;
94
+ }
95
+ }
96
+ }
97
+ return interstitials;
98
+ }
99
+
100
+ /**
101
+ * @param {!shaka.extern.xml.Node} vmap
102
+ * @return {!Array.<{time: ?number, uri: string}>}
103
+ */
104
+ static parseVMAP(vmap) {
105
+ const TXml = shaka.util.TXml;
106
+ /** @type {!Array.<{time: ?number, uri: string}>} */
107
+ const ads = [];
108
+ for (const adBreak of TXml.findChildren(vmap, 'vmap:AdBreak')) {
109
+ const timeOffset = adBreak.attributes['timeOffset'];
110
+ if (!timeOffset) {
111
+ continue;
112
+ }
113
+ let time = null;
114
+ if (timeOffset == 'start') {
115
+ time = 0;
116
+ } else if (timeOffset == 'end') {
117
+ time = Infinity;
118
+ } else {
119
+ time = shaka.util.TextParser.parseTime(timeOffset);
120
+ }
121
+ const adSource = TXml.findChild(adBreak, 'vmap:AdSource');
122
+ if (!adSource) {
123
+ continue;
124
+ }
125
+ const adTagURI = TXml.findChild(adSource, 'vmap:AdTagURI');
126
+ if (!adTagURI) {
127
+ continue;
128
+ }
129
+ const uri = TXml.getTextContents(adTagURI);
130
+ if (!uri) {
131
+ continue;
132
+ }
133
+ ads.push({
134
+ time,
135
+ uri,
136
+ });
137
+ }
138
+ return ads;
139
+ }
17
140
  };
18
141
 
19
142
  /**
@@ -15,17 +15,22 @@ shaka.ads.InterstitialAd = class {
15
15
  /**
16
16
  * @param {HTMLMediaElement} video
17
17
  * @param {boolean} isSkippable
18
+ * @param {?number} skipOffset
18
19
  * @param {function()} onSkip
19
20
  * @param {number} sequenceLength
20
21
  * @param {number} adPosition
21
22
  */
22
- constructor(video, isSkippable, onSkip, sequenceLength, adPosition) {
23
+ constructor(video, isSkippable, skipOffset, onSkip,
24
+ sequenceLength, adPosition) {
23
25
  /** @private {HTMLMediaElement} */
24
26
  this.video_ = video;
25
27
 
26
28
  /** @private {boolean} */
27
29
  this.isSkippable_ = isSkippable;
28
30
 
31
+ /** @private {?number} */
32
+ this.skipOffset_ = skipOffset;
33
+
29
34
  /** @private {function()} */
30
35
  this.onSkip_ = onSkip;
31
36
 
@@ -98,7 +103,9 @@ shaka.ads.InterstitialAd = class {
98
103
  */
99
104
  getTimeUntilSkippable() {
100
105
  if (this.isSkippable_) {
101
- return 0;
106
+ const canSkipIn =
107
+ this.getRemainingTime() + this.skipOffset_ - this.getDuration();
108
+ return Math.max(canSkipIn, 0);
102
109
  }
103
110
  return Math.max(this.getRemainingTime(), 0);
104
111
  }