shaka-player 4.7.3 → 4.7.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.
@@ -155,6 +155,7 @@ shaka.ads.ClientSideAd = class {
155
155
  * @export
156
156
  */
157
157
  setVolume(volume) {
158
+ this.video_.volume = volume;
158
159
  return this.manager_.setVolume(volume);
159
160
  }
160
161
 
@@ -197,13 +198,14 @@ shaka.ads.ClientSideAd = class {
197
198
  * @export
198
199
  */
199
200
  setMuted(muted) {
201
+ this.video_.muted = muted;
200
202
  // Emulate the "mute" functionality, where current, pre-mute
201
203
  // volume is saved and can be restored on unmute.
202
204
  if (muted) {
203
205
  this.volume_ = this.getVolume();
204
- this.setVolume(0);
206
+ this.manager_.setVolume(0);
205
207
  } else {
206
- this.setVolume(this.volume_);
208
+ this.manager_.setVolume(this.volume_);
207
209
  }
208
210
  }
209
211
 
@@ -234,10 +234,12 @@ shaka.ads.ClientSideAdManager = class {
234
234
  videoPlayHead.currentTime = this.video_.currentTime;
235
235
  });
236
236
  this.eventManager_.listen(this.video_, 'volumechange', () => {
237
+ if (!this.ad_) {
238
+ return;
239
+ }
240
+ this.ad_.setVolume(this.video_.volume);
237
241
  if (this.video_.muted) {
238
- this.imaAdsManager_.setVolume(0);
239
- } else {
240
- this.imaAdsManager_.setVolume(this.video_.volume);
242
+ this.ad_.setMuted(true);
241
243
  }
242
244
  });
243
245
  }
@@ -79,7 +79,7 @@ shaka.cea.Cea608Memory = class {
79
79
  * @return {?shaka.extern.ICaptionDecoder.ClosedCaption}
80
80
  */
81
81
  forceEmit(startTime, endTime) {
82
- const stream = `CC${(this.fieldNum_<< 1) | this.channelNum_ +1}`;
82
+ const stream = `CC${((this.fieldNum_<< 1) | this.channelNum_) + 1}`;
83
83
  const topLevelCue = new shaka.text.Cue(
84
84
  startTime, endTime, /* payload= */ '');
85
85
  topLevelCue.lineInterpretation =
@@ -283,7 +283,7 @@ shaka.cea.CeaDecoder = class {
283
283
  // Get the correct stream for this caption packet (CC1, ..., CC4)
284
284
  const selectedChannel = fieldNum ?
285
285
  this.currentField2Channel_ : this.currentField1Channel_;
286
- const selectedMode = `CC${(fieldNum << 1) | selectedChannel + 1}`;
286
+ const selectedMode = `CC${((fieldNum << 1) | selectedChannel) + 1}`;
287
287
  const selectedStream = this.cea608ModeToStream_.get(selectedMode);
288
288
 
289
289
  // Check for bad frames (bad pairs). This can be two 0xff, two 0x00, or any
@@ -979,6 +979,22 @@ shaka.hls.HlsParser = class {
979
979
  this.presentationTimeline_.setSegmentAvailabilityDuration(
980
980
  segmentAvailabilityDuration);
981
981
  }
982
+
983
+ if (!this.presentationTimeline_.isStartTimeLocked()) {
984
+ const streamInfos = Array.from(this.uriToStreamInfosMap_.values());
985
+ const activeStreamInfos =
986
+ streamInfos.filter((s) => s.stream.segmentIndex);
987
+ for (const streamInfo of activeStreamInfos) {
988
+ if (streamInfo.type != 'audio' && streamInfo.type != 'video') {
989
+ continue;
990
+ }
991
+ const firstReference = streamInfo.stream.segmentIndex.get(0);
992
+ if (firstReference && firstReference.syncTime) {
993
+ const syncTime = firstReference.syncTime;
994
+ this.presentationTimeline_.setPresentationStartTime(syncTime);
995
+ }
996
+ }
997
+ }
982
998
  } else {
983
999
  // Use the minimum duration as the presentation duration.
984
1000
  this.presentationTimeline_.setDuration(this.getMinDuration_());
@@ -168,9 +168,6 @@ shaka.media.MediaSourceEngine = class {
168
168
 
169
169
  const mediaSource = new ManagedMediaSource();
170
170
 
171
- this.eventManager_.listenOnce(
172
- mediaSource, 'sourceopen', () => this.onSourceOpen_(p));
173
-
174
171
  this.eventManager_.listen(
175
172
  mediaSource, 'startstreaming', () => {
176
173
  this.streamingAllowed_ = true;
@@ -181,6 +178,9 @@ shaka.media.MediaSourceEngine = class {
181
178
  this.streamingAllowed_ = false;
182
179
  });
183
180
 
181
+ this.eventManager_.listenOnce(
182
+ mediaSource, 'sourceopen', () => this.onSourceOpen_(p));
183
+
184
184
  // Correctly set when playback has begun.
185
185
  this.eventManager_.listenOnce(this.video_, 'playing', () => {
186
186
  this.playbackHasBegun_ = true;
@@ -328,6 +328,17 @@ shaka.media.PresentationTimeline = class {
328
328
  }
329
329
 
330
330
 
331
+ /**
332
+ * Returns if the presentation timeline's start time is locked.
333
+ *
334
+ * @return {boolean}
335
+ * @export
336
+ */
337
+ isStartTimeLocked() {
338
+ return this.startTimeLocked_;
339
+ }
340
+
341
+
331
342
  /**
332
343
  * Gives PresentationTimeline a Stream's minimum segment start time.
333
344
  *
@@ -71,14 +71,6 @@ shaka.offline.SessionDeleter = class {
71
71
  return [];
72
72
  }
73
73
 
74
- try {
75
- await drmEngine.setServerCertificate();
76
- } catch (e) {
77
- shaka.log.warning('Error setting server certificate', e);
78
- await drmEngine.destroy();
79
- return [];
80
- }
81
-
82
74
  /** @type {!Array.<string>} */
83
75
  const sessionIds = [];
84
76
  await Promise.all(bucket.sessionIds.map(async (sessionId) => {
package/lib/player.js CHANGED
@@ -4837,12 +4837,18 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
4837
4837
 
4838
4838
  const references = [];
4839
4839
  for (const cue of cues) {
4840
- const imageUri = shaka.util.ManifestParserUtils.resolveUris(
4841
- [uri], [cue.payload])[0];
4840
+ let uris = null;
4841
+ const getUris = () => {
4842
+ if (uris == null) {
4843
+ uris = shaka.util.ManifestParserUtils.resolveUris(
4844
+ [uri], [cue.payload]);
4845
+ }
4846
+ return uris || [];
4847
+ };
4842
4848
  const reference = new shaka.media.SegmentReference(
4843
4849
  cue.startTime,
4844
4850
  cue.endTime,
4845
- () => [imageUri],
4851
+ getUris,
4846
4852
  /* startByte= */ 0,
4847
4853
  /* endByte= */ null,
4848
4854
  /* initSegmentReference= */ null,
@@ -4850,8 +4856,8 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
4850
4856
  /* appendWindowStart= */ 0,
4851
4857
  /* appendWindowEnd= */ Infinity,
4852
4858
  );
4853
- if (imageUri.includes('#xywh')) {
4854
- const spriteInfo = imageUri.split('#xywh=')[1].split(',');
4859
+ if (cue.payload.includes('#xywh')) {
4860
+ const spriteInfo = cue.payload.split('#xywh=')[1].split(',');
4855
4861
  if (spriteInfo.length === 4) {
4856
4862
  reference.setThumbnailSprite({
4857
4863
  height: parseInt(spriteInfo[3], 10),
@@ -6865,7 +6871,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
6865
6871
  * @export
6866
6872
  */
6867
6873
  // eslint-disable-next-line no-useless-concat
6868
- shaka.Player.version = 'v4.7.3' + '-uncompiled'; // x-release-please-version
6874
+ shaka.Player.version = 'v4.7.4' + '-uncompiled'; // x-release-please-version
6869
6875
 
6870
6876
  // Initialize the deprecation system using the version string we just set
6871
6877
  // on the player.
@@ -791,9 +791,3 @@ shaka.polyfill.PatchedMediaKeysApple.MediaKeyStatusMap = class {
791
791
  goog.asserts.assert(false, 'Not used! Provided only for the compiler.');
792
792
  }
793
793
  };
794
-
795
- if (!navigator.requestMediaKeySystemAccess ||
796
- // eslint-disable-next-line no-restricted-syntax
797
- !MediaKeySystemAccess.prototype.getConfiguration) {
798
- shaka.polyfill.register(shaka.polyfill.PatchedMediaKeysApple.install);
799
- }
@@ -451,6 +451,11 @@ shaka.text.VttTextParser = class {
451
451
  */
452
452
  static parseCueStyles(payload, rootCue, styles) {
453
453
  const VttTextParser = shaka.text.VttTextParser;
454
+ // Optimization for unstyled payloads.
455
+ if (!payload.includes('<')) {
456
+ rootCue.payload = VttTextParser.htmlUnescape_(payload);
457
+ return;
458
+ }
454
459
  if (styles.size === 0) {
455
460
  VttTextParser.addDefaultTextColor_(styles);
456
461
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shaka-player",
3
3
  "description": "DASH/EME video player library",
4
- "version": "4.7.3",
4
+ "version": "4.7.4",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [
package/ui/play_button.js CHANGED
@@ -72,6 +72,11 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
72
72
  this.updateIcon();
73
73
  });
74
74
 
75
+ this.eventManager.listen(this.adManager, AdManager.AD_STOPPED, () => {
76
+ this.updateAriaLabel();
77
+ this.updateIcon();
78
+ });
79
+
75
80
  this.eventManager.listen(this.button, 'click', () => {
76
81
  if (this.ad && this.ad.isLinear()) {
77
82
  this.controls.playPauseAd();
@@ -99,6 +104,18 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
99
104
  return this.controls.presentationIsPaused();
100
105
  }
101
106
 
107
+ /**
108
+ * @return {boolean}
109
+ * @protected
110
+ */
111
+ isEnded() {
112
+ if (this.ad && this.ad.isLinear()) {
113
+ return false;
114
+ }
115
+
116
+ return this.video.ended;
117
+ }
118
+
102
119
  /**
103
120
  * Called when the button's aria label needs to change.
104
121
  * To be overridden by subclasses.
@@ -38,7 +38,7 @@ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
38
38
  /** @override */
39
39
  updateIcon() {
40
40
  const Icons = shaka.ui.Enums.MaterialDesignIcons;
41
- if (this.video.ended) {
41
+ if (this.isEnded()) {
42
42
  this.button.textContent = Icons.REPLAY;
43
43
  } else {
44
44
  this.button.textContent = this.isPaused() ? Icons.PLAY : Icons.PAUSE;
@@ -48,7 +48,7 @@ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
48
48
  /** @override */
49
49
  updateAriaLabel() {
50
50
  const LocIds = shaka.ui.Locales.Ids;
51
- if (this.video.ended) {
51
+ if (this.isEnded()) {
52
52
  this.button.ariaLabel = this.localization.resolve(LocIds.REPLAY);
53
53
  } else {
54
54
  const label = this.isPaused() ? LocIds.PLAY : LocIds.PAUSE;