rx-player 4.2.0-dev.2024101500 → 4.2.0

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 (34) hide show
  1. package/CHANGELOG.md +8 -13
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  5. package/dist/commonjs/main_thread/api/public_api.js +2 -2
  6. package/dist/commonjs/main_thread/decrypt/create_or_load_session.d.ts.map +1 -1
  7. package/dist/commonjs/main_thread/decrypt/create_or_load_session.js +4 -1
  8. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  9. package/dist/commonjs/main_thread/decrypt/get_media_keys.js +2 -1
  10. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  11. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.js +3 -7
  12. package/dist/commonjs/public_types.d.ts +54 -2
  13. package/dist/commonjs/public_types.d.ts.map +1 -1
  14. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  15. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  16. package/dist/es2017/main_thread/api/public_api.js +2 -2
  17. package/dist/es2017/main_thread/decrypt/create_or_load_session.d.ts.map +1 -1
  18. package/dist/es2017/main_thread/decrypt/create_or_load_session.js +4 -1
  19. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  20. package/dist/es2017/main_thread/decrypt/get_media_keys.js +2 -1
  21. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  22. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.js +3 -7
  23. package/dist/es2017/public_types.d.ts +54 -2
  24. package/dist/es2017/public_types.d.ts.map +1 -1
  25. package/dist/mpd-parser.wasm +0 -0
  26. package/dist/rx-player.js +9 -4
  27. package/dist/rx-player.min.js +2 -2
  28. package/package.json +1 -1
  29. package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
  30. package/src/main_thread/api/public_api.ts +2 -2
  31. package/src/main_thread/decrypt/create_or_load_session.ts +6 -1
  32. package/src/main_thread/decrypt/get_media_keys.ts +1 -0
  33. package/src/main_thread/init/utils/initial_seek_and_play.ts +3 -7
  34. package/src/public_types.ts +54 -3
@@ -411,7 +411,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
411
411
  // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
412
412
  videoElement.preload = "auto";
413
413
 
414
- this.version = /* PLAYER_VERSION */ "4.2.0-dev.2024101500";
414
+ this.version = /* PLAYER_VERSION */ "4.2.0";
415
415
  this.log = log;
416
416
  this.state = "STOPPED";
417
417
  this.videoElement = videoElement;
@@ -3330,7 +3330,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
3330
3330
  }
3331
3331
  }
3332
3332
  }
3333
- Player.version = /* PLAYER_VERSION */ "4.2.0-dev.2024101500";
3333
+ Player.version = /* PLAYER_VERSION */ "4.2.0";
3334
3334
 
3335
3335
  /** Every events sent by the RxPlayer's public API. */
3336
3336
  interface IPublicAPIEvent {
@@ -82,7 +82,12 @@ export default async function createOrLoadSession(
82
82
  }
83
83
  }
84
84
 
85
- await cleanOldLoadedSessions(loadedSessionsStore, maxSessionCacheSize);
85
+ await cleanOldLoadedSessions(
86
+ loadedSessionsStore,
87
+ // Account for the next session we will be creating
88
+ // Note that `maxSessionCacheSize < 0 has special semantic (no limit)`
89
+ maxSessionCacheSize <= 0 ? maxSessionCacheSize : maxSessionCacheSize - 1,
90
+ );
86
91
  if (cancelSignal.cancellationError !== null) {
87
92
  throw cancelSignal.cancellationError; // stop here if cancelled since
88
93
  }
@@ -98,6 +98,7 @@ export default async function getMediaKeysInfos(
98
98
  const persistentSessionsStore = createPersistentSessionsStorage(options);
99
99
 
100
100
  if (
101
+ evt.value.options.reuseMediaKeys !== false &&
101
102
  canReuseMediaKeys() &&
102
103
  currentState !== null &&
103
104
  evt.type === "reuse-media-key-system-access"
@@ -121,13 +121,9 @@ export default function performInitialSeekAndPlay(
121
121
  obs.readyState < HTMLMediaElement.HAVE_CURRENT_DATA
122
122
  ) {
123
123
  /**
124
- * On browser, such as Safari, the HTMLMediaElement.duration
125
- * and HTMLMediaElement.buffered may not be initialized at readyState 1, leading
126
- * to cases where it can be equal to `Infinity`.
127
- * If so, the range in which it is possible to seek is not yet known.
128
- * To solve this, the seek should be done after readyState HAVE_CURRENT_DATA (2),
129
- * at that time the previously mentioned attributes are correctly initialized and
130
- * the range in which it is possible to seek is correctly known.
124
+ * The starting position may not be known yet.
125
+ * Postpone the seek to a moment where the starting position should be known,
126
+ * assumely it's when readyState is greater or equal to HAVE_CURRENT_DATA (2).
131
127
  * If the initiallySeekedTime is still `undefined` when the readyState is >= 2,
132
128
  * let assume that the initiallySeekedTime will never be known and continue
133
129
  * the logic without seeking.
@@ -559,11 +559,62 @@ export interface IKeySystemOption {
559
559
  */
560
560
  distinctiveIdentifier?: MediaKeysRequirement | undefined;
561
561
  /**
562
- * If true, all open MediaKeySession (used to decrypt the content) will be
563
- * closed when the current playback stops.
562
+ * If true, all open `MediaKeySession` (JavaScript Objects linked to the keys
563
+ * used to decrypt the content) will be closed when the current playback
564
+ * stops.
565
+ *
566
+ * By default, we keep `MediaKeySession` from previous contents (up to
567
+ * `maxSessionCacheSize` `MediaKeySession`) to speed-up playback and avoid
568
+ * round-trips to the license server if the user ever decide to go back to
569
+ * those contents or to other contents relying to the same keys.
570
+ *
571
+ * However we found that some devices poorly handle that optimization.
572
+ *
573
+ * Note that if setting that property to `true` fixes your issue, it may be
574
+ * that it's just the `maxSessionCacheSize` which is for now too high.
575
+ *
576
+ * However if your problem doesn't disappear after setting
577
+ * `closeSessionsOnStop` to `true`, you may try `reuseMediaKeys` next.
564
578
  */
565
579
  closeSessionsOnStop?: boolean;
566
-
580
+ /**
581
+ * If set to `true` or if not set, we might rely on the previous `MediaKeys`
582
+ * if a compatible one is already set on the media element, allowing to
583
+ * potentially speed-up content playback.
584
+ *
585
+ * If set to `false`, we will create a new `MediaKeys` instance (a
586
+ * JavaScript object needed to decrypt contents) if needed for that content.
587
+ *
588
+ * We noticed that reusing a previous MediaKeys had led to errors on a few
589
+ * devices. For example some smart TVs had shown errors after playing several
590
+ * encrypted contents, errors which disappeared if we renewed the
591
+ * `MediaKeys` for each content.
592
+ *
593
+ * We should already be able to detect most of those cases in the RxPlayer
594
+ * logic. However, it is still possible that we don't know yet of a device
595
+ * which also has problem with that optimization.
596
+ *
597
+ * If you have issues appearing only after playing multiple encrypted
598
+ * contents:
599
+ *
600
+ * - First, try setting the `closeSessionsOnStop` option which is less
601
+ * destructive.
602
+ *
603
+ * If it fixes your issue, it may be that it's just the number of
604
+ * `MediaKeySession` cached by the RxPlayer that is here too high.
605
+ *
606
+ * In that case you can instead update the `maxSessionCacheSize` option
607
+ * to still profit from a `MediaKeySession` cache (which avoid making
608
+ * license requests for already-played contents).
609
+ *
610
+ * If that second option doesn't seem to have an effect, you can just set
611
+ * `closeSessionsOnStop`.
612
+ *
613
+ * - If none of the precedent work-arounds work however, you can try setting
614
+ * `reuseMediaKeys` to `false`. If it fixes your problem, please open an
615
+ * RxPlayer issue so we can add your device to our list.
616
+ */
617
+ reuseMediaKeys?: boolean | undefined;
567
618
  singleLicensePer?: "content" | "periods" | "init-data";
568
619
  /**
569
620
  * Maximum number of `MediaKeySession` that should be created on the same