rx-player 3.33.1 → 3.33.3

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 (92) hide show
  1. package/CHANGELOG.md +1080 -1129
  2. package/VERSION +1 -1
  3. package/dist/_esm5.processed/compat/can_rely_on_request_media_key_system_access.d.ts +34 -0
  4. package/dist/_esm5.processed/compat/can_rely_on_request_media_key_system_access.js +40 -0
  5. package/dist/_esm5.processed/compat/generate_init_data.d.ts +14 -0
  6. package/dist/_esm5.processed/compat/generate_init_data.js +61 -0
  7. package/dist/_esm5.processed/compat/may_media_element_fail_on_undecipherable_data.d.ts +16 -0
  8. package/dist/_esm5.processed/compat/may_media_element_fail_on_undecipherable_data.js +17 -0
  9. package/dist/_esm5.processed/compat/should_wait_for_data_before_loaded.d.ts +1 -1
  10. package/dist/_esm5.processed/compat/should_wait_for_data_before_loaded.js +5 -3
  11. package/dist/_esm5.processed/config.d.ts +2 -0
  12. package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +1 -1
  13. package/dist/_esm5.processed/core/api/debug/buffer_graph.js +3 -3
  14. package/dist/_esm5.processed/core/api/public_api.d.ts +17 -0
  15. package/dist/_esm5.processed/core/api/public_api.js +41 -2
  16. package/dist/_esm5.processed/core/api/tracks_management/media_element_track_choice_manager.js +21 -25
  17. package/dist/_esm5.processed/core/decrypt/attach_media_keys.js +6 -6
  18. package/dist/_esm5.processed/core/decrypt/find_key_system.d.ts +10 -0
  19. package/dist/_esm5.processed/core/decrypt/find_key_system.js +42 -1
  20. package/dist/_esm5.processed/core/decrypt/session_events_listener.js +2 -2
  21. package/dist/_esm5.processed/core/fetchers/manifest/manifest_fetcher.js +2 -2
  22. package/dist/_esm5.processed/core/fetchers/segment/segment_fetcher.js +1 -1
  23. package/dist/_esm5.processed/core/init/media_source_content_initializer.js +34 -12
  24. package/dist/_esm5.processed/core/init/utils/get_loaded_reference.js +6 -1
  25. package/dist/_esm5.processed/core/init/utils/initial_seek_and_play.js +4 -1
  26. package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +24 -25
  27. package/dist/_esm5.processed/core/segment_buffers/implementations/image/image_segment_buffer.js +1 -1
  28. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +1 -1
  29. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/text_track_cues_store.js +2 -2
  30. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/utils.d.ts +15 -0
  31. package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/utils.js +23 -0
  32. package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +1 -1
  33. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.d.ts +18 -4
  34. package/dist/_esm5.processed/core/segment_buffers/inventory/segment_inventory.js +57 -13
  35. package/dist/_esm5.processed/core/stream/adaptation/adaptation_stream.js +3 -0
  36. package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +15 -8
  37. package/dist/_esm5.processed/core/stream/representation/utils/get_buffer_status.js +1 -37
  38. package/dist/_esm5.processed/core/stream/representation/utils/get_needed_segments.js +19 -11
  39. package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +6 -6
  40. package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +9 -9
  41. package/dist/_esm5.processed/default_config.d.ts +31 -0
  42. package/dist/_esm5.processed/default_config.js +48 -17
  43. package/dist/_esm5.processed/errors/assertion_error.d.ts +0 -1
  44. package/dist/_esm5.processed/errors/assertion_error.js +1 -2
  45. package/dist/_esm5.processed/errors/custom_loader_error.d.ts +0 -1
  46. package/dist/_esm5.processed/errors/custom_loader_error.js +1 -2
  47. package/dist/_esm5.processed/errors/encrypted_media_error.d.ts +0 -1
  48. package/dist/_esm5.processed/errors/encrypted_media_error.js +1 -2
  49. package/dist/_esm5.processed/errors/media_error.d.ts +0 -1
  50. package/dist/_esm5.processed/errors/media_error.js +1 -2
  51. package/dist/_esm5.processed/errors/network_error.d.ts +0 -1
  52. package/dist/_esm5.processed/errors/network_error.js +1 -2
  53. package/dist/_esm5.processed/errors/other_error.d.ts +0 -1
  54. package/dist/_esm5.processed/errors/other_error.js +1 -2
  55. package/dist/_esm5.processed/errors/request_error.d.ts +0 -1
  56. package/dist/_esm5.processed/errors/request_error.js +17 -15
  57. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader_error.d.ts +0 -1
  58. package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader_error.js +2 -2
  59. package/dist/_esm5.processed/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +1 -1
  60. package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.js +4 -4
  61. package/dist/_esm5.processed/parsers/containers/isobmff/utils.js +3 -1
  62. package/dist/_esm5.processed/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +1 -3
  63. package/dist/_esm5.processed/parsers/manifest/dash/common/parse_representation_index.js +9 -5
  64. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +0 -1
  65. package/dist/_esm5.processed/parsers/manifest/dash/js-parser/node_parsers/utils.js +1 -2
  66. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.d.ts +1 -1
  67. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.js +1 -1
  68. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.d.ts +1 -1
  69. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.js +1 -1
  70. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.d.ts +1 -1
  71. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.js +1 -1
  72. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/parsers_stack.d.ts +2 -1
  73. package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/types.d.ts +55 -55
  74. package/dist/_esm5.processed/parsers/manifest/smooth/parse_protection_node.js +1 -1
  75. package/dist/_esm5.processed/transports/dash/extract_complete_chunks.d.ts +1 -1
  76. package/dist/_esm5.processed/transports/dash/extract_complete_chunks.js +6 -2
  77. package/dist/_esm5.processed/transports/dash/low_latency_segment_loader.js +4 -2
  78. package/dist/_esm5.processed/utils/languages/ISO_639-1_to_ISO_639-3.js +182 -182
  79. package/dist/_esm5.processed/utils/languages/ISO_639-2_to_ISO_639-3.js +19 -19
  80. package/dist/_esm5.processed/utils/languages/normalize.js +4 -1
  81. package/dist/_esm5.processed/utils/resolve_url.d.ts +13 -10
  82. package/dist/_esm5.processed/utils/resolve_url.js +220 -69
  83. package/dist/_esm5.processed/utils/string_parsing.d.ts +1 -1
  84. package/dist/_esm5.processed/utils/string_parsing.js +1 -1
  85. package/dist/_esm5.processed/utils/task_canceller.d.ts +0 -1
  86. package/dist/_esm5.processed/utils/task_canceller.js +3 -2
  87. package/dist/mpd-parser.wasm +0 -0
  88. package/dist/rx-player.d.ts +1 -1
  89. package/dist/rx-player.js +3951 -3398
  90. package/dist/rx-player.min.d.ts +1 -1
  91. package/dist/rx-player.min.js +1 -1
  92. package/package.json +40 -40
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import config from "../../../../config";
17
16
  import isNullOrUndefined from "../../../../utils/is_null_or_undefined";
18
17
  import SegmentBuffersStore, { SegmentBufferOperation, } from "../../../segment_buffers";
19
18
  import checkForDiscontinuity from "./check_for_discontinuity";
@@ -53,8 +52,7 @@ export default function getBufferStatus(content, initialWantedTime, playbackObse
53
52
  return operation.type === SegmentBufferOperation.EndOfSegment;
54
53
  }).map(function (operation) { return operation.value; });
55
54
  /** Data on every segments buffered around `neededRange`. */
56
- var bufferedSegments = getPlayableBufferedSegments({ start: Math.max(neededRange.start - 0.5, 0),
57
- end: neededRange.end + 0.5 }, segmentBuffer.getInventory());
55
+ var bufferedSegments = segmentBuffer.getInventory();
58
56
  var currentPlaybackTime = playbackObserver.getCurrentTime();
59
57
  /** Callback allowing to retrieve a segment's history in the buffer. */
60
58
  var getBufferedHistory = segmentBuffer.getSegmentHistory.bind(segmentBuffer);
@@ -168,37 +166,3 @@ function isPeriodTheCurrentAndLastOne(manifest, period, time) {
168
166
  manifest.isLastPeriodKnown &&
169
167
  period.id === ((_a = manifest.periods[manifest.periods.length - 1]) === null || _a === void 0 ? void 0 : _a.id);
170
168
  }
171
- /**
172
- * From the given SegmentInventory, filters the "playable" (in a supported codec
173
- * and not known to be undecipherable) buffered Segment Objects which overlap
174
- * with the given range.
175
- * @param {Object} neededRange
176
- * @param {Array.<Object>} segmentInventory
177
- * @returns {Array.<Object>}
178
- */
179
- function getPlayableBufferedSegments(neededRange, segmentInventory) {
180
- var MINIMUM_SEGMENT_SIZE = config.getCurrent().MINIMUM_SEGMENT_SIZE;
181
- var segmentRoundingError = Math.max(1 / 60, MINIMUM_SEGMENT_SIZE);
182
- var minEnd = neededRange.start + segmentRoundingError;
183
- var maxStart = neededRange.end - segmentRoundingError;
184
- var overlappingChunks = [];
185
- for (var i = segmentInventory.length - 1; i >= 0; i--) {
186
- var eltInventory = segmentInventory[i];
187
- var representation = eltInventory.infos.representation;
188
- if (eltInventory.status === 1 /* ChunkStatus.Complete */ &&
189
- representation.decipherable !== false &&
190
- representation.isSupported) {
191
- var inventorySegment = eltInventory.infos.segment;
192
- var eltInventoryStart = inventorySegment.time /
193
- inventorySegment.timescale;
194
- var eltInventoryEnd = !inventorySegment.complete ?
195
- eltInventory.end :
196
- eltInventoryStart + inventorySegment.duration / inventorySegment.timescale;
197
- if ((eltInventoryEnd > minEnd && eltInventoryStart < maxStart) ||
198
- (eltInventory.end > minEnd && eltInventory.start < maxStart)) {
199
- overlappingChunks.unshift(eltInventory);
200
- }
201
- }
202
- }
203
- return overlappingChunks;
204
- }
@@ -102,7 +102,12 @@ export default function getNeededSegments(_a) {
102
102
  if ((oldSegment.time - ROUNDING_ERROR) > time) {
103
103
  return false;
104
104
  }
105
- if ((oldSegment.end + ROUNDING_ERROR) < end) {
105
+ if (oldSegment.complete) {
106
+ if (oldSegment.end + ROUNDING_ERROR < end) {
107
+ return false;
108
+ }
109
+ }
110
+ else if (Math.abs(time - oldSegment.time) > time) {
106
111
  return false;
107
112
  }
108
113
  return !shouldContentBeReplaced(pendingSegment, contentObject, currentPlaybackTime, fastSwitchThreshold);
@@ -119,11 +124,18 @@ export default function getNeededSegments(_a) {
119
124
  // periods, we should consider a segment as already downloaded if
120
125
  // it is from same period (but can be from different adaptation or
121
126
  // representation)
122
- if (areFromSamePeriod) {
127
+ if (completeSeg.status === 1 /* ChunkStatus.FullyLoaded */ && areFromSamePeriod) {
123
128
  var completeSegInfos = completeSeg.infos.segment;
124
- if (time - completeSegInfos.time > -ROUNDING_ERROR &&
125
- completeSegInfos.end - end > -ROUNDING_ERROR) {
126
- return false; // already downloaded
129
+ if (time - completeSegInfos.time > -ROUNDING_ERROR) {
130
+ if (completeSegInfos.complete) {
131
+ if (completeSegInfos.end - end > -ROUNDING_ERROR) {
132
+ return false; // Same segment's characteristics: already downloaded
133
+ }
134
+ }
135
+ else if (Math.abs(time - completeSegInfos.time) < ROUNDING_ERROR) {
136
+ // same start (special case for non-complete segments): already downloaded
137
+ return false;
138
+ }
127
139
  }
128
140
  }
129
141
  }
@@ -280,9 +292,7 @@ function canFastSwitch(oldSegmentRepresentation, newSegmentRepresentation, fastS
280
292
  function doesStartSeemGarbageCollected(currentSeg, prevSeg, maximumStartTime) {
281
293
  var MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT = config.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;
282
294
  if (currentSeg.bufferedStart === undefined) {
283
- log.warn("Stream: Start of a segment unknown. " +
284
- "Assuming it is garbage collected by default.", currentSeg.start);
285
- return true;
295
+ return false;
286
296
  }
287
297
  if (prevSeg !== null && prevSeg.bufferedEnd !== undefined &&
288
298
  (currentSeg.bufferedStart - prevSeg.bufferedEnd < 0.1)) {
@@ -311,9 +321,7 @@ function doesStartSeemGarbageCollected(currentSeg, prevSeg, maximumStartTime) {
311
321
  function doesEndSeemGarbageCollected(currentSeg, nextSeg, minimumEndTime) {
312
322
  var MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT = config.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;
313
323
  if (currentSeg.bufferedEnd === undefined) {
314
- log.warn("Stream: End of a segment unknown. " +
315
- "Assuming it is garbage collected by default.", currentSeg.end);
316
- return true;
324
+ return false;
317
325
  }
318
326
  if (nextSeg !== null && nextSeg.bufferedStart !== undefined &&
319
327
  (nextSeg.bufferedStart - currentSeg.bufferedEnd < 0.1)) {
@@ -57,12 +57,12 @@ import appendSegmentToBuffer from "./append_segment_to_buffer";
57
57
  * @param {Object} cancelSignal
58
58
  * @returns {Promise}
59
59
  */
60
- export default function pushInitSegment(_a, cancelSignal) {
61
- var playbackObserver = _a.playbackObserver, content = _a.content, initSegmentUniqueId = _a.initSegmentUniqueId, segment = _a.segment, segmentData = _a.segmentData, segmentBuffer = _a.segmentBuffer;
62
- return __awaiter(this, void 0, void 0, function () {
60
+ export default function pushInitSegment(_a, cancelSignal_1) {
61
+ return __awaiter(this, arguments, void 0, function (_b, cancelSignal) {
63
62
  var codec, data, inventoryInfos, buffered;
64
- return __generator(this, function (_b) {
65
- switch (_b.label) {
63
+ var playbackObserver = _b.playbackObserver, content = _b.content, initSegmentUniqueId = _b.initSegmentUniqueId, segment = _b.segment, segmentData = _b.segmentData, segmentBuffer = _b.segmentBuffer;
64
+ return __generator(this, function (_c) {
65
+ switch (_c.label) {
66
66
  case 0:
67
67
  if (cancelSignal.cancellationError !== null) {
68
68
  throw cancelSignal.cancellationError;
@@ -76,7 +76,7 @@ export default function pushInitSegment(_a, cancelSignal) {
76
76
  end: 0 }, content);
77
77
  return [4 /*yield*/, appendSegmentToBuffer(playbackObserver, segmentBuffer, { data: data, inventoryInfos: inventoryInfos }, cancelSignal)];
78
78
  case 1:
79
- _b.sent();
79
+ _c.sent();
80
80
  buffered = segmentBuffer.getBufferedRanges();
81
81
  return [2 /*return*/, { content: content, segment: segment, buffered: buffered, segmentData: segmentData }];
82
82
  }
@@ -58,13 +58,13 @@ import appendSegmentToBuffer from "./append_segment_to_buffer";
58
58
  * @param {Object} cancelSignal
59
59
  * @returns {Promise}
60
60
  */
61
- export default function pushMediaSegment(_a, cancelSignal) {
62
- var _b, _c;
63
- var playbackObserver = _a.playbackObserver, content = _a.content, initSegmentUniqueId = _a.initSegmentUniqueId, parsedSegment = _a.parsedSegment, segment = _a.segment, segmentBuffer = _a.segmentBuffer;
64
- return __awaiter(this, void 0, void 0, function () {
61
+ export default function pushMediaSegment(_a, cancelSignal_1) {
62
+ return __awaiter(this, arguments, void 0, function (_b, cancelSignal) {
65
63
  var chunkData, chunkInfos, chunkOffset, chunkSize, appendWindow, codec, APPEND_WINDOW_SECURITIES, safeAppendWindow, data, estimatedStart, estimatedDuration, estimatedEnd, inventoryInfos, buffered;
66
- return __generator(this, function (_d) {
67
- switch (_d.label) {
64
+ var _c, _d;
65
+ var playbackObserver = _b.playbackObserver, content = _b.content, initSegmentUniqueId = _b.initSegmentUniqueId, parsedSegment = _b.parsedSegment, segment = _b.segment, segmentBuffer = _b.segmentBuffer;
66
+ return __generator(this, function (_e) {
67
+ switch (_e.label) {
68
68
  case 0:
69
69
  if (parsedSegment.chunkData === null) {
70
70
  return [2 /*return*/, null];
@@ -86,8 +86,8 @@ export default function pushMediaSegment(_a, cancelSignal) {
86
86
  data = { initSegmentUniqueId: initSegmentUniqueId, chunk: chunkData,
87
87
  timestampOffset: chunkOffset,
88
88
  appendWindow: safeAppendWindow, codec: codec };
89
- estimatedStart = (_b = chunkInfos === null || chunkInfos === void 0 ? void 0 : chunkInfos.time) !== null && _b !== void 0 ? _b : segment.time;
90
- estimatedDuration = (_c = chunkInfos === null || chunkInfos === void 0 ? void 0 : chunkInfos.duration) !== null && _c !== void 0 ? _c : segment.duration;
89
+ estimatedStart = (_c = chunkInfos === null || chunkInfos === void 0 ? void 0 : chunkInfos.time) !== null && _c !== void 0 ? _c : segment.time;
90
+ estimatedDuration = (_d = chunkInfos === null || chunkInfos === void 0 ? void 0 : chunkInfos.duration) !== null && _d !== void 0 ? _d : segment.duration;
91
91
  estimatedEnd = estimatedStart + estimatedDuration;
92
92
  if (safeAppendWindow[0] !== undefined) {
93
93
  estimatedStart = Math.max(estimatedStart, safeAppendWindow[0]);
@@ -99,7 +99,7 @@ export default function pushMediaSegment(_a, cancelSignal) {
99
99
  end: estimatedEnd }, content);
100
100
  return [4 /*yield*/, appendSegmentToBuffer(playbackObserver, segmentBuffer, { data: data, inventoryInfos: inventoryInfos }, cancelSignal)];
101
101
  case 1:
102
- _d.sent();
102
+ _e.sent();
103
103
  buffered = segmentBuffer.getBufferedRanges();
104
104
  return [2 /*return*/, { content: content, segment: segment, buffered: buffered, segmentData: chunkData }];
105
105
  }
@@ -628,6 +628,37 @@ declare const DEFAULT_CONFIG: {
628
628
  * buffers.
629
629
  */
630
630
  UNFREEZING_DELTA_POSITION: number;
631
+ /**
632
+ * The RxPlayer has a recurring logic which will synchronize the browser's
633
+ * buffers' buffered time ranges with its internal representation in the
634
+ * RxPlayer to then rely on that internal representation to determine where
635
+ * segments are technically present in the browser's buffer.
636
+ *
637
+ * We found out that when inserting a new segment to the buffer, the browser
638
+ * may actually take time before actually considering the full segment in its
639
+ * advertised buffered time ranges.
640
+ *
641
+ * This value thus set an amount of milliseconds we might want to wait before
642
+ * being sure that the buffered time ranges should have considered a segment
643
+ * that has been pushed.
644
+ */
645
+ SEGMENT_SYNCHRONIZATION_DELAY: number;
646
+ /**
647
+ * The `SEGMENT_SYNCHRONIZATION_DELAY` defined in this same configuration
648
+ * object only needs to be used if it appears that the current buffered
649
+ * time ranges do not reflect the full data of a pushed segment yet.
650
+ *
651
+ * The `MISSING_DATA_TRIGGER_SYNC_DELAY` value thus allows to define a
652
+ * minimum time difference in seconds between what's buffered and what the
653
+ * segment's ranges should have been, from which we might consider that we may
654
+ * want to wait the `SEGMENT_SYNCHRONIZATION_DELAY` before trusting the buffered
655
+ * time ranges for that segment.
656
+ * If what's missing from that segment is however less than that value in
657
+ * seconds, we can begin to trust the reported buffered time ranges.
658
+ *
659
+ * Should generally be inferior to `MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT`.
660
+ */
661
+ MISSING_DATA_TRIGGER_SYNC_DELAY: number;
631
662
  /**
632
663
  * Maximum authorized difference between what we calculated to be the
633
664
  * beginning or end of the segment in a media buffer and what we
@@ -221,8 +221,8 @@ var DEFAULT_CONFIG = {
221
221
  * @type {Object}
222
222
  */
223
223
  DEFAULT_INITIAL_BITRATES: {
224
- audio: 0,
225
- video: 0,
224
+ audio: 0, // only "audio" segments
225
+ video: 0, // only "video" segments
226
226
  other: 0, // tracks which are not audio/video (text images).
227
227
  // Though those are generally at a single bitrate, so no adaptive
228
228
  // mechanism is triggered for them.
@@ -239,8 +239,8 @@ var DEFAULT_CONFIG = {
239
239
  * @type {Object}
240
240
  */
241
241
  DEFAULT_MIN_BITRATES: {
242
- audio: 0,
243
- video: 0,
242
+ audio: 0, // only "audio" segments
243
+ video: 0, // only "video" segments
244
244
  other: 0, // tracks which are not audio/video
245
245
  // Though those are generally at a single bitrate, so no
246
246
  // adaptive mechanism is triggered for them.
@@ -258,8 +258,8 @@ var DEFAULT_CONFIG = {
258
258
  * @type {Object}
259
259
  */
260
260
  DEFAULT_MAX_BITRATES: {
261
- audio: Infinity,
262
- video: Infinity,
261
+ audio: Infinity, // only "audio" segments
262
+ video: Infinity, // only "video" segments
263
263
  other: Infinity, // tracks which are not audio/video
264
264
  // Though those are generally at a single bitrate, so no
265
265
  // adaptive mechanism is triggered for them.
@@ -661,6 +661,37 @@ var DEFAULT_CONFIG = {
661
661
  * buffers.
662
662
  */
663
663
  UNFREEZING_DELTA_POSITION: 0.001,
664
+ /**
665
+ * The RxPlayer has a recurring logic which will synchronize the browser's
666
+ * buffers' buffered time ranges with its internal representation in the
667
+ * RxPlayer to then rely on that internal representation to determine where
668
+ * segments are technically present in the browser's buffer.
669
+ *
670
+ * We found out that when inserting a new segment to the buffer, the browser
671
+ * may actually take time before actually considering the full segment in its
672
+ * advertised buffered time ranges.
673
+ *
674
+ * This value thus set an amount of milliseconds we might want to wait before
675
+ * being sure that the buffered time ranges should have considered a segment
676
+ * that has been pushed.
677
+ */
678
+ SEGMENT_SYNCHRONIZATION_DELAY: 1500,
679
+ /**
680
+ * The `SEGMENT_SYNCHRONIZATION_DELAY` defined in this same configuration
681
+ * object only needs to be used if it appears that the current buffered
682
+ * time ranges do not reflect the full data of a pushed segment yet.
683
+ *
684
+ * The `MISSING_DATA_TRIGGER_SYNC_DELAY` value thus allows to define a
685
+ * minimum time difference in seconds between what's buffered and what the
686
+ * segment's ranges should have been, from which we might consider that we may
687
+ * want to wait the `SEGMENT_SYNCHRONIZATION_DELAY` before trusting the buffered
688
+ * time ranges for that segment.
689
+ * If what's missing from that segment is however less than that value in
690
+ * seconds, we can begin to trust the reported buffered time ranges.
691
+ *
692
+ * Should generally be inferior to `MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT`.
693
+ */
694
+ MISSING_DATA_TRIGGER_SYNC_DELAY: 0.1,
664
695
  /**
665
696
  * Maximum authorized difference between what we calculated to be the
666
697
  * beginning or end of the segment in a media buffer and what we
@@ -795,8 +826,8 @@ var DEFAULT_CONFIG = {
795
826
  * @type {Object}
796
827
  */
797
828
  BUFFER_PADDING: {
798
- audio: 1,
799
- video: 3,
829
+ audio: 1, // only "audio" segments
830
+ video: 3, // only "video" segments
800
831
  other: 1, // tracks which are not audio/video (text images).
801
832
  },
802
833
  /**
@@ -862,12 +893,12 @@ var DEFAULT_CONFIG = {
862
893
  *
863
894
  * @type {Array.<Number>}
864
895
  */
865
- SEGMENT_PRIORITIES_STEPS: [2,
866
- 4,
867
- 8,
868
- 12,
869
- 18,
870
- 25],
896
+ SEGMENT_PRIORITIES_STEPS: [2, // 1st Step (priority number = 0): < 2
897
+ 4, // 2nd Step (priority number = 1): 2-4
898
+ 8, // 3rd Step (priority number = 2): 4-8
899
+ 12, // 4th Step (priority number = 3): 8-12
900
+ 18, // 5th Step (priority number = 4): 12-18
901
+ 25], // 6th Step (priority number = 5): 18-25
871
902
  // 7th Step (priority number = 6): >= 25
872
903
  /**
873
904
  * Some segment requests are said to be "high priority".
@@ -880,7 +911,7 @@ var DEFAULT_CONFIG = {
880
911
  * (beginning by the first step, which has the priority number `0`).
881
912
  * @type {number}
882
913
  */
883
- MAX_HIGH_PRIORITY_LEVEL: 1,
914
+ MAX_HIGH_PRIORITY_LEVEL: 1, // priority number 1 and lower is high priority
884
915
  /**
885
916
  * Enter here the first priority step (see `SEGMENT_PRIORITIES_STEPS`) that
886
917
  * will be considered as low priority.
@@ -893,7 +924,7 @@ var DEFAULT_CONFIG = {
893
924
  * `MAX_HIGH_PRIORITY_LEVEL`.
894
925
  * @type {number}
895
926
  */
896
- MIN_CANCELABLE_PRIORITY: 3,
927
+ MIN_CANCELABLE_PRIORITY: 3, // priority number 3 onward can be cancelled
897
928
  /**
898
929
  * Codecs used in the videoCapabilities of the MediaKeySystemConfiguration
899
930
  * (DRM).
@@ -1107,7 +1138,7 @@ var DEFAULT_CONFIG = {
1107
1138
  ADAPTATION_SWITCH_BUFFER_PADDINGS: {
1108
1139
  video: { before: 5, after: 5 },
1109
1140
  audio: { before: 2, after: 2.5 },
1110
- text: { before: 0, after: 0 },
1141
+ text: { before: 0, after: 0 }, // not managed natively, so no problem here
1111
1142
  image: { before: 0, after: 0 }, // not managed natively, so no problem here
1112
1143
  },
1113
1144
  /**
@@ -23,7 +23,6 @@
23
23
  */
24
24
  export default class AssertionError extends Error {
25
25
  readonly name: "AssertionError";
26
- readonly message: string;
27
26
  /**
28
27
  * @param {string} message
29
28
  */
@@ -42,11 +42,10 @@ var AssertionError = /** @class */ (function (_super) {
42
42
  * @param {string} message
43
43
  */
44
44
  function AssertionError(message) {
45
- var _this = _super.call(this) || this;
45
+ var _this = _super.call(this, message) || this;
46
46
  // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
47
47
  Object.setPrototypeOf(_this, AssertionError.prototype);
48
48
  _this.name = "AssertionError";
49
- _this.message = message;
50
49
  return _this;
51
50
  }
52
51
  return AssertionError;
@@ -24,7 +24,6 @@
24
24
  */
25
25
  export default class CustomLoaderError extends Error {
26
26
  readonly name: "CustomLoaderError";
27
- readonly message: string;
28
27
  readonly canRetry: boolean;
29
28
  readonly isOfflineError: boolean;
30
29
  readonly xhr: XMLHttpRequest | undefined;
@@ -46,11 +46,10 @@ var CustomLoaderError = /** @class */ (function (_super) {
46
46
  * @param {XMLHttpRequest} xhr
47
47
  */
48
48
  function CustomLoaderError(message, canRetry, isOfflineError, xhr) {
49
- var _this = _super.call(this) || this;
49
+ var _this = _super.call(this, message) || this;
50
50
  // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
51
51
  Object.setPrototypeOf(_this, CustomLoaderError.prototype);
52
52
  _this.name = "CustomLoaderError";
53
- _this.message = message;
54
53
  _this.canRetry = canRetry;
55
54
  _this.isOfflineError = isOfflineError;
56
55
  _this.xhr = xhr;
@@ -26,7 +26,6 @@ export default class EncryptedMediaError extends Error {
26
26
  readonly type: "ENCRYPTED_MEDIA_ERROR";
27
27
  readonly code: IEncryptedMediaErrorCode;
28
28
  readonly keyStatuses?: IEncryptedMediaErrorKeyStatusObject[];
29
- message: string;
30
29
  fatal: boolean;
31
30
  /**
32
31
  * @param {string} code
@@ -39,13 +39,12 @@ import errorMessage from "./error_message";
39
39
  var EncryptedMediaError = /** @class */ (function (_super) {
40
40
  __extends(EncryptedMediaError, _super);
41
41
  function EncryptedMediaError(code, reason, supplementaryInfos) {
42
- var _this = _super.call(this) || this;
42
+ var _this = _super.call(this, errorMessage("EncryptedMediaError", code, reason)) || this;
43
43
  // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
44
44
  Object.setPrototypeOf(_this, EncryptedMediaError.prototype);
45
45
  _this.name = "EncryptedMediaError";
46
46
  _this.type = ErrorTypes.ENCRYPTED_MEDIA_ERROR;
47
47
  _this.code = code;
48
- _this.message = errorMessage(_this.name, _this.code, reason);
49
48
  _this.fatal = false;
50
49
  if (typeof (supplementaryInfos === null || supplementaryInfos === void 0 ? void 0 : supplementaryInfos.keyStatuses) === "string") {
51
50
  _this.keyStatuses = supplementaryInfos.keyStatuses;
@@ -39,7 +39,6 @@ type ICodeWithAdaptationType = "BUFFER_APPEND_ERROR" | "BUFFER_FULL_ERROR" | "NO
39
39
  export default class MediaError extends Error {
40
40
  readonly name: "MediaError";
41
41
  readonly type: "MEDIA_ERROR";
42
- readonly message: string;
43
42
  readonly code: IMediaErrorCode;
44
43
  readonly trackInfo: IMediaErrorTrackContext | undefined;
45
44
  fatal: boolean;
@@ -39,13 +39,12 @@ import errorMessage from "./error_message";
39
39
  var MediaError = /** @class */ (function (_super) {
40
40
  __extends(MediaError, _super);
41
41
  function MediaError(code, reason, context) {
42
- var _this = _super.call(this) || this;
42
+ var _this = _super.call(this, errorMessage("MediaError", code, reason)) || this;
43
43
  // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
44
44
  Object.setPrototypeOf(_this, MediaError.prototype);
45
45
  _this.name = "MediaError";
46
46
  _this.type = ErrorTypes.MEDIA_ERROR;
47
47
  _this.code = code;
48
- _this.message = errorMessage(_this.name, _this.code, reason);
49
48
  _this.fatal = false;
50
49
  var adaptation = context === null || context === void 0 ? void 0 : context.adaptation;
51
50
  if (adaptation !== undefined) {
@@ -24,7 +24,6 @@ import RequestError from "./request_error";
24
24
  export default class NetworkError extends Error {
25
25
  readonly name: "NetworkError";
26
26
  readonly type: "NETWORK_ERROR";
27
- readonly message: string;
28
27
  readonly code: INetworkErrorCode;
29
28
  readonly xhr: XMLHttpRequest | null;
30
29
  readonly url: string;
@@ -43,7 +43,7 @@ var NetworkError = /** @class */ (function (_super) {
43
43
  * @param {Error} baseError
44
44
  */
45
45
  function NetworkError(code, baseError) {
46
- var _this = _super.call(this) || this;
46
+ var _this = _super.call(this, errorMessage("NetworkError", code, baseError.message)) || this;
47
47
  // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
48
48
  Object.setPrototypeOf(_this, NetworkError.prototype);
49
49
  _this.name = "NetworkError";
@@ -53,7 +53,6 @@ var NetworkError = /** @class */ (function (_super) {
53
53
  _this.status = baseError.status;
54
54
  _this.errorType = baseError.type;
55
55
  _this.code = code;
56
- _this.message = errorMessage(_this.name, _this.code, baseError.message);
57
56
  _this.fatal = false;
58
57
  return _this;
59
58
  }
@@ -21,7 +21,6 @@ import { IOtherErrorCode } from "./error_codes";
21
21
  export default class OtherError extends Error {
22
22
  readonly name: "OtherError";
23
23
  readonly type: "OTHER_ERROR";
24
- readonly message: string;
25
24
  readonly code: IOtherErrorCode;
26
25
  fatal: boolean;
27
26
  /**
@@ -41,13 +41,12 @@ var OtherError = /** @class */ (function (_super) {
41
41
  * @param {string} reason
42
42
  */
43
43
  function OtherError(code, reason) {
44
- var _this = _super.call(this) || this;
44
+ var _this = _super.call(this, errorMessage("OtherError", code, reason)) || this;
45
45
  // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
46
46
  Object.setPrototypeOf(_this, OtherError.prototype);
47
47
  _this.name = "OtherError";
48
48
  _this.type = ErrorTypes.OTHER_ERROR;
49
49
  _this.code = code;
50
- _this.message = errorMessage(_this.name, _this.code, reason);
51
50
  _this.fatal = false;
52
51
  return _this;
53
52
  }
@@ -26,7 +26,6 @@ import { INetworkErrorType } from "./error_codes";
26
26
  export default class RequestError extends Error {
27
27
  readonly name: "RequestError";
28
28
  readonly type: INetworkErrorType;
29
- readonly message: string;
30
29
  readonly xhr?: XMLHttpRequest;
31
30
  readonly url: string;
32
31
  readonly status: number;
@@ -45,31 +45,33 @@ var RequestError = /** @class */ (function (_super) {
45
45
  * @param {string} type
46
46
  */
47
47
  function RequestError(url, status, type, xhr) {
48
- var _this = _super.call(this) || this;
49
- // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
50
- Object.setPrototypeOf(_this, RequestError.prototype);
51
- _this.name = "RequestError";
52
- _this.url = url;
53
- if (xhr !== undefined) {
54
- _this.xhr = xhr;
55
- }
56
- _this.status = status;
57
- _this.type = type;
48
+ var _this = this;
49
+ var message;
58
50
  switch (type) {
59
51
  case "TIMEOUT":
60
- _this.message = "The request timed out";
52
+ message = "The request timed out";
61
53
  break;
62
54
  case "ERROR_EVENT":
63
- _this.message = "An error prevented the request to be performed successfully";
55
+ message = "An error prevented the request to be performed successfully";
64
56
  break;
65
57
  case "PARSE_ERROR":
66
- _this.message = "An error happened while formatting the response data";
58
+ message = "An error happened while formatting the response data";
67
59
  break;
68
60
  case "ERROR_HTTP_CODE":
69
- _this.message = "An HTTP status code indicating failure was received: " +
70
- String(_this.status);
61
+ message =
62
+ "An HTTP status code indicating failure was received: " + String(status);
71
63
  break;
72
64
  }
65
+ _this = _super.call(this, message) || this;
66
+ // @see https://stackoverflow.com/questions/41102060/typescript-extending-error-class
67
+ Object.setPrototypeOf(_this, RequestError.prototype);
68
+ _this.name = "RequestError";
69
+ _this.url = url;
70
+ if (xhr !== undefined) {
71
+ _this.xhr = xhr;
72
+ }
73
+ _this.status = status;
74
+ _this.type = type;
73
75
  return _this;
74
76
  }
75
77
  return RequestError;
@@ -15,7 +15,6 @@
15
15
  */
16
16
  export default class VideoThumbnailLoaderError extends Error {
17
17
  readonly name: "VideoThumbnailLoaderError";
18
- readonly message: string;
19
18
  readonly code: string;
20
19
  /**
21
20
  * @param {string} code
@@ -28,6 +28,7 @@ var __extends = (this && this.__extends) || (function () {
28
28
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
29
  };
30
30
  })();
31
+ import errorMessage from "../../../errors/error_message";
31
32
  // Returned error when rejecting
32
33
  var VideoThumbnailLoaderError = /** @class */ (function (_super) {
33
34
  __extends(VideoThumbnailLoaderError, _super);
@@ -36,11 +37,10 @@ var VideoThumbnailLoaderError = /** @class */ (function (_super) {
36
37
  * @param {string} message
37
38
  */
38
39
  function VideoThumbnailLoaderError(code, message) {
39
- var _this = _super.call(this) || this;
40
+ var _this = _super.call(this, errorMessage("VideoThumbnailLoaderError", code, message)) || this;
40
41
  Object.setPrototypeOf(_this, VideoThumbnailLoaderError.prototype);
41
42
  _this.name = "VideoThumbnailLoaderError";
42
43
  _this.code = code;
43
- _this.message = message;
44
44
  return _this;
45
45
  }
46
46
  return VideoThumbnailLoaderError;
@@ -94,9 +94,9 @@ function parseDuration(val) {
94
94
  * @returns {Promise.<number>}
95
95
  */
96
96
  function getDurationFromManifest(url, transport) {
97
- var _a;
98
97
  return __awaiter(this, void 0, void 0, function () {
99
98
  var response_1, responseData_1, root, dashDurationAttribute, periodElements, firstDASHStartAttribute, firstDASHStart, dashDuration, smoothDurationAttribute, smoothTimeScaleAttribute, timescale, response, responseData, metaplaylist, contents, lastEnd, firstStart;
99
+ var _a;
100
100
  return __generator(this, function (_b) {
101
101
  switch (_b.label) {
102
102
  case 0:
@@ -64,10 +64,6 @@ export default function probeDecodingInfos(config) {
64
64
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
65
65
  /* eslint-disable @typescript-eslint/no-unsafe-return */
66
66
  return navigator.mediaCapabilities.decodingInfo(config)
67
- /* eslint-enable @typescript-eslint/no-explicit-any */
68
- /* eslint-enable @typescript-eslint/no-unsafe-call */
69
- /* eslint-enable @typescript-eslint/no-unsafe-member-access */
70
- /* eslint-enable @typescript-eslint/no-unsafe-return */
71
67
  .then(function (result) {
72
68
  return [
73
69
  result.supported ? ProberStatus.Supported : ProberStatus.NotSupported,
@@ -75,5 +71,9 @@ export default function probeDecodingInfos(config) {
75
71
  }).catch(function () {
76
72
  return [ProberStatus.NotSupported];
77
73
  });
74
+ /* eslint-enable @typescript-eslint/no-explicit-any */
75
+ /* eslint-enable @typescript-eslint/no-unsafe-call */
76
+ /* eslint-enable @typescript-eslint/no-unsafe-member-access */
77
+ /* eslint-enable @typescript-eslint/no-unsafe-return */
78
78
  });
79
79
  }
@@ -429,6 +429,8 @@ function getKeyIdFromInitSegment(segment) {
429
429
  if (tenc === null || tenc.byteLength < 24) {
430
430
  return null;
431
431
  }
432
- return tenc.subarray(8, 24);
432
+ var keyId = tenc.subarray(8, 24);
433
+ // Zero-filled keyId should only be valid for unencrypted content
434
+ return keyId.every(function (b) { return b === 0; }) ? null : keyId;
433
435
  }
434
436
  export { getKeyIdFromInitSegment, getMDHDTimescale, getPlayReadyKIDFromPrivateData, getTrackFragmentDecodeTime, getDurationFromTrun, getSegmentsFromSidx, patchPssh, updateBoxLength, parseEmsgBoxes, };