senza-sdk 4.2.59-c9128b1.0 → 4.2.60

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "senza-sdk",
3
- "version": "4.2.59-c9128b1.0",
3
+ "version": "4.2.60",
4
4
  "main": "./src/api.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
@@ -85,7 +85,7 @@ class DeviceManager extends EventTarget {
85
85
  connectionId: sessionInfoObj.connectionId,
86
86
  community: sessionInfoObj.community,
87
87
  tenant: sessionInfoObj.tenant,
88
- clientIp: sessionInfoObj.clientIp,
88
+ clientIp: sessionInfoObj?.settings?.["ui-streamer"]?.clientIpOverride || sessionInfoObj.clientIp,
89
89
  countryCode: sessionInfoObj.general?.location?.["x-country-code"],
90
90
  connectionType: (!sessionInfoObj.connectionType || sessionInfoObj.connectionType === "direct") ? "device" : sessionInfoObj.connectionType
91
91
  };
package/src/lifecycle.js CHANGED
@@ -136,7 +136,7 @@ class Lifecycle extends EventTarget {
136
136
  const event = new Event("onstatechange");
137
137
  event.state = e.detail;
138
138
  this._state = event.state;
139
- if (this._autoBackground && this.state === this.UiState.FOREGROUND) {
139
+ if (this._isAutoBackgroundEnabled() && this.state === this.UiState.FOREGROUND) {
140
140
  this._startCountdown();
141
141
  }
142
142
  this.dispatchEvent(event);
@@ -160,7 +160,7 @@ class Lifecycle extends EventTarget {
160
160
  });
161
161
 
162
162
  typeof document !== "undefined" && document.addEventListener("keydown", () => {
163
- if (this._autoBackground) {
163
+ if (this._isAutoBackgroundEnabled()) {
164
164
  if (this.state === this.UiState.BACKGROUND ||
165
165
  this.state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
166
166
  this.moveToForeground();
@@ -172,7 +172,7 @@ class Lifecycle extends EventTarget {
172
172
 
173
173
  // Add playModeChange listener
174
174
  remotePlayer.addEventListener("playModeChange", (event) => {
175
- if (this._autoBackground && this.state === this.UiState.FOREGROUND) {
175
+ if (this._isAutoBackgroundEnabled() && this.state === this.UiState.FOREGROUND) {
176
176
  sdkLogger.log("Resetting auto background timer due to play mode change", event.detail.isPlaying);
177
177
  this._startCountdown(event.detail.isPlaying);
178
178
  }
@@ -264,6 +264,11 @@ class Lifecycle extends EventTarget {
264
264
 
265
265
  // Apply autoBackground settings if provided
266
266
  if (uiStreamerSettings?.autoBackground) {
267
+ // Overrides stored before any auto background settings are applied
268
+ if (uiStreamerSettings.autoBackground.overrides) {
269
+ this._autoBackgroundOverrides = uiStreamerSettings.autoBackground.overrides;
270
+ sdkLogger.warn(`Using overrides for autoBackground settings: ${JSON.stringify(this._autoBackgroundOverrides)}`);
271
+ }
267
272
  this.configure({
268
273
  autoBackground: uiStreamerSettings.autoBackground
269
274
  });
@@ -271,6 +276,35 @@ class Lifecycle extends EventTarget {
271
276
  }
272
277
  }
273
278
 
279
+ /** @private Checks if auto background is enabled including overrides.
280
+ * @returns {boolean}
281
+ */
282
+ _isAutoBackgroundEnabled() {
283
+ return this._autoBackgroundOverrides?.enabled ?? this._autoBackground;
284
+ }
285
+
286
+ /** @private Gets the auto background video delay including overrides.
287
+ * @returns {number}
288
+ */
289
+ _getAutoBackgroundOnVideoDelay() {
290
+ const playing = this._autoBackgroundOverrides?.timeout?.playing;
291
+ if (playing !== undefined) {
292
+ return playing === false ? -1 : playing;
293
+ }
294
+ return this._autoBackgroundOnVideoDelay;
295
+ }
296
+
297
+ /** @private Gets the auto background UI delay including overrides.
298
+ * @returns {number}
299
+ */
300
+ _getAutoBackgroundOnUIDelay() {
301
+ const idle = this._autoBackgroundOverrides?.timeout?.idle;
302
+ if (idle !== undefined) {
303
+ return idle === false ? -1 : idle;
304
+ }
305
+ return this._autoBackgroundOnUIDelay;
306
+ }
307
+
274
308
  /**
275
309
  * Configure lifecycle settings
276
310
  * @param {Object} config - Configuration object
@@ -309,8 +343,9 @@ class Lifecycle extends EventTarget {
309
343
  }
310
344
  }
311
345
  }
346
+
312
347
  // Start or stop countdown based on new configuration
313
- if (this._autoBackground) {
348
+ if (this._isAutoBackgroundEnabled()) {
314
349
  this._startCountdown();
315
350
  } else {
316
351
  this._stopCountdown();
@@ -419,7 +454,7 @@ class Lifecycle extends EventTarget {
419
454
  */
420
455
  set autoBackground(enabled) {
421
456
  this._autoBackground = enabled;
422
- if (enabled) {
457
+ if (this._isAutoBackgroundEnabled()) {
423
458
  this._startCountdown();
424
459
  } else {
425
460
  this._stopCountdown();
@@ -440,8 +475,7 @@ class Lifecycle extends EventTarget {
440
475
  */
441
476
  set autoBackgroundDelay(delay) {
442
477
  this._autoBackgroundOnVideoDelay = delay;
443
-
444
- if (this.autoBackground && remotePlayer._isPlaying) {
478
+ if (this._isAutoBackgroundEnabled() && remotePlayer._isPlaying) {
445
479
  this._startCountdown();
446
480
  }
447
481
  }
@@ -460,8 +494,7 @@ class Lifecycle extends EventTarget {
460
494
  */
461
495
  set autoBackgroundOnUIDelay(delay) {
462
496
  this._autoBackgroundOnUIDelay = delay;
463
-
464
- if (this.autoBackground && !remotePlayer._isPlaying) {
497
+ if (this._isAutoBackgroundEnabled() && !remotePlayer._isPlaying) {
465
498
  this._startCountdown();
466
499
  }
467
500
  }
@@ -476,7 +509,7 @@ class Lifecycle extends EventTarget {
476
509
  _startCountdown(isPlaying = remotePlayer._isPlaying) {
477
510
  this._stopCountdown();
478
511
 
479
- const timeoutDelay = isPlaying ? this._autoBackgroundOnVideoDelay : this._autoBackgroundOnUIDelay;
512
+ const timeoutDelay = isPlaying ? this._getAutoBackgroundOnVideoDelay() : this._getAutoBackgroundOnUIDelay();
480
513
 
481
514
  // Only start countdown if delay is positive
482
515
  if (timeoutDelay > 0) {
@@ -695,6 +695,11 @@ class RemotePlayer extends EventTarget {
695
695
  const audioLanguage = this._selectedAudioTrack || this._config.preferredAudioLanguage || "";
696
696
  const subtitlesLanguage = this._selectedSubtitlesTrack || this._config.preferredSubtitlesLanguage || "";
697
697
 
698
+ if (this._remotePlayerApiVersion >= 2 && !this._textTrackVisibility && streamType === StreamType.SUBTITLE) {
699
+ logger.log("remotePlayer play: text track visibility is disabled and streamType is only SUBTITLE. returning early with no action.");
700
+ return Promise.resolve(undefined); // nothing to do
701
+ }
702
+
698
703
  const message = {
699
704
  type: "remotePlayer.play",
700
705
  class: "remotePlayer",
@@ -710,17 +715,10 @@ class RemotePlayer extends EventTarget {
710
715
  message.streamType = streamType;
711
716
  waitForResponse = true;
712
717
 
713
- if (!this._textTrackVisibility) {
714
- const onlySubtitle = message.streamType === StreamType.SUBTITLE;
715
- if (onlySubtitle) {
716
- logger.log("remotePlayer play: text track visibility is disabled and streamType is only SUBTITLE. returning early with no action.");
717
- return Promise.resolve(undefined); // nothing to do
718
- }
719
- if (message.streamType && StreamType.SUBTITLE) {
720
- // remove SUBTITLE
721
- message.streamType = message.streamType & ~StreamType.SUBTITLE;
722
- logger.log("remotePlayer play: text track visibility is disabled. Removed SUBTITLE from streamType.");
723
- }
718
+ if (!this._textTrackVisibility && (message.streamType & StreamType.SUBTITLE) !== 0) {
719
+ // remove SUBTITLE
720
+ message.streamType = message.streamType & ~StreamType.SUBTITLE;
721
+ logger.log("remotePlayer play: text track visibility is disabled. Removed SUBTITLE from streamType.");
724
722
  }
725
723
  } else if (!this.textTrackVisibility) {
726
724
  message.subtitlesLanguage = "";