shaka-player 4.9.0 → 4.9.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.
Files changed (40) hide show
  1. package/dist/deps.js +1 -1
  2. package/dist/locales.js +33 -33
  3. package/dist/shaka-player.compiled.d.ts +0 -1
  4. package/dist/shaka-player.compiled.debug.d.ts +0 -1
  5. package/dist/shaka-player.compiled.debug.externs.js +0 -1
  6. package/dist/shaka-player.compiled.debug.js +222 -219
  7. package/dist/shaka-player.compiled.debug.map +3 -3
  8. package/dist/shaka-player.compiled.externs.js +0 -1
  9. package/dist/shaka-player.compiled.js +961 -961
  10. package/dist/shaka-player.compiled.map +2 -2
  11. package/dist/shaka-player.ui.d.ts +0 -1
  12. package/dist/shaka-player.ui.debug.d.ts +0 -1
  13. package/dist/shaka-player.ui.debug.externs.js +0 -1
  14. package/dist/shaka-player.ui.debug.js +140 -135
  15. package/dist/shaka-player.ui.debug.map +3 -3
  16. package/dist/shaka-player.ui.externs.js +0 -1
  17. package/dist/shaka-player.ui.js +1229 -1228
  18. package/dist/shaka-player.ui.map +3 -3
  19. package/lib/media/content_workarounds.js +4 -2
  20. package/lib/media/drm_engine.js +1 -1
  21. package/lib/media/media_source_engine.js +66 -31
  22. package/lib/media/preload_manager.js +42 -62
  23. package/lib/player.js +25 -17
  24. package/lib/polyfill/mediasource.js +12 -0
  25. package/lib/transmuxer/aac_transmuxer.js +4 -2
  26. package/lib/transmuxer/ac3_transmuxer.js +2 -1
  27. package/lib/transmuxer/ec3_transmuxer.js +2 -1
  28. package/lib/transmuxer/mp3_transmuxer.js +4 -2
  29. package/lib/transmuxer/mpeg_ts_transmuxer.js +2 -1
  30. package/lib/transmuxer/mss_transmuxer.js +4 -2
  31. package/lib/transmuxer/ts_transmuxer.js +44 -24
  32. package/lib/util/config_utils.js +2 -0
  33. package/lib/util/error.js +10 -8
  34. package/lib/util/object_utils.js +1 -2
  35. package/lib/util/platform.js +11 -2
  36. package/package.json +1 -1
  37. package/ui/audio_language_selection.js +4 -0
  38. package/ui/presentation_time.js +15 -0
  39. package/ui/resolution_selection.js +7 -0
  40. package/ui/text_selection.js +4 -0
@@ -30,10 +30,11 @@ shaka.media.ContentWorkarounds = class {
30
30
  * need this workaround.
31
31
  *
32
32
  * @param {!BufferSource} initSegmentBuffer
33
+ * @param {?string} uri
33
34
  * @return {!Uint8Array}
34
35
  * @see https://github.com/shaka-project/shaka-player/issues/2759
35
36
  */
36
- static fakeEncryption(initSegmentBuffer) {
37
+ static fakeEncryption(initSegmentBuffer, uri) {
37
38
  const ContentWorkarounds = shaka.media.ContentWorkarounds;
38
39
  let initSegment = shaka.util.BufferUtils.toUint8(initSegmentBuffer);
39
40
  let isEncrypted = false;
@@ -154,7 +155,8 @@ shaka.media.ContentWorkarounds = class {
154
155
  throw new shaka.util.Error(
155
156
  shaka.util.Error.Severity.CRITICAL,
156
157
  shaka.util.Error.Category.MEDIA,
157
- shaka.util.Error.Code.CONTENT_TRANSFORMATION_FAILED);
158
+ shaka.util.Error.Code.CONTENT_TRANSFORMATION_FAILED,
159
+ uri);
158
160
  }
159
161
 
160
162
  // Modify boxes in order from largest offset to smallest, so that earlier
@@ -393,7 +393,6 @@ shaka.media.DrmEngine = class {
393
393
  this.config_.keySystemsMapping);
394
394
  }
395
395
 
396
-
397
396
  /** @type {!Map.<string, MediaKeySystemConfiguration>} */
398
397
  let configsByKeySystem;
399
398
 
@@ -402,6 +401,7 @@ shaka.media.DrmEngine = class {
402
401
  await shaka.util.StreamUtils.getDecodingInfosForVariants(variants,
403
402
  this.usePersistentLicenses_, this.srcEquals_,
404
403
  this.config_.preferredKeySystems);
404
+ this.destroyer_.ensureNotDestroyed();
405
405
 
406
406
  const hasDrmInfo = hadDrmInfo || Object.keys(this.config_.servers).length;
407
407
  // An unencrypted content is initialized.
@@ -569,7 +569,8 @@ shaka.media.MediaSourceEngine = class {
569
569
  shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
570
570
  exception,
571
571
  'The mediaSource_ status was ' + this.mediaSource_.readyState +
572
- ' expected \'open\'');
572
+ ' expected \'open\'',
573
+ null);
573
574
  }
574
575
 
575
576
  if (this.sequenceMode_) {
@@ -935,10 +936,12 @@ shaka.media.MediaSourceEngine = class {
935
936
  if (this.attemptTimestampOffsetCalculation_) {
936
937
  this.enqueueOperation_(
937
938
  contentType,
938
- () => this.abort_(contentType));
939
+ () => this.abort_(contentType),
940
+ null);
939
941
  this.enqueueOperation_(
940
942
  contentType,
941
- () => this.setTimestampOffset_(contentType, timestampOffset));
943
+ () => this.setTimestampOffset_(contentType, timestampOffset),
944
+ null);
942
945
  }
943
946
  }
944
947
  // Timestamps can only be reliably extracted from video, not audio.
@@ -983,7 +986,8 @@ shaka.media.MediaSourceEngine = class {
983
986
  }
984
987
 
985
988
  data = this.workAroundBrokenPlatforms_(
986
- data, reference ? reference.startTime : null, contentType);
989
+ data, reference ? reference.startTime : null, contentType,
990
+ reference ? reference.getUris()[0] : null);
987
991
 
988
992
  if (reference && this.sequenceMode_ && contentType != ContentType.TEXT) {
989
993
  // In sequence mode, for non-text streams, if we just cleared the buffer
@@ -995,10 +999,14 @@ shaka.media.MediaSourceEngine = class {
995
999
  // extended during unbuffered seeks or automatic adaptations; it is
996
1000
  // possible for the append state to be PARSING_MEDIA_SEGMENT from the
997
1001
  // previous SourceBuffer#appendBuffer() call.
998
- this.enqueueOperation_(contentType, () => this.abort_(contentType));
999
1002
  this.enqueueOperation_(
1000
1003
  contentType,
1001
- () => this.setTimestampOffset_(contentType, timestampOffset));
1004
+ () => this.abort_(contentType),
1005
+ null);
1006
+ this.enqueueOperation_(
1007
+ contentType,
1008
+ () => this.setTimestampOffset_(contentType, timestampOffset),
1009
+ null);
1002
1010
  }
1003
1011
  }
1004
1012
 
@@ -1009,7 +1017,7 @@ shaka.media.MediaSourceEngine = class {
1009
1017
  bufferedBefore = this.getBuffered_(contentType);
1010
1018
  }
1011
1019
  this.append_(contentType, data, timestampOffset);
1012
- });
1020
+ }, reference ? reference.getUris()[0] : null);
1013
1021
 
1014
1022
  if (goog.DEBUG && reference && !reference.isPreload() && !isChunkedData) {
1015
1023
  const bufferedAfter = this.getBuffered_(contentType);
@@ -1067,11 +1075,13 @@ shaka.media.MediaSourceEngine = class {
1067
1075
  } else {
1068
1076
  await this.enqueueOperation_(
1069
1077
  contentType,
1070
- () => this.remove_(contentType, startTime, endTime));
1078
+ () => this.remove_(contentType, startTime, endTime),
1079
+ null);
1071
1080
  if (this.needSplitMuxedContent_) {
1072
1081
  await this.enqueueOperation_(
1073
1082
  ContentType.AUDIO,
1074
- () => this.remove_(ContentType.AUDIO, startTime, endTime));
1083
+ () => this.remove_(ContentType.AUDIO, startTime, endTime),
1084
+ null);
1075
1085
  }
1076
1086
  }
1077
1087
  }
@@ -1093,12 +1103,14 @@ shaka.media.MediaSourceEngine = class {
1093
1103
  // Note that not all platforms allow clearing to Infinity.
1094
1104
  await this.enqueueOperation_(
1095
1105
  contentType,
1096
- () => this.remove_(contentType, 0, this.mediaSource_.duration));
1106
+ () => this.remove_(contentType, 0, this.mediaSource_.duration),
1107
+ null);
1097
1108
  if (this.needSplitMuxedContent_) {
1098
1109
  await this.enqueueOperation_(
1099
1110
  ContentType.AUDIO,
1100
1111
  () => this.remove_(
1101
- ContentType.AUDIO, 0, this.mediaSource_.duration));
1112
+ ContentType.AUDIO, 0, this.mediaSource_.duration),
1113
+ null);
1102
1114
  }
1103
1115
  }
1104
1116
  }
@@ -1129,11 +1141,13 @@ shaka.media.MediaSourceEngine = class {
1129
1141
  }
1130
1142
  await this.enqueueOperation_(
1131
1143
  contentType,
1132
- () => this.flush_(contentType));
1144
+ () => this.flush_(contentType),
1145
+ null);
1133
1146
  if (this.needSplitMuxedContent_) {
1134
1147
  await this.enqueueOperation_(
1135
1148
  ContentType.AUDIO,
1136
- () => this.flush_(ContentType.AUDIO));
1149
+ () => this.flush_(ContentType.AUDIO),
1150
+ null);
1137
1151
  }
1138
1152
  }
1139
1153
 
@@ -1188,33 +1202,39 @@ shaka.media.MediaSourceEngine = class {
1188
1202
  // set it.
1189
1203
  operations.push(this.enqueueOperation_(
1190
1204
  contentType,
1191
- () => this.abort_(contentType)));
1205
+ () => this.abort_(contentType),
1206
+ null));
1192
1207
  if (this.needSplitMuxedContent_) {
1193
1208
  operations.push(this.enqueueOperation_(
1194
1209
  ContentType.AUDIO,
1195
- () => this.abort_(ContentType.AUDIO)));
1210
+ () => this.abort_(ContentType.AUDIO),
1211
+ null));
1196
1212
  }
1197
1213
  }
1198
1214
  if (!ignoreTimestampOffset) {
1199
1215
  operations.push(this.enqueueOperation_(
1200
1216
  contentType,
1201
- () => this.setTimestampOffset_(contentType, timestampOffset)));
1217
+ () => this.setTimestampOffset_(contentType, timestampOffset),
1218
+ null));
1202
1219
  if (this.needSplitMuxedContent_) {
1203
1220
  operations.push(this.enqueueOperation_(
1204
1221
  ContentType.AUDIO,
1205
1222
  () => this.setTimestampOffset_(
1206
- ContentType.AUDIO, timestampOffset)));
1223
+ ContentType.AUDIO, timestampOffset),
1224
+ null));
1207
1225
  }
1208
1226
  }
1209
1227
  operations.push(this.enqueueOperation_(
1210
1228
  contentType,
1211
1229
  () => this.setAppendWindow_(
1212
- contentType, appendWindowStart, appendWindowEnd)));
1230
+ contentType, appendWindowStart, appendWindowEnd),
1231
+ null));
1213
1232
  if (this.needSplitMuxedContent_) {
1214
1233
  operations.push(this.enqueueOperation_(
1215
1234
  ContentType.AUDIO,
1216
1235
  () => this.setAppendWindow_(
1217
- ContentType.AUDIO, appendWindowStart, appendWindowEnd)));
1236
+ ContentType.AUDIO, appendWindowStart, appendWindowEnd),
1237
+ null));
1218
1238
  }
1219
1239
 
1220
1240
  await Promise.all(operations);
@@ -1251,19 +1271,23 @@ shaka.media.MediaSourceEngine = class {
1251
1271
  // set it.
1252
1272
  this.enqueueOperation_(
1253
1273
  contentType,
1254
- () => this.abort_(contentType));
1274
+ () => this.abort_(contentType),
1275
+ null);
1255
1276
  if (this.needSplitMuxedContent_) {
1256
1277
  this.enqueueOperation_(
1257
1278
  ContentType.AUDIO,
1258
- () => this.abort_(ContentType.AUDIO));
1279
+ () => this.abort_(ContentType.AUDIO),
1280
+ null);
1259
1281
  }
1260
1282
  await this.enqueueOperation_(
1261
1283
  contentType,
1262
- () => this.setTimestampOffset_(contentType, timestampOffset));
1284
+ () => this.setTimestampOffset_(contentType, timestampOffset),
1285
+ null);
1263
1286
  if (this.needSplitMuxedContent_) {
1264
1287
  await this.enqueueOperation_(
1265
1288
  ContentType.AUDIO,
1266
- () => this.setTimestampOffset_(ContentType.AUDIO, timestampOffset));
1289
+ () => this.setTimestampOffset_(ContentType.AUDIO, timestampOffset),
1290
+ null);
1267
1291
  }
1268
1292
  }
1269
1293
 
@@ -1306,6 +1330,7 @@ shaka.media.MediaSourceEngine = class {
1306
1330
  const dummyOperation = {
1307
1331
  start: () => {},
1308
1332
  p: new shaka.util.PublicPromise(),
1333
+ uri: null,
1309
1334
  };
1310
1335
  this.queues_[contentType].unshift(dummyOperation);
1311
1336
  }
@@ -1465,7 +1490,7 @@ shaka.media.MediaSourceEngine = class {
1465
1490
  shaka.util.Error.Severity.CRITICAL,
1466
1491
  shaka.util.Error.Category.MEDIA,
1467
1492
  shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_FAILED,
1468
- code));
1493
+ code, operation.uri));
1469
1494
  // Do not pop from queue. An 'updateend' event will fire next, and to
1470
1495
  // avoid synchronizing these two event handlers, we will allow that one to
1471
1496
  // pop from the queue as normal. Note that because the operation has
@@ -1497,14 +1522,16 @@ shaka.media.MediaSourceEngine = class {
1497
1522
  *
1498
1523
  * @param {shaka.util.ManifestParserUtils.ContentType} contentType
1499
1524
  * @param {function()} start
1525
+ * @param {?string} uri
1500
1526
  * @return {!Promise}
1501
1527
  * @private
1502
1528
  */
1503
- enqueueOperation_(contentType, start) {
1529
+ enqueueOperation_(contentType, start, uri) {
1504
1530
  this.destroyer_.ensureNotDestroyed();
1505
1531
  const operation = {
1506
1532
  start: start,
1507
1533
  p: new shaka.util.PublicPromise(),
1534
+ uri,
1508
1535
  };
1509
1536
  this.queues_[contentType].push(operation);
1510
1537
 
@@ -1536,6 +1563,7 @@ shaka.media.MediaSourceEngine = class {
1536
1563
  const operation = {
1537
1564
  start: () => ready.resolve(),
1538
1565
  p: ready,
1566
+ uri: null,
1539
1567
  };
1540
1568
 
1541
1569
  this.queues_[contentType].push(operation);
@@ -1593,7 +1621,8 @@ shaka.media.MediaSourceEngine = class {
1593
1621
  shaka.util.Error.Category.MEDIA,
1594
1622
  shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
1595
1623
  exception,
1596
- this.video_.error || 'No error in the media element');
1624
+ this.video_.error || 'No error in the media element',
1625
+ null);
1597
1626
  } finally {
1598
1627
  // Unblock the queues.
1599
1628
  for (const contentType in this.sourceBuffers_) {
@@ -1637,7 +1666,8 @@ shaka.media.MediaSourceEngine = class {
1637
1666
  shaka.util.Error.Category.MEDIA,
1638
1667
  shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
1639
1668
  exception,
1640
- this.video_.error || 'No error in the media element'));
1669
+ this.video_.error || 'No error in the media element',
1670
+ next.uri));
1641
1671
  }
1642
1672
  this.popFromQueue_(contentType);
1643
1673
  }
@@ -1684,10 +1714,11 @@ shaka.media.MediaSourceEngine = class {
1684
1714
  * @param {!BufferSource} segment
1685
1715
  * @param {?number} startTime
1686
1716
  * @param {shaka.util.ManifestParserUtils.ContentType} contentType
1717
+ * @param {?string} uri
1687
1718
  * @return {!BufferSource}
1688
1719
  * @private
1689
1720
  */
1690
- workAroundBrokenPlatforms_(segment, startTime, contentType) {
1721
+ workAroundBrokenPlatforms_(segment, startTime, contentType, uri) {
1691
1722
  const isInitSegment = startTime == null;
1692
1723
  const encryptionExpected = this.expectedEncryption_[contentType];
1693
1724
 
@@ -1708,7 +1739,7 @@ shaka.media.MediaSourceEngine = class {
1708
1739
  shaka.util.MimeUtils.getContainerType(
1709
1740
  this.sourceBufferTypes_[contentType]) == 'mp4') {
1710
1741
  shaka.log.debug('Forcing fake encryption information in init segment.');
1711
- segment = shaka.media.ContentWorkarounds.fakeEncryption(segment);
1742
+ segment = shaka.media.ContentWorkarounds.fakeEncryption(segment, uri);
1712
1743
  }
1713
1744
 
1714
1745
  return segment;
@@ -1761,7 +1792,8 @@ shaka.media.MediaSourceEngine = class {
1761
1792
  changeType(contentType, mimeType, transmuxer) {
1762
1793
  return this.enqueueOperation_(
1763
1794
  contentType,
1764
- () => this.change_(contentType, mimeType, transmuxer));
1795
+ () => this.change_(contentType, mimeType, transmuxer),
1796
+ null);
1765
1797
  }
1766
1798
 
1767
1799
  /**
@@ -2096,7 +2128,8 @@ shaka.media.MediaSourceEngine.createObjectURL = window.URL.createObjectURL;
2096
2128
  /**
2097
2129
  * @typedef {{
2098
2130
  * start: function(),
2099
- * p: !shaka.util.PublicPromise
2131
+ * p: !shaka.util.PublicPromise,
2132
+ * uri: ?string
2100
2133
  * }}
2101
2134
  *
2102
2135
  * @summary An operation in queue.
@@ -2104,6 +2137,8 @@ shaka.media.MediaSourceEngine.createObjectURL = window.URL.createObjectURL;
2104
2137
  * The function which starts the operation.
2105
2138
  * @property {!shaka.util.PublicPromise} p
2106
2139
  * The PublicPromise which is associated with this operation.
2140
+ * @property {?string} uri
2141
+ * A segment URI (if any) associated with this operation.
2107
2142
  */
2108
2143
  shaka.media.MediaSourceEngine.Operation;
2109
2144
 
@@ -132,19 +132,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
132
132
  this.stats_ = new shaka.util.Stats();
133
133
 
134
134
  /** @private {!shaka.util.PublicPromise} */
135
- this.manifestPromise_ = new shaka.util.PublicPromise();
136
-
137
- /** @private {!shaka.util.PublicPromise} */
138
- this.drmPromise_ = new shaka.util.PublicPromise();
139
-
140
- /** @private {!shaka.util.PublicPromise} */
141
- this.chooseInitialVariantPromise_ = new shaka.util.PublicPromise();
142
-
143
- /** @private {!shaka.util.PublicPromise} */
144
- this.destroyPromise_ = new shaka.util.PublicPromise();
145
-
146
- // Silence promise failures, in case nobody is catching this.destroyPromise_
147
- this.destroyPromise_.catch((error) => {});
135
+ this.successPromise_ = new shaka.util.PublicPromise();
148
136
 
149
137
  /** @private {?shaka.util.FakeEventTarget} */
150
138
  this.eventHandoffTarget_ = null;
@@ -353,21 +341,6 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
353
341
  return this.segmentPrefetchById_;
354
342
  }
355
343
 
356
- /** @return {!Promise} */
357
- waitForManifest() {
358
- return this.manifestPromise_;
359
- }
360
-
361
- /** @return {!Promise} */
362
- waitForDrm() {
363
- return this.drmPromise_;
364
- }
365
-
366
- /** @return {!Promise} */
367
- waitForChooseInitialVariant() {
368
- return this.chooseInitialVariantPromise_;
369
- }
370
-
371
344
  /**
372
345
  * @param {?shaka.extern.AbrManager} abrManager
373
346
  * @param {?shaka.extern.AbrManager.Factory} abrFactory
@@ -397,34 +370,30 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
397
370
 
398
371
  /**
399
372
  * Starts the process of loading the asset.
400
- * @return {!Promise}
373
+ * Success or failure will be measured through waitForFinish()
401
374
  */
402
- async start() {
403
- // Force a context switch, to give the player a chance to hook up events
404
- // immediately if desired.
405
- await Promise.resolve();
406
-
407
- // Perform the preloading process.
408
- try {
409
- await this.parseManifestInner_();
410
- if (this.isDestroyed()) {
411
- return;
412
- }
413
- this.manifestPromise_.resolve();
414
- await this.initializeDrmInner_();
415
- if (this.isDestroyed()) {
416
- return;
417
- }
418
- this.drmPromise_.resolve();
419
- await this.chooseInitialVariantInner_();
420
- if (this.isDestroyed()) {
421
- return;
375
+ start() {
376
+ (async () => {
377
+ // Force a context switch, to give the player a chance to hook up events
378
+ // immediately if desired.
379
+ await Promise.resolve();
380
+
381
+ // Perform the preloading process.
382
+ try {
383
+ await this.parseManifestInner_();
384
+ this.throwIfDestroyed_();
385
+
386
+ await this.initializeDrmInner_();
387
+ this.throwIfDestroyed_();
388
+
389
+ await this.chooseInitialVariantInner_();
390
+ this.throwIfDestroyed_();
391
+
392
+ this.successPromise_.resolve();
393
+ } catch (error) {
394
+ this.successPromise_.reject(error);
422
395
  }
423
- this.chooseInitialVariantPromise_.resolve();
424
- } catch (error) {
425
- this.destroyPromise_.reject(error);
426
- throw error;
427
- }
396
+ })();
428
397
  }
429
398
 
430
399
  /**
@@ -446,7 +415,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
446
415
  onError(error) {
447
416
  if (error.severity === shaka.util.Error.Severity.CRITICAL) {
448
417
  // Cancel the loading process.
449
- this.destroyPromise_.reject(error);
418
+ this.successPromise_.reject(error);
450
419
  this.destroy();
451
420
  }
452
421
 
@@ -458,6 +427,20 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
458
427
  }
459
428
  }
460
429
 
430
+ /**
431
+ * Throw if destroyed, to interrupt processes with a recognizable error.
432
+ *
433
+ * @private
434
+ */
435
+ throwIfDestroyed_() {
436
+ if (this.isDestroyed()) {
437
+ throw new shaka.util.Error(
438
+ shaka.util.Error.Severity.CRITICAL,
439
+ shaka.util.Error.Category.PLAYER,
440
+ shaka.util.Error.Code.OBJECT_DESTROYED);
441
+ }
442
+ }
443
+
461
444
  /**
462
445
  * Makes a fires an event corresponding to entering a state of the loading
463
446
  * process.
@@ -553,12 +536,11 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
553
536
 
554
537
  const tracksChangedInitial = this.manifestFilterer_.applyRestrictions(
555
538
  this.manifest_);
556
- const tracksChangedBefore = await this.manifestFilterer_.filterManifest(
557
- this.manifest_);
558
- if (tracksChangedInitial || tracksChangedBefore) {
539
+ if (tracksChangedInitial) {
559
540
  const event = this.makeEvent_(
560
541
  shaka.util.FakeEvent.EventName.TracksChanged);
561
542
  await Promise.resolve();
543
+ this.throwIfDestroyed_();
562
544
  this.dispatchEvent(event);
563
545
  }
564
546
 
@@ -567,6 +549,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
567
549
  await this.drmEngine_.initForPlayback(
568
550
  playableVariants,
569
551
  this.manifest_.offlineSessionIds);
552
+ this.throwIfDestroyed_();
570
553
 
571
554
  // Now that we have drm information, filter the manifest (again) so that
572
555
  // we can ensure we only use variants with the selected key system.
@@ -717,10 +700,7 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
717
700
  * @export
718
701
  */
719
702
  waitForFinish() {
720
- return Promise.race([
721
- this.chooseInitialVariantPromise_,
722
- this.destroyPromise_,
723
- ]);
703
+ return this.successPromise_;
724
704
  }
725
705
 
726
706
  /**
package/lib/player.js CHANGED
@@ -1607,7 +1607,12 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
1607
1607
  if (preloadManager) {
1608
1608
  preloadManager.setEventHandoffTarget(this);
1609
1609
  this.stats_ = preloadManager.getStats();
1610
- await mutexWrapOperation(() => preloadManager.start(), 'preload');
1610
+ preloadManager.start();
1611
+ // Silence "uncaught error" warnings from this. Unless we are
1612
+ // interrupted, we will check the result of this process and respond
1613
+ // appropriately. If we are interrupted, we can ignore any error
1614
+ // there.
1615
+ preloadManager.waitForFinish().catch(() => {});
1611
1616
  } else {
1612
1617
  this.stats_ = new shaka.util.Stats();
1613
1618
  }
@@ -1648,9 +1653,12 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
1648
1653
  }, 'initializeMediaSourceEngineInner_');
1649
1654
  }
1650
1655
 
1656
+ // Wait for the preload manager to do all of the loading it can do.
1657
+ await mutexWrapOperation(async () => {
1658
+ await preloadManager.waitForFinish();
1659
+ }, 'waitForFinish');
1660
+
1651
1661
  // Get manifest and associated values from preloader.
1652
- await mutexWrapOperation(
1653
- () => preloadManager.waitForManifest(), 'waitForManifest');
1654
1662
  this.config_ = preloadManager.getConfiguration();
1655
1663
  this.manifestFilterer_ = preloadManager.getManifestFilterer();
1656
1664
  this.parserFactory_ = preloadManager.getParserFactory();
@@ -1674,18 +1682,11 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
1674
1682
  }
1675
1683
 
1676
1684
  // Get drm engine from preloader, then finalize it.
1677
- await mutexWrapOperation(
1678
- () => preloadManager.waitForDrm(), 'waitForDrm');
1679
1685
  this.drmEngine_ = preloadManager.receiveDrmEngine();
1680
1686
  await mutexWrapOperation(async () => {
1681
1687
  await this.drmEngine_.attach(this.video_);
1682
1688
  }, 'drmEngine_.attach');
1683
1689
 
1684
- // Choose an initial variant.
1685
- await mutexWrapOperation(
1686
- () => preloadManager.waitForChooseInitialVariant(),
1687
- 'waitForChooseInitialVariant');
1688
-
1689
1690
  // Also get the ABR manager, which has special logic related to being
1690
1691
  // received.
1691
1692
  const abrManagerFactory = preloadManager.getAbrManagerFactory();
@@ -1873,7 +1874,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
1873
1874
  shaka.util.Error.Category.PLAYER,
1874
1875
  shaka.util.Error.Code.SRC_EQUALS_PRELOAD_NOT_SUPPORTED));
1875
1876
  } else {
1876
- preloadManager.start().catch((error) => {}); // Catch errors.
1877
+ preloadManager.start();
1877
1878
  }
1878
1879
  return preloadManager;
1879
1880
  }
@@ -2405,7 +2406,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
2405
2406
  const setupPlayhead = (startTime) => {
2406
2407
  this.playhead_ = this.createPlayhead(startTime);
2407
2408
  this.playheadObservers_ =
2408
- this.createPlayheadObserversForMSE_(startTimeOfLoad);
2409
+ this.createPlayheadObserversForMSE_(startTime);
2409
2410
 
2410
2411
  // We need to start the buffer management code near the end because it
2411
2412
  // will set the initial buffering state and that depends on other
@@ -3242,16 +3243,16 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
3242
3243
  * Create the observers for MSE playback. These observers are responsible for
3243
3244
  * notifying the app and player of specific events during MSE playback.
3244
3245
  *
3245
- * @param {number} startTimeOfLoad
3246
+ * @param {number} startTime
3246
3247
  * @return {!shaka.media.PlayheadObserverManager}
3247
3248
  * @private
3248
3249
  */
3249
- createPlayheadObserversForMSE_(startTimeOfLoad) {
3250
+ createPlayheadObserversForMSE_(startTime) {
3250
3251
  goog.asserts.assert(this.manifest_, 'Must have manifest');
3251
3252
  goog.asserts.assert(this.regionTimeline_, 'Must have region timeline');
3252
3253
  goog.asserts.assert(this.video_, 'Must have video element');
3253
3254
 
3254
- const startsPastZero = this.isLive() || startTimeOfLoad > 0;
3255
+ const startsPastZero = this.isLive() || startTime > 0;
3255
3256
 
3256
3257
  // Create the region observer. This will allow us to notify the app when we
3257
3258
  // move in and out of timeline regions.
@@ -7103,7 +7104,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
7103
7104
  shaka.util.FakeEvent.EventName.KeyStatusChanged);
7104
7105
  this.dispatchEvent(event);
7105
7106
 
7106
- const keyIds = Object.keys(keyStatusMap);
7107
+ let keyIds = Object.keys(keyStatusMap);
7107
7108
  if (keyIds.length == 0) {
7108
7109
  shaka.log.warning(
7109
7110
  'Got a key status event without any key statuses, so we don\'t ' +
@@ -7111,6 +7112,13 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
7111
7112
  'you\'ll need to set restrictions so we don\'t select those tracks.');
7112
7113
  }
7113
7114
 
7115
+ // Non-standard version of global key status. Modify it to match standard
7116
+ // behavior.
7117
+ if (keyIds.length == 1 && keyIds[0] == '') {
7118
+ keyIds = ['00'];
7119
+ keyStatusMap = {'00': keyStatusMap['']};
7120
+ }
7121
+
7114
7122
  // If EME is using a synthetic key ID, the only key ID is '00' (a single 0
7115
7123
  // byte). In this case, it is only used to report global success/failure.
7116
7124
  // See note about old platforms in: https://bit.ly/2tpez5Z
@@ -7446,7 +7454,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
7446
7454
  * @export
7447
7455
  */
7448
7456
  // eslint-disable-next-line no-useless-concat
7449
- shaka.Player.version = 'v4.9.0' + '-uncompiled'; // x-release-please-version
7457
+ shaka.Player.version = 'v4.9.2' + '-uncompiled'; // x-release-please-version
7450
7458
 
7451
7459
  // Initialize the deprecation system using the version string we just set
7452
7460
  // on the player.
@@ -67,6 +67,18 @@ shaka.polyfill.MediaSource = class {
67
67
  // Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342
68
68
  shaka.polyfill.MediaSource.stubAbort_();
69
69
  }
70
+ } else if (shaka.util.Platform.isZenterio()) {
71
+ // Zenterio uses WPE based on Webkit 607.x.x which do not correctly
72
+ // implement abort() on SourceBuffer.
73
+ // Calling abort() before appending a segment causes that segment to be
74
+ // incomplete in the buffer.
75
+ // Bug filed: https://bugs.webkit.org/show_bug.cgi?id=165342
76
+ shaka.polyfill.MediaSource.stubAbort_();
77
+ // If you remove up to a keyframe, Webkit 607.x.x incorrectly will also
78
+ // remove that keyframe and the content up to the next.
79
+ // Offsetting the end of the removal range seems to help.
80
+ // Bug filed: https://bugs.webkit.org/show_bug.cgi?id=177884
81
+ shaka.polyfill.MediaSource.patchRemovalRange_();
70
82
  } else if (shaka.util.Platform.isTizen2() ||
71
83
  shaka.util.Platform.isTizen3() ||
72
84
  shaka.util.Platform.isTizen4()) {
@@ -141,7 +141,8 @@ shaka.transmuxer.AacTransmuxer = class {
141
141
  return Promise.reject(new shaka.util.Error(
142
142
  shaka.util.Error.Severity.CRITICAL,
143
143
  shaka.util.Error.Category.MEDIA,
144
- shaka.util.Error.Code.TRANSMUXING_FAILED));
144
+ shaka.util.Error.Code.TRANSMUXING_FAILED,
145
+ reference ? reference.getUris()[0] : null));
145
146
  }
146
147
  stream.audioSamplingRate = info.sampleRate;
147
148
  stream.channelsCount = info.channelCount;
@@ -155,7 +156,8 @@ shaka.transmuxer.AacTransmuxer = class {
155
156
  return Promise.reject(new shaka.util.Error(
156
157
  shaka.util.Error.Severity.CRITICAL,
157
158
  shaka.util.Error.Category.MEDIA,
158
- shaka.util.Error.Code.TRANSMUXING_FAILED));
159
+ shaka.util.Error.Code.TRANSMUXING_FAILED,
160
+ reference ? reference.getUris()[0] : null));
159
161
  }
160
162
  const length = header.headerLength + header.frameLength;
161
163
  if (offset + length <= uint8ArrayData.length) {
@@ -144,7 +144,8 @@ shaka.transmuxer.Ac3Transmuxer = class {
144
144
  return Promise.reject(new shaka.util.Error(
145
145
  shaka.util.Error.Severity.CRITICAL,
146
146
  shaka.util.Error.Category.MEDIA,
147
- shaka.util.Error.Code.TRANSMUXING_FAILED));
147
+ shaka.util.Error.Code.TRANSMUXING_FAILED,
148
+ reference ? reference.getUris()[0] : null));
148
149
  }
149
150
  stream.audioSamplingRate = frame.sampleRate;
150
151
  stream.channelsCount = frame.channelCount;
@@ -144,7 +144,8 @@ shaka.transmuxer.Ec3Transmuxer = class {
144
144
  return Promise.reject(new shaka.util.Error(
145
145
  shaka.util.Error.Severity.CRITICAL,
146
146
  shaka.util.Error.Category.MEDIA,
147
- shaka.util.Error.Code.TRANSMUXING_FAILED));
147
+ shaka.util.Error.Code.TRANSMUXING_FAILED,
148
+ reference ? reference.getUris()[0] : null));
148
149
  }
149
150
  stream.audioSamplingRate = frame.sampleRate;
150
151
  stream.channelsCount = frame.channelCount;