rx-player 4.2.0-dev.2024091600 → 4.2.0-dev.2024100200

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 (161) hide show
  1. package/CHANGELOG.md +20 -11
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  5. package/dist/commonjs/compat/eme/close_session.js +2 -2
  6. package/dist/commonjs/compat/eme/load_session.js +2 -2
  7. package/dist/commonjs/compat/patch_webkit_source_buffer.d.ts.map +1 -1
  8. package/dist/commonjs/compat/patch_webkit_source_buffer.js +0 -3
  9. package/dist/commonjs/config.d.ts +7 -156
  10. package/dist/commonjs/config.d.ts.map +1 -1
  11. package/dist/commonjs/config.js +50 -3
  12. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +2 -2
  13. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -2
  14. package/dist/commonjs/core/fetchers/utils/schedule_request.js +2 -2
  15. package/dist/commonjs/core/main/worker/worker_main.d.ts.map +1 -1
  16. package/dist/commonjs/core/main/worker/worker_main.js +7 -0
  17. package/dist/commonjs/core/segment_sinks/garbage_collector.js +2 -2
  18. package/dist/commonjs/core/segment_sinks/implementations/audio_video/audio_video_segment_buffer.js +2 -2
  19. package/dist/commonjs/core/segment_sinks/implementations/text/text_segment_buffer.js +2 -2
  20. package/dist/commonjs/core/stream/adaptation/adaptation_stream.d.ts.map +1 -1
  21. package/dist/commonjs/core/stream/adaptation/adaptation_stream.js +35 -9
  22. package/dist/commonjs/core/stream/adaptation/index.d.ts +1 -1
  23. package/dist/commonjs/core/stream/adaptation/index.d.ts.map +1 -1
  24. package/dist/commonjs/core/stream/adaptation/index.js +0 -15
  25. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +2 -2
  26. package/dist/commonjs/core/stream/period/index.d.ts +1 -1
  27. package/dist/commonjs/core/stream/period/index.d.ts.map +1 -1
  28. package/dist/commonjs/core/stream/period/index.js +0 -15
  29. package/dist/commonjs/core/stream/period/period_stream.js +2 -2
  30. package/dist/commonjs/core/stream/representation/index.d.ts +1 -1
  31. package/dist/commonjs/core/stream/representation/index.d.ts.map +1 -1
  32. package/dist/commonjs/core/stream/representation/index.js +0 -15
  33. package/dist/commonjs/core/stream/representation/representation_stream.d.ts.map +1 -1
  34. package/dist/commonjs/core/stream/representation/representation_stream.js +2 -0
  35. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.d.ts.map +1 -1
  36. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.js +16 -11
  37. package/dist/commonjs/core/stream/representation/utils/push_init_segment.js +2 -2
  38. package/dist/commonjs/core/stream/representation/utils/push_media_segment.js +2 -2
  39. package/dist/commonjs/default_config.js +4 -0
  40. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +2 -2
  41. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +2 -2
  42. package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
  43. package/dist/commonjs/main_thread/api/public_api.js +19 -4
  44. package/dist/commonjs/main_thread/decrypt/attach_media_keys.js +2 -2
  45. package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  46. package/dist/commonjs/main_thread/decrypt/content_decryptor.js +4 -2
  47. package/dist/commonjs/main_thread/decrypt/create_or_load_session.js +2 -2
  48. package/dist/commonjs/main_thread/decrypt/create_session.js +2 -2
  49. package/dist/commonjs/main_thread/decrypt/dispose_decryption_resources.js +2 -2
  50. package/dist/commonjs/main_thread/decrypt/find_key_system.js +2 -2
  51. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  52. package/dist/commonjs/main_thread/decrypt/get_media_keys.js +3 -2
  53. package/dist/commonjs/main_thread/decrypt/init_media_keys.js +2 -2
  54. package/dist/commonjs/main_thread/decrypt/session_events_listener.js +2 -2
  55. package/dist/commonjs/main_thread/decrypt/set_server_certificate.js +2 -4
  56. package/dist/commonjs/main_thread/decrypt/utils/clean_old_loaded_sessions.js +2 -2
  57. package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.js +2 -2
  58. package/dist/commonjs/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  59. package/dist/commonjs/main_thread/init/directfile_content_initializer.js +14 -6
  60. package/dist/commonjs/main_thread/init/media_source_content_initializer.js +2 -2
  61. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts +13 -0
  62. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
  63. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +96 -47
  64. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts +1 -1
  65. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  66. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.js +21 -5
  67. package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
  68. package/dist/commonjs/mse/main_media_source_interface.js +21 -2
  69. package/dist/commonjs/multithread_types.d.ts +8 -1
  70. package/dist/commonjs/multithread_types.d.ts.map +1 -1
  71. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +2 -2
  72. package/dist/commonjs/parsers/manifest/index.d.ts +1 -1
  73. package/dist/commonjs/parsers/manifest/index.d.ts.map +1 -1
  74. package/dist/commonjs/parsers/manifest/index.js +0 -15
  75. package/dist/commonjs/transports/dash/integrity_checks.js +2 -2
  76. package/dist/commonjs/transports/dash/load_chunked_segment_data.js +2 -2
  77. package/dist/commonjs/transports/dash/segment_loader.js +2 -2
  78. package/dist/commonjs/transports/dash/text_loader.js +2 -2
  79. package/dist/commonjs/transports/smooth/pipelines.d.ts.map +1 -1
  80. package/dist/commonjs/transports/smooth/pipelines.js +1 -0
  81. package/dist/commonjs/transports/smooth/segment_loader.js +2 -2
  82. package/dist/commonjs/transports/utils/parse_text_track.d.ts.map +1 -1
  83. package/dist/commonjs/transports/utils/parse_text_track.js +1 -0
  84. package/dist/commonjs/utils/request/fetch.js +2 -2
  85. package/dist/commonjs/utils/retry_promise_with_backoff.js +2 -2
  86. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  87. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  88. package/dist/es2017/compat/patch_webkit_source_buffer.d.ts.map +1 -1
  89. package/dist/es2017/compat/patch_webkit_source_buffer.js +0 -3
  90. package/dist/es2017/config.d.ts +7 -156
  91. package/dist/es2017/config.d.ts.map +1 -1
  92. package/dist/es2017/config.js +6 -1
  93. package/dist/es2017/core/main/worker/worker_main.d.ts.map +1 -1
  94. package/dist/es2017/core/main/worker/worker_main.js +7 -0
  95. package/dist/es2017/core/stream/adaptation/adaptation_stream.d.ts.map +1 -1
  96. package/dist/es2017/core/stream/adaptation/adaptation_stream.js +33 -7
  97. package/dist/es2017/core/stream/adaptation/index.d.ts +1 -1
  98. package/dist/es2017/core/stream/adaptation/index.d.ts.map +1 -1
  99. package/dist/es2017/core/stream/adaptation/index.js +0 -1
  100. package/dist/es2017/core/stream/period/index.d.ts +1 -1
  101. package/dist/es2017/core/stream/period/index.d.ts.map +1 -1
  102. package/dist/es2017/core/stream/period/index.js +0 -1
  103. package/dist/es2017/core/stream/representation/index.d.ts +1 -1
  104. package/dist/es2017/core/stream/representation/index.d.ts.map +1 -1
  105. package/dist/es2017/core/stream/representation/index.js +0 -1
  106. package/dist/es2017/core/stream/representation/representation_stream.d.ts.map +1 -1
  107. package/dist/es2017/core/stream/representation/representation_stream.js +2 -0
  108. package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.d.ts.map +1 -1
  109. package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.js +6 -2
  110. package/dist/es2017/default_config.js +4 -0
  111. package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
  112. package/dist/es2017/main_thread/api/public_api.js +17 -2
  113. package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  114. package/dist/es2017/main_thread/decrypt/content_decryptor.js +2 -0
  115. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  116. package/dist/es2017/main_thread/decrypt/get_media_keys.js +1 -0
  117. package/dist/es2017/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  118. package/dist/es2017/main_thread/init/directfile_content_initializer.js +14 -6
  119. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts +13 -0
  120. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
  121. package/dist/es2017/main_thread/init/multi_thread_content_initializer.js +78 -41
  122. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts +1 -1
  123. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  124. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.js +19 -3
  125. package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
  126. package/dist/es2017/mse/main_media_source_interface.js +19 -0
  127. package/dist/es2017/multithread_types.d.ts +8 -1
  128. package/dist/es2017/multithread_types.d.ts.map +1 -1
  129. package/dist/es2017/parsers/manifest/index.d.ts +1 -1
  130. package/dist/es2017/parsers/manifest/index.d.ts.map +1 -1
  131. package/dist/es2017/parsers/manifest/index.js +1 -1
  132. package/dist/es2017/transports/smooth/pipelines.d.ts.map +1 -1
  133. package/dist/es2017/transports/smooth/pipelines.js +1 -0
  134. package/dist/es2017/transports/utils/parse_text_track.d.ts.map +1 -1
  135. package/dist/es2017/transports/utils/parse_text_track.js +1 -0
  136. package/dist/rx-player.js +101 -23
  137. package/dist/rx-player.min.js +14 -14
  138. package/dist/worker.js +6 -6
  139. package/package.json +38 -21
  140. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  141. package/src/compat/patch_webkit_source_buffer.ts +0 -3
  142. package/src/config.ts +10 -2
  143. package/src/core/main/worker/worker_main.ts +8 -0
  144. package/src/core/stream/adaptation/adaptation_stream.ts +41 -8
  145. package/src/core/stream/adaptation/index.ts +1 -1
  146. package/src/core/stream/period/index.ts +1 -1
  147. package/src/core/stream/representation/index.ts +1 -1
  148. package/src/core/stream/representation/representation_stream.ts +11 -0
  149. package/src/core/stream/representation/utils/append_segment_to_buffer.ts +6 -2
  150. package/src/default_config.ts +21 -0
  151. package/src/main_thread/api/public_api.ts +19 -2
  152. package/src/main_thread/decrypt/content_decryptor.ts +2 -0
  153. package/src/main_thread/decrypt/get_media_keys.ts +1 -0
  154. package/src/main_thread/init/directfile_content_initializer.ts +20 -10
  155. package/src/main_thread/init/multi_thread_content_initializer.ts +94 -61
  156. package/src/main_thread/init/utils/initial_seek_and_play.ts +24 -5
  157. package/src/mse/main_media_source_interface.ts +20 -0
  158. package/src/multithread_types.ts +9 -0
  159. package/src/parsers/manifest/index.ts +1 -1
  160. package/src/transports/smooth/pipelines.ts +1 -0
  161. package/src/transports/utils/parse_text_track.ts +1 -0
package/dist/rx-player.js CHANGED
@@ -1747,6 +1747,9 @@
1747
1747
  DEFAULT_AUDIO_TRACK_SWITCHING_MODE: "seamless"
1748
1748
  };
1749
1749
  var default_config_default = DEFAULT_CONFIG;
1750
+ function checkIsSerializable(_conf) {
1751
+ }
1752
+ checkIsSerializable(DEFAULT_CONFIG);
1750
1753
 
1751
1754
  // src/utils/object_assign.ts
1752
1755
  function objectAssign(target, ...sources) {
@@ -1798,13 +1801,17 @@
1798
1801
  }
1799
1802
 
1800
1803
  // src/config.ts
1801
- var ConfigHandler = class {
1804
+ var ConfigHandler = class extends EventEmitter {
1802
1805
  constructor() {
1806
+ super(...arguments);
1807
+ this.updated = false;
1803
1808
  this._config = default_config_default;
1804
1809
  }
1805
1810
  update(config) {
1806
1811
  const newConfig = deepMerge(this._config, config);
1807
1812
  this._config = newConfig;
1813
+ this.updated = true;
1814
+ this.trigger("update", config);
1808
1815
  }
1809
1816
  getCurrent() {
1810
1817
  return this._config;
@@ -9741,6 +9748,7 @@
9741
9748
  const currentState = media_keys_infos_store_default.getState(mediaElement);
9742
9749
  const persistentSessionsStore = createPersistentSessionsStorage(options);
9743
9750
  if (canReuseMediaKeys() && currentState !== null && evt.type === "reuse-media-key-system-access") {
9751
+ log_default.debug("DRM: Reusing already created MediaKeys");
9744
9752
  const { mediaKeys: mediaKeys2, loadedSessionsStore: loadedSessionsStore2 } = currentState;
9745
9753
  if (server_certificate_store_default.hasOne(mediaKeys2) === false || !isNullOrUndefined(options.serverCertificate) && server_certificate_store_default.has(mediaKeys2, options.serverCertificate)) {
9746
9754
  return {
@@ -10386,6 +10394,7 @@
10386
10394
  }
10387
10395
  this.systemId = systemId;
10388
10396
  if (this._stateData.state === 0 /* Initializing */) {
10397
+ log_default.debug("DRM: Waiting for attachment.");
10389
10398
  this._stateData = {
10390
10399
  state: 1 /* WaitingForAttachment */,
10391
10400
  isInitDataQueueLocked: true,
@@ -10428,6 +10437,7 @@
10428
10437
  const { options, mediaKeys, mediaKeySystemAccess, stores, askedConfiguration } = mediaKeysInfo;
10429
10438
  const shouldDisableLock = options.disableMediaKeysAttachmentLock === true;
10430
10439
  if (shouldDisableLock) {
10440
+ log_default.debug("DRM: disabling MediaKeys attachment lock. Ready for content");
10431
10441
  this._stateData = {
10432
10442
  state: 2 /* ReadyForContent */,
10433
10443
  isInitDataQueueLocked: true,
@@ -16969,8 +16979,12 @@
16969
16979
  log_default.warn("Stream: Running garbage collector");
16970
16980
  const start = Math.max(currentPos - 5, 0);
16971
16981
  const end = currentPos + bufferGoal.getValue() + 12;
16972
- await segmentSink.removeBuffer(0, start);
16973
- await segmentSink.removeBuffer(end, Number.MAX_VALUE);
16982
+ if (start > 0) {
16983
+ await segmentSink.removeBuffer(0, start);
16984
+ }
16985
+ if (end < Number.MAX_VALUE) {
16986
+ await segmentSink.removeBuffer(end, Number.MAX_VALUE);
16987
+ }
16974
16988
  await sleep(200);
16975
16989
  if (cancellationSignal.cancellationError !== null) {
16976
16990
  throw cancellationSignal.cancellationError;
@@ -17085,6 +17099,11 @@
17085
17099
  segmentQueue,
17086
17100
  terminate
17087
17101
  }, callbacks, parentCancelSignal) {
17102
+ log_default.debug(
17103
+ "Stream: Creating RepresentationStream",
17104
+ content.adaptation.type,
17105
+ content.representation.bitrate
17106
+ );
17088
17107
  const { period, adaptation, representation } = content;
17089
17108
  const { bufferGoal, maxBufferSize, drmSystemId, fastSwitchThreshold } = options;
17090
17109
  const bufferType = adaptation.type;
@@ -17375,6 +17394,12 @@
17375
17394
  if (globalCanceller.isUsed() && err instanceof CancellationError) {
17376
17395
  return;
17377
17396
  }
17397
+ log_default.warn(
17398
+ "Stream: Received fatal buffer error",
17399
+ adaptation.type,
17400
+ representation.bitrate,
17401
+ err instanceof Error ? err : null
17402
+ );
17378
17403
  globalCanceller.cancel();
17379
17404
  callbacks.error(err);
17380
17405
  }
@@ -17549,6 +17574,7 @@
17549
17574
  switch (switchStrat.type) {
17550
17575
  case "continue":
17551
17576
  break;
17577
+ // nothing to do
17552
17578
  case "needs-reload":
17553
17579
  return queue_microtask_default(() => {
17554
17580
  playbackObserver.listen(
@@ -17569,6 +17595,7 @@
17569
17595
  );
17570
17596
  });
17571
17597
  case "flush-buffer":
17598
+ // Clean + flush
17572
17599
  case "clean-buffer":
17573
17600
  for (const range of switchStrat.value) {
17574
17601
  await segmentSink.removeBuffer(range.start, range.end);
@@ -17661,12 +17688,13 @@
17661
17688
  );
17662
17689
  }
17663
17690
  function createRepresentationStream(representation, terminateCurrentStream, representationStreamCallbacks, fnCancelSignal) {
17691
+ let hasEncounteredError = false;
17664
17692
  const bufferGoalCanceller = new TaskCanceller();
17665
17693
  bufferGoalCanceller.linkToSignal(fnCancelSignal);
17666
17694
  const bufferGoal = createMappedReference(
17667
17695
  wantedBufferAhead,
17668
17696
  (prev) => {
17669
- return prev * getBufferGoalRatio(representation);
17697
+ return getBufferGoal(representation, prev);
17670
17698
  },
17671
17699
  bufferGoalCanceller.signal
17672
17700
  );
@@ -17680,6 +17708,11 @@
17680
17708
  const updatedCallbacks = object_assign_default({}, representationStreamCallbacks, {
17681
17709
  error(err) {
17682
17710
  var _a;
17711
+ if (hasEncounteredError) {
17712
+ log_default.warn("Stream: Ignoring RepresentationStream error", err);
17713
+ return;
17714
+ }
17715
+ hasEncounteredError = true;
17683
17716
  const formattedError = formatError(err, {
17684
17717
  defaultCode: "NONE",
17685
17718
  defaultReason: "Unknown `RepresentationStream` error"
@@ -17687,13 +17720,19 @@
17687
17720
  if (formattedError.code !== "BUFFER_FULL_ERROR") {
17688
17721
  representationStreamCallbacks.error(err);
17689
17722
  } else {
17723
+ log_default.warn(
17724
+ "Stream: received BUFFER_FULL_ERROR",
17725
+ adaptation.type,
17726
+ representation.bitrate
17727
+ );
17690
17728
  const wba = wantedBufferAhead.getValue();
17691
17729
  const lastBufferGoalRatio = (_a = bufferGoalRatioMap.get(representation.id)) != null ? _a : 1;
17692
17730
  const newBufferGoalRatio = lastBufferGoalRatio * 0.7;
17693
- if (newBufferGoalRatio <= 0.05 || wba * newBufferGoalRatio <= 2) {
17694
- throw formattedError;
17695
- }
17696
17731
  bufferGoalRatioMap.set(representation.id, newBufferGoalRatio);
17732
+ if (newBufferGoalRatio <= 0.05 || getBufferGoal(representation, wba) <= 2) {
17733
+ representationStreamCallbacks.error(formattedError);
17734
+ return;
17735
+ }
17697
17736
  cancellableSleep(4e3, adapStreamCanceller.signal).then(() => {
17698
17737
  return createRepresentationStream(
17699
17738
  representation,
@@ -17756,13 +17795,16 @@
17756
17795
  fnCancelSignal
17757
17796
  );
17758
17797
  }
17759
- function getBufferGoalRatio(representation) {
17798
+ function getBufferGoal(representation, wba) {
17760
17799
  const oldBufferGoalRatio = bufferGoalRatioMap.get(representation.id);
17761
17800
  const bufferGoalRatio = oldBufferGoalRatio !== void 0 ? oldBufferGoalRatio : 1;
17762
17801
  if (oldBufferGoalRatio === void 0) {
17763
17802
  bufferGoalRatioMap.set(representation.id, bufferGoalRatio);
17764
17803
  }
17765
- return bufferGoalRatio;
17804
+ if (bufferGoalRatio < 1 && wba === Infinity) {
17805
+ return 5 * 60 * 1e3 * bufferGoalRatio;
17806
+ }
17807
+ return wba * bufferGoalRatio;
17766
17808
  }
17767
17809
  }
17768
17810
 
@@ -19439,6 +19481,7 @@
19439
19481
  op.reject(error);
19440
19482
  });
19441
19483
  this._currentOperations = [];
19484
+ this._performNextOperation();
19442
19485
  }
19443
19486
  } else {
19444
19487
  this._currentOperations = [nextElem];
@@ -19453,7 +19496,11 @@
19453
19496
  false
19454
19497
  );
19455
19498
  nextElem.reject(error);
19499
+ this._currentOperations.forEach((op) => {
19500
+ op.reject(error);
19501
+ });
19456
19502
  this._currentOperations = [];
19503
+ this._performNextOperation();
19457
19504
  }
19458
19505
  }
19459
19506
  }
@@ -19824,17 +19871,20 @@
19824
19871
  };
19825
19872
  if (!isDirectfile || typeof startTime === "number") {
19826
19873
  const initiallySeekedTime = typeof startTime === "number" ? startTime : startTime();
19827
- if (initiallySeekedTime !== 0) {
19874
+ if (initiallySeekedTime !== 0 && initiallySeekedTime !== void 0) {
19828
19875
  performInitialSeek(initiallySeekedTime);
19829
19876
  }
19830
19877
  waitForSeekable();
19831
19878
  } else {
19832
19879
  playbackObserver.listen(
19833
19880
  (obs, stopListening) => {
19881
+ const initiallySeekedTime = typeof startTime === "number" ? startTime : startTime();
19882
+ if (initiallySeekedTime === void 0 && obs.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
19883
+ return;
19884
+ }
19834
19885
  if (obs.readyState >= 1) {
19835
19886
  stopListening();
19836
- const initiallySeekedTime = typeof startTime === "number" ? startTime : startTime();
19837
- if (initiallySeekedTime !== 0) {
19887
+ if (initiallySeekedTime !== 0 && initiallySeekedTime !== void 0) {
19838
19888
  if (can_seek_directly_after_loaded_metadata_default) {
19839
19889
  performInitialSeek(initiallySeekedTime);
19840
19890
  } else {
@@ -24432,6 +24482,7 @@
24432
24482
  switch (transferCharacteristicScheme.value) {
24433
24483
  case "15":
24434
24484
  return void 0;
24485
+ // SDR
24435
24486
  case "16":
24436
24487
  return { eotf: "pq" };
24437
24488
  case "18":
@@ -27983,6 +28034,8 @@
27983
28034
  }
27984
28035
  switch (codecs.toLowerCase()) {
27985
28036
  case "stpp":
28037
+ // stpp === TTML in MP4
28038
+ case "stpp.ttml":
27986
28039
  case "stpp.ttml.im1t":
27987
28040
  return "ttml";
27988
28041
  case "wvtt":
@@ -28406,25 +28459,33 @@
28406
28459
  }
28407
28460
  const duration = mediaElement.duration;
28408
28461
  if (typeof startAt.fromLastPosition === "number") {
28409
- if (isNullOrUndefined(duration) || !isFinite(duration)) {
28410
- log_default.warn(
28411
- "startAt.fromLastPosition set but no known duration, beginning at 0."
28412
- );
28413
- return 0;
28462
+ if (!isNullOrUndefined(duration) && isFinite(duration)) {
28463
+ return Math.max(0, duration + startAt.fromLastPosition);
28414
28464
  }
28415
- return Math.max(0, duration + startAt.fromLastPosition);
28465
+ if (mediaElement.seekable.length > 0) {
28466
+ const lastSegmentEnd = mediaElement.seekable.end(mediaElement.seekable.length - 1);
28467
+ if (isFinite(lastSegmentEnd)) {
28468
+ return Math.max(0, lastSegmentEnd + startAt.fromLastPosition);
28469
+ }
28470
+ }
28471
+ log_default.warn(
28472
+ "Init: startAt.fromLastPosition set but no known duration, it may be too soon to seek"
28473
+ );
28474
+ return void 0;
28416
28475
  } else if (typeof startAt.fromLivePosition === "number") {
28417
28476
  const livePosition = mediaElement.seekable.length > 0 ? mediaElement.seekable.end(0) : duration;
28418
28477
  if (isNullOrUndefined(livePosition)) {
28419
28478
  log_default.warn(
28420
- "startAt.fromLivePosition set but no known live position, beginning at 0."
28479
+ "Init: startAt.fromLivePosition set but no known live position, beginning at 0."
28421
28480
  );
28422
28481
  return 0;
28423
28482
  }
28424
28483
  return Math.max(0, livePosition + startAt.fromLivePosition);
28425
28484
  } else if (!isNullOrUndefined(startAt.percentage)) {
28426
28485
  if (isNullOrUndefined(duration) || !isFinite(duration)) {
28427
- log_default.warn("startAt.percentage set but no known duration, beginning at 0.");
28486
+ log_default.warn(
28487
+ "Init: startAt.percentage set but no known duration, beginning at 0."
28488
+ );
28428
28489
  return 0;
28429
28490
  }
28430
28491
  const { percentage } = startAt;
@@ -30878,6 +30939,7 @@
30878
30939
  case "proportionalSansSerif":
30879
30940
  element.style.fontFamily = "Arial, Helvetica, Liberation Sans, sans-serif";
30880
30941
  break;
30942
+ // TODO monospace or sans-serif or font with both?
30881
30943
  case "monospaceSansSerif":
30882
30944
  case "sansSerif":
30883
30945
  element.style.fontFamily = "sans-serif";
@@ -30886,6 +30948,7 @@
30886
30948
  case "default":
30887
30949
  element.style.fontFamily = "Courier New, Liberation Mono, monospace";
30888
30950
  break;
30951
+ // TODO font with both?
30889
30952
  case "proportionalSerif":
30890
30953
  element.style.fontFamily = "serif";
30891
30954
  break;
@@ -34458,7 +34521,7 @@
34458
34521
  segmentEnd = chunkInfos.duration !== void 0 ? chunkInfos.time + chunkInfos.duration : segment.end;
34459
34522
  }
34460
34523
  const lcCodec = codecs.toLowerCase();
34461
- if (mimeType === "application/ttml+xml+mp4" || lcCodec === "stpp" || lcCodec === "stpp.ttml.im1t") {
34524
+ if (mimeType === "application/ttml+xml+mp4" || lcCodec === "stpp" || lcCodec === "stpp.ttml" || lcCodec === "stpp.ttml.im1t") {
34462
34525
  _sdType = "ttml";
34463
34526
  } else if (lcCodec === "wvtt") {
34464
34527
  _sdType = "vtt";
@@ -36848,7 +36911,7 @@ ${event}`
36848
36911
  } = parseConstructorOptions(options);
36849
36912
  videoElement.preload = "auto";
36850
36913
  this.version = /* PLAYER_VERSION */
36851
- "4.2.0-dev.2024091600";
36914
+ "4.2.0-dev.2024100200";
36852
36915
  this.log = log_default;
36853
36916
  this.state = "STOPPED";
36854
36917
  this.videoElement = videoElement;
@@ -36998,6 +37061,20 @@ ${event}`
36998
37061
  },
36999
37062
  this._destroyCanceller.signal
37000
37063
  );
37064
+ const sendConfigUpdates = (updates) => {
37065
+ if (this._priv_worker === null) {
37066
+ return;
37067
+ }
37068
+ log_default.debug("---> Sending To Worker:", "config-update" /* ConfigUpdate */);
37069
+ this._priv_worker.postMessage({
37070
+ type: "config-update" /* ConfigUpdate */,
37071
+ value: updates
37072
+ });
37073
+ };
37074
+ if (config_default.updated) {
37075
+ sendConfigUpdates(config_default.getCurrent());
37076
+ }
37077
+ config_default.addEventListener("update", sendConfigUpdates, this._destroyCanceller.signal);
37001
37078
  });
37002
37079
  }
37003
37080
  /**
@@ -37463,6 +37540,7 @@ ${event}`
37463
37540
  case "RELOADING":
37464
37541
  case "LOADING":
37465
37542
  break;
37543
+ // keep previous metadata
37466
37544
  case "ENDED":
37467
37545
  this._priv_reloadingMetadata.reloadInPause = true;
37468
37546
  this._priv_reloadingMetadata.reloadPosition = playbackObserver.getReference().getValue().position.getPolled();
@@ -39374,7 +39452,7 @@ ${event}`
39374
39452
  _Player._priv_currentlyUsedVideoElements = /* @__PURE__ */ new WeakSet();
39375
39453
  var Player = _Player;
39376
39454
  Player.version = /* PLAYER_VERSION */
39377
- "4.2.0-dev.2024091600";
39455
+ "4.2.0-dev.2024100200";
39378
39456
  var public_api_default = Player;
39379
39457
 
39380
39458
  // src/main_thread/api/index.ts