shaka-player 4.8.1 → 4.8.2

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.
@@ -282,12 +282,6 @@ shaka.dash.MpdUtils = class {
282
282
  const durationStr =
283
283
  MpdUtils.inheritAttribute(context, callback, 'duration');
284
284
  let segmentDuration = TXml.parsePositiveInt(durationStr || '');
285
- const ContentType = shaka.util.ManifestParserUtils.ContentType;
286
- // TODO: The specification is not clear, check this once it is resolved:
287
- // https://github.com/Dash-Industry-Forum/DASH-IF-IOP/issues/404
288
- if (context.representation.contentType == ContentType.IMAGE) {
289
- segmentDuration = TXml.parseFloat(durationStr || '');
290
- }
291
285
  if (segmentDuration) {
292
286
  segmentDuration /= timescale;
293
287
  }
@@ -398,6 +398,11 @@ shaka.dash.SegmentTemplate = class {
398
398
  Math.ceil(availablePeriodTimes[1] / segmentDuration) - 1,
399
399
  ];
400
400
 
401
+ // For Low Latency we can request the partial current position.
402
+ if (context.representation.availabilityTimeOffset) {
403
+ availablePeriodPositions[1]++;
404
+ }
405
+
401
406
  // In absolute positions.
402
407
  const availablePresentationPositions =
403
408
  availablePeriodPositions.map((x) => x + startNumber);
@@ -382,10 +382,10 @@ shaka.media.MediaSourcePlayhead = class {
382
382
  seekStart = seekEnd - this.minSeekRange_;
383
383
  }
384
384
 
385
- if (currentTime < seekStart || currentTime > seekEnd) {
386
- // playhead is outside of the seekrange. Move playhead to catch up.
385
+ if (currentTime < seekStart) {
386
+ // The seek range has moved past the playhead. Move ahead to catch up.
387
387
  const targetTime = this.reposition_(currentTime);
388
- shaka.log.info('Jumping by ' + (targetTime - currentTime) +
388
+ shaka.log.info('Jumping forward ' + (targetTime - currentTime) +
389
389
  ' seconds to catch up with the seek range.');
390
390
  this.mediaElement_.currentTime = targetTime;
391
391
  }
@@ -147,7 +147,12 @@ shaka.media.SegmentPrefetch = class {
147
147
  }
148
148
 
149
149
  // init segments are ignored from the prefetch limit
150
- if (!this.initSegmentPrefetchMap_.has(initSegmentReference)) {
150
+ const initSegments = Array.from(this.initSegmentPrefetchMap_.keys());
151
+ const someReference = initSegments.some((reference) => {
152
+ return shaka.media.InitSegmentReference.equal(
153
+ reference, initSegmentReference);
154
+ });
155
+ if (!someReference) {
151
156
  const segmentPrefetchOperation =
152
157
  new shaka.media.SegmentPrefetchOperation(this.fetchDispatcher_);
153
158
  segmentPrefetchOperation.dispatchFetch(
@@ -233,6 +238,15 @@ shaka.media.SegmentPrefetch = class {
233
238
  this.prefetchPosTime_ = 0;
234
239
  }
235
240
 
241
+ /**
242
+ * Remove a reference of prefetched segment if already exists.
243
+ * @param {!shaka.media.SegmentReference} reference
244
+ * @public
245
+ */
246
+ removeReference(reference) {
247
+ this.abortPrefetchedSegment_(reference);
248
+ }
249
+
236
250
  /**
237
251
  * @param {number} time
238
252
  * @param {boolean=} clearInitSegments
@@ -261,9 +275,11 @@ shaka.media.SegmentPrefetch = class {
261
275
  const segmentReferences = Array.from(this.segmentPrefetchMap_.keys());
262
276
  for (const initSegmentReference of this.initSegmentPrefetchMap_.keys()) {
263
277
  // if no segment references this init segment, we should remove it.
264
- if (!segmentReferences.some(
265
- (segmentReference) =>
266
- segmentReference.initSegmentReference === initSegmentReference)) {
278
+ const someReference = segmentReferences.some((segmentReference) => {
279
+ return shaka.media.InitSegmentReference.equal(
280
+ segmentReference.initSegmentReference, initSegmentReference);
281
+ });
282
+ if (!someReference) {
267
283
  this.abortPrefetchedSegment_(initSegmentReference);
268
284
  }
269
285
  }
@@ -1702,6 +1702,11 @@ shaka.media.StreamingEngine = class {
1702
1702
  error.code);
1703
1703
  mediaState.hasError = true;
1704
1704
 
1705
+ if (error.category == shaka.util.Error.Category.NETWORK &&
1706
+ mediaState.segmentPrefetch) {
1707
+ mediaState.segmentPrefetch.removeReference(reference);
1708
+ }
1709
+
1705
1710
  error.severity = shaka.util.Error.Severity.CRITICAL;
1706
1711
  await this.handleStreamingError_(mediaState, error);
1707
1712
  }
package/lib/player.js CHANGED
@@ -7182,7 +7182,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
7182
7182
  * @export
7183
7183
  */
7184
7184
  // eslint-disable-next-line no-useless-concat
7185
- shaka.Player.version = 'v4.8.1' + '-uncompiled'; // x-release-please-version
7185
+ shaka.Player.version = 'v4.8.2' + '-uncompiled'; // x-release-please-version
7186
7186
 
7187
7187
  // Initialize the deprecation system using the version string we just set
7188
7188
  // on the player.
@@ -8,6 +8,7 @@
8
8
  goog.provide('shaka.text.UITextDisplayer');
9
9
 
10
10
  goog.require('goog.asserts');
11
+ goog.require('shaka.Deprecate');
11
12
  goog.require('shaka.text.Cue');
12
13
  goog.require('shaka.text.CueRegion');
13
14
  goog.require('shaka.util.Dom');
@@ -65,12 +66,22 @@ shaka.text.UITextDisplayer = class {
65
66
 
66
67
  this.videoContainer_.appendChild(this.textContainer_);
67
68
 
69
+ if (!config || !config.captionsUpdatePeriod) {
70
+ shaka.Deprecate.deprecateFeature(5,
71
+ 'UITextDisplayer w/ config',
72
+ 'Please migrate to initializing UITextDisplayer with a config.');
73
+ }
74
+
75
+ /** @private {number} */
76
+ const updatePeriod = (config && config.captionsUpdatePeriod) ?
77
+ config.captionsUpdatePeriod : 0.25;
78
+
68
79
  /** @private {shaka.util.Timer} */
69
80
  this.captionsTimer_ = new shaka.util.Timer(() => {
70
81
  if (!this.video_.paused) {
71
82
  this.updateCaptions_();
72
83
  }
73
- }).tickEvery(config.captionsUpdatePeriod);
84
+ }).tickEvery(updatePeriod);
74
85
 
75
86
  /**
76
87
  * Maps cues to cue elements. Specifically points out the wrapper element of
@@ -186,6 +186,17 @@ shaka.util.Platform = class {
186
186
  return shaka.util.Platform.userAgentContains_('CrKey');
187
187
  }
188
188
 
189
+ /**
190
+ * Check if the current platform is a Google Chromecast with Android
191
+ * (i.e. Chromecast with GoogleTV).
192
+ *
193
+ * @return {boolean}
194
+ */
195
+ static isAndroidCastDevice() {
196
+ const Platform = shaka.util.Platform;
197
+ return Platform.isChromecast() && Platform.isAndroid();
198
+ }
199
+
189
200
  /**
190
201
  * Returns a major version number for Chrome, or Chromium-based browsers.
191
202
  *
@@ -416,6 +427,9 @@ shaka.util.Platform = class {
416
427
  return navigator.userAgentData.platform.toLowerCase() == 'macos';
417
428
  }
418
429
  // Fall back to the old API, with less strict matching.
430
+ if (!navigator.platform) {
431
+ return false;
432
+ }
419
433
  return navigator.platform.toLowerCase().includes('mac');
420
434
  }
421
435
 
@@ -430,6 +444,9 @@ shaka.util.Platform = class {
430
444
  return navigator.userAgentData.platform.toLowerCase() == 'windows';
431
445
  }
432
446
  // Fall back to the old API, with less strict matching.
447
+ if (!navigator.platform) {
448
+ return false;
449
+ }
433
450
  return navigator.platform.toLowerCase().includes('windows');
434
451
  }
435
452
 
@@ -556,6 +573,10 @@ shaka.util.Platform = class {
556
573
  Platform.isWebOS4() || Platform.isWebOS5()) {
557
574
  return false;
558
575
  }
576
+ // Older chromecasts without GoogleTV seem to not support SMOOTH properly.
577
+ if (Platform.isChromecast() && !Platform.isAndroidCastDevice()) {
578
+ return false;
579
+ }
559
580
  // See: https://chromium-review.googlesource.com/c/chromium/src/+/4577759
560
581
  if (Platform.isWindows() && Platform.isEdge()) {
561
582
  return false;
package/lib/util/tXml.js CHANGED
@@ -779,7 +779,7 @@ shaka.util.TXml = class {
779
779
  element.setAttribute(k, v);
780
780
  }
781
781
 
782
- if (doParents && node.parent) {
782
+ if (doParents && node.parent && node.parent.tagName != '?xml') {
783
783
  const parentElement = TXml.txmlNodeToDomElement(
784
784
  node.parent, /* doParents= */ true, /* doChildren= */ false);
785
785
  parentElement.appendChild(element);
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.8.1",
4
+ "version": "4.8.2",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [
@@ -116,6 +116,7 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
116
116
  } else {
117
117
  otherIdx = tracks.findIndex((t) => {
118
118
  return t.height == track.height &&
119
+ t.videoBandwidth == track.videoBandwidth &&
119
120
  t.frameRate == track.frameRate &&
120
121
  t.hdr == track.hdr &&
121
122
  t.videoLayout == track.videoLayout;