senza-sdk 4.2.59-c9128b1.0 → 4.2.59
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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/deviceManager.js +1 -1
- package/src/lifecycle.js +46 -17
- package/src/remotePlayer.js +24 -31
- package/src/senzaShakaPlayer.js +0 -3
package/package.json
CHANGED
package/src/deviceManager.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 (
|
|
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.
|
|
512
|
+
const timeoutDelay = isPlaying ? this._getAutoBackgroundOnVideoDelay() : this._getAutoBackgroundOnUIDelay();
|
|
480
513
|
|
|
481
514
|
// Only start countdown if delay is positive
|
|
482
515
|
if (timeoutDelay > 0) {
|
|
@@ -637,10 +670,10 @@ class Lifecycle extends EventTarget {
|
|
|
637
670
|
return new Promise((resolve, reject) => {
|
|
638
671
|
const FCID = getFCID();
|
|
639
672
|
const logger = sdkLogger.withFields({ FCID });
|
|
673
|
+
logger.log("lifecycle moveToBackground: sending play action");
|
|
640
674
|
const configuration = remotePlayer.getConfiguration();
|
|
641
675
|
const audioLanguage = remotePlayer._selectedAudioTrack || configuration.preferredAudioLanguage || "";
|
|
642
|
-
const subtitlesLanguage = remotePlayer._selectedSubtitlesTrack || configuration.preferredSubtitlesLanguage || "";
|
|
643
|
-
|
|
676
|
+
const subtitlesLanguage = remotePlayer.textTrackVisibility && (remotePlayer._selectedSubtitlesTrack || configuration.preferredSubtitlesLanguage) || "";
|
|
644
677
|
let request;
|
|
645
678
|
const message = {
|
|
646
679
|
action: "play",
|
|
@@ -652,7 +685,7 @@ class Lifecycle extends EventTarget {
|
|
|
652
685
|
message.type = "remotePlayer.play";
|
|
653
686
|
message.class = "remotePlayer";
|
|
654
687
|
message.switchMode = remotePlayer._isAudioSyncEnabled() ? SwitchMode.SEAMLESS : SwitchMode.NON_SEAMLESS;
|
|
655
|
-
message.streamType =
|
|
688
|
+
message.streamType = StreamType.AUDIO | StreamType.VIDEO | StreamType.SUBTITLE;
|
|
656
689
|
request = {
|
|
657
690
|
target: "TC",
|
|
658
691
|
waitForResponse: true,
|
|
@@ -660,12 +693,8 @@ class Lifecycle extends EventTarget {
|
|
|
660
693
|
message: JSON.stringify(message)
|
|
661
694
|
};
|
|
662
695
|
} else {
|
|
663
|
-
if (!remotePlayer.textTrackVisibility) {
|
|
664
|
-
message.subtitlesLanguage = "";
|
|
665
|
-
}
|
|
666
696
|
request = message;
|
|
667
697
|
}
|
|
668
|
-
logger.log(`lifecycle moveToBackground: sending play action audioLanguage=${message.audioLanguage} subtitlesLanguage=${message.subtitlesLanguage} textTrackVisibility=${remotePlayer.textTrackVisibility}`);
|
|
669
698
|
let timerId = 0;
|
|
670
699
|
const timeBeforeSendingRequest = Date.now();
|
|
671
700
|
const queryId = window.cefQuery({
|
package/src/remotePlayer.js
CHANGED
|
@@ -495,7 +495,13 @@ class RemotePlayer extends EventTarget {
|
|
|
495
495
|
}
|
|
496
496
|
if (this._availableTextTracks) {
|
|
497
497
|
const selectedTrack = this._availableTextTracks.find((track) => track.selected === true);
|
|
498
|
-
|
|
498
|
+
if (selectedTrack) {
|
|
499
|
+
this._selectedSubtitlesTrack = selectedTrack.id;
|
|
500
|
+
this._textTrackVisibility = true;
|
|
501
|
+
} else {
|
|
502
|
+
this._selectedSubtitlesTrack = "";
|
|
503
|
+
this._textTrackVisibility = false;
|
|
504
|
+
}
|
|
499
505
|
}
|
|
500
506
|
}
|
|
501
507
|
|
|
@@ -692,9 +698,12 @@ class RemotePlayer extends EventTarget {
|
|
|
692
698
|
if (window.cefQuery) {
|
|
693
699
|
const FCID = getFCID();
|
|
694
700
|
const logger = sdkLogger.withFields({ FCID });
|
|
701
|
+
logger.log("remotePlayer play: sending play action");
|
|
695
702
|
const audioLanguage = this._selectedAudioTrack || this._config.preferredAudioLanguage || "";
|
|
696
|
-
|
|
697
|
-
|
|
703
|
+
let subtitlesLanguage = "";
|
|
704
|
+
if (this._textTrackVisibility) {
|
|
705
|
+
subtitlesLanguage = this._selectedSubtitlesTrack || this._config.preferredSubtitlesLanguage || "";
|
|
706
|
+
}
|
|
698
707
|
const message = {
|
|
699
708
|
type: "remotePlayer.play",
|
|
700
709
|
class: "remotePlayer",
|
|
@@ -709,23 +718,7 @@ class RemotePlayer extends EventTarget {
|
|
|
709
718
|
message.switchMode = this._isAudioSyncEnabled() ? SwitchMode.SEAMLESS : SwitchMode.NON_SEAMLESS;
|
|
710
719
|
message.streamType = streamType;
|
|
711
720
|
waitForResponse = true;
|
|
712
|
-
|
|
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
|
-
}
|
|
724
|
-
}
|
|
725
|
-
} else if (!this.textTrackVisibility) {
|
|
726
|
-
message.subtitlesLanguage = "";
|
|
727
721
|
}
|
|
728
|
-
logger.log(`remotePlayer play: sending play action remotePlayer._isPlaying: ${this._isPlaying} audioLanguage=${message.audioLanguage} subtitlesLanguage=${message.subtitlesLanguage} textTrackVisibility=${this.textTrackVisibility}`);
|
|
729
722
|
const request = { target: "TC", waitForResponse: waitForResponse, message: JSON.stringify(message) };
|
|
730
723
|
return new Promise((resolve, reject) => {
|
|
731
724
|
let timerId = 0;
|
|
@@ -954,7 +947,10 @@ class RemotePlayer extends EventTarget {
|
|
|
954
947
|
const playbackPosition = position ?? 0;
|
|
955
948
|
const logger = sdkLogger.withFields({ FCID, loadUrl: url, playbackPosition });
|
|
956
949
|
const audioLanguage = audioTrackId || this._selectedAudioTrack || this._config.preferredAudioLanguage || "";
|
|
957
|
-
|
|
950
|
+
let subtitlesLanguage = "";
|
|
951
|
+
if (this._textTrackVisibility) {
|
|
952
|
+
subtitlesLanguage = textTrackId || this._selectedSubtitlesTrack || this._config.preferredSubtitlesLanguage || "";
|
|
953
|
+
}
|
|
958
954
|
|
|
959
955
|
const message = {
|
|
960
956
|
url,
|
|
@@ -972,7 +968,7 @@ class RemotePlayer extends EventTarget {
|
|
|
972
968
|
} else {
|
|
973
969
|
message.type = "setPlayableUri";
|
|
974
970
|
}
|
|
975
|
-
logger.log(`remotePlayer load: sending ${message.type} request. remotePlayer._isPlaying: ${this._isPlaying}
|
|
971
|
+
logger.log(`remotePlayer load: sending ${message.type} request. remotePlayer._isPlaying: ${this._isPlaying}`);
|
|
976
972
|
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
977
973
|
let timerId = 0;
|
|
978
974
|
const timeBeforeSendingRequest = Date.now();
|
|
@@ -1523,23 +1519,20 @@ class RemotePlayer extends EventTarget {
|
|
|
1523
1519
|
/**
|
|
1524
1520
|
* Enable or disable the subtitles.
|
|
1525
1521
|
* If the player is in an unloaded state, the request will be applied next time content is played.
|
|
1526
|
-
* @param {boolean
|
|
1527
|
-
* @throws {TypeError} if visible is not a boolean variable
|
|
1522
|
+
* @param {boolean} visible whether the subtitles are visible or not
|
|
1523
|
+
* @throws {TypeError} if visible is not a boolean variable
|
|
1528
1524
|
*/
|
|
1529
1525
|
setTextTrackVisibility(visible) {
|
|
1530
1526
|
const oldVisibility = this._textTrackVisibility;
|
|
1531
|
-
if (typeof visible !== "boolean"
|
|
1532
|
-
throw new TypeError("visible parameter must be a boolean
|
|
1527
|
+
if (typeof visible !== "boolean") {
|
|
1528
|
+
throw new TypeError("visible parameter must be a boolean");
|
|
1533
1529
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
if (oldVisibility === newVisibility) {
|
|
1530
|
+
const newVisibility = visible;
|
|
1531
|
+
if (newVisibility === oldVisibility) {
|
|
1538
1532
|
return;
|
|
1539
1533
|
}
|
|
1540
|
-
|
|
1541
1534
|
this._textTrackVisibility = newVisibility;
|
|
1542
|
-
if (!
|
|
1535
|
+
if (!newVisibility) {
|
|
1543
1536
|
// Setting the visibility to false clears any previous selections user has done
|
|
1544
1537
|
this._selectedSubtitlesTrack = "";
|
|
1545
1538
|
}
|
package/src/senzaShakaPlayer.js
CHANGED
|
@@ -502,8 +502,6 @@ export class SenzaShakaPlayer extends shaka.Player {
|
|
|
502
502
|
* });
|
|
503
503
|
*/
|
|
504
504
|
configure(config) {
|
|
505
|
-
sdkLogger.log("configure player with: ", JSON.stringify(config));
|
|
506
|
-
|
|
507
505
|
// Handle custom configuration
|
|
508
506
|
if (config.shouldStopRemotePlayerOnError !== undefined) {
|
|
509
507
|
this._shouldStopRemotePlayerOnError = !!config.shouldStopRemotePlayerOnError;
|
|
@@ -524,7 +522,6 @@ export class SenzaShakaPlayer extends shaka.Player {
|
|
|
524
522
|
remoteConfiguration["preferredSubtitlesLanguage"] = config["preferredTextLanguage"];
|
|
525
523
|
}
|
|
526
524
|
|
|
527
|
-
sdkLogger.log("configure remote player with: ", JSON.stringify(remoteConfiguration));
|
|
528
525
|
remotePlayer.configure(remoteConfiguration);
|
|
529
526
|
}
|
|
530
527
|
|