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