senza-sdk 4.2.59 → 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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/lifecycle.js +7 -3
- package/src/remotePlayer.js +28 -23
- package/src/senzaShakaPlayer.js +3 -0
package/package.json
CHANGED
package/src/lifecycle.js
CHANGED
|
@@ -670,10 +670,10 @@ class Lifecycle extends EventTarget {
|
|
|
670
670
|
return new Promise((resolve, reject) => {
|
|
671
671
|
const FCID = getFCID();
|
|
672
672
|
const logger = sdkLogger.withFields({ FCID });
|
|
673
|
-
logger.log("lifecycle moveToBackground: sending play action");
|
|
674
673
|
const configuration = remotePlayer.getConfiguration();
|
|
675
674
|
const audioLanguage = remotePlayer._selectedAudioTrack || configuration.preferredAudioLanguage || "";
|
|
676
|
-
const subtitlesLanguage = remotePlayer.
|
|
675
|
+
const subtitlesLanguage = remotePlayer._selectedSubtitlesTrack || configuration.preferredSubtitlesLanguage || "";
|
|
676
|
+
|
|
677
677
|
let request;
|
|
678
678
|
const message = {
|
|
679
679
|
action: "play",
|
|
@@ -685,7 +685,7 @@ class Lifecycle extends EventTarget {
|
|
|
685
685
|
message.type = "remotePlayer.play";
|
|
686
686
|
message.class = "remotePlayer";
|
|
687
687
|
message.switchMode = remotePlayer._isAudioSyncEnabled() ? SwitchMode.SEAMLESS : SwitchMode.NON_SEAMLESS;
|
|
688
|
-
message.streamType = StreamType.AUDIO | StreamType.VIDEO | StreamType.SUBTITLE;
|
|
688
|
+
message.streamType = remotePlayer.textTrackVisibility ? (StreamType.AUDIO | StreamType.VIDEO | StreamType.SUBTITLE) : (StreamType.AUDIO | StreamType.VIDEO);
|
|
689
689
|
request = {
|
|
690
690
|
target: "TC",
|
|
691
691
|
waitForResponse: true,
|
|
@@ -693,8 +693,12 @@ class Lifecycle extends EventTarget {
|
|
|
693
693
|
message: JSON.stringify(message)
|
|
694
694
|
};
|
|
695
695
|
} else {
|
|
696
|
+
if (!remotePlayer.textTrackVisibility) {
|
|
697
|
+
message.subtitlesLanguage = "";
|
|
698
|
+
}
|
|
696
699
|
request = message;
|
|
697
700
|
}
|
|
701
|
+
logger.log(`lifecycle moveToBackground: sending play action audioLanguage=${message.audioLanguage} subtitlesLanguage=${message.subtitlesLanguage} textTrackVisibility=${remotePlayer.textTrackVisibility}`);
|
|
698
702
|
let timerId = 0;
|
|
699
703
|
const timeBeforeSendingRequest = Date.now();
|
|
700
704
|
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,14 @@ 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
|
-
|
|
696
|
+
const subtitlesLanguage = this._selectedSubtitlesTrack || this._config.preferredSubtitlesLanguage || "";
|
|
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
|
|
706
701
|
}
|
|
702
|
+
|
|
707
703
|
const message = {
|
|
708
704
|
type: "remotePlayer.play",
|
|
709
705
|
class: "remotePlayer",
|
|
@@ -718,7 +714,16 @@ class RemotePlayer extends EventTarget {
|
|
|
718
714
|
message.switchMode = this._isAudioSyncEnabled() ? SwitchMode.SEAMLESS : SwitchMode.NON_SEAMLESS;
|
|
719
715
|
message.streamType = streamType;
|
|
720
716
|
waitForResponse = true;
|
|
717
|
+
|
|
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.");
|
|
722
|
+
}
|
|
723
|
+
} else if (!this.textTrackVisibility) {
|
|
724
|
+
message.subtitlesLanguage = "";
|
|
721
725
|
}
|
|
726
|
+
logger.log(`remotePlayer play: sending play action remotePlayer._isPlaying: ${this._isPlaying} audioLanguage=${message.audioLanguage} subtitlesLanguage=${message.subtitlesLanguage} textTrackVisibility=${this.textTrackVisibility}`);
|
|
722
727
|
const request = { target: "TC", waitForResponse: waitForResponse, message: JSON.stringify(message) };
|
|
723
728
|
return new Promise((resolve, reject) => {
|
|
724
729
|
let timerId = 0;
|
|
@@ -947,10 +952,7 @@ class RemotePlayer extends EventTarget {
|
|
|
947
952
|
const playbackPosition = position ?? 0;
|
|
948
953
|
const logger = sdkLogger.withFields({ FCID, loadUrl: url, playbackPosition });
|
|
949
954
|
const audioLanguage = audioTrackId || this._selectedAudioTrack || this._config.preferredAudioLanguage || "";
|
|
950
|
-
|
|
951
|
-
if (this._textTrackVisibility) {
|
|
952
|
-
subtitlesLanguage = textTrackId || this._selectedSubtitlesTrack || this._config.preferredSubtitlesLanguage || "";
|
|
953
|
-
}
|
|
955
|
+
const subtitlesLanguage = textTrackId || this._selectedSubtitlesTrack || this._config.preferredSubtitlesLanguage || "";
|
|
954
956
|
|
|
955
957
|
const message = {
|
|
956
958
|
url,
|
|
@@ -968,7 +970,7 @@ class RemotePlayer extends EventTarget {
|
|
|
968
970
|
} else {
|
|
969
971
|
message.type = "setPlayableUri";
|
|
970
972
|
}
|
|
971
|
-
logger.log(`remotePlayer load: sending ${message.type} request. remotePlayer._isPlaying: ${this._isPlaying}`);
|
|
973
|
+
logger.log(`remotePlayer load: sending ${message.type} request. remotePlayer._isPlaying: ${this._isPlaying} audioLanguage=${audioLanguage} subtitlesLanguage=${subtitlesLanguage}`);
|
|
972
974
|
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
973
975
|
let timerId = 0;
|
|
974
976
|
const timeBeforeSendingRequest = Date.now();
|
|
@@ -1519,20 +1521,23 @@ class RemotePlayer extends EventTarget {
|
|
|
1519
1521
|
/**
|
|
1520
1522
|
* Enable or disable the subtitles.
|
|
1521
1523
|
* 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
|
|
1524
|
+
* @param {boolean|0|1} visible whether the subtitles are visible or not
|
|
1525
|
+
* @throws {TypeError} if visible is not a boolean variable or 0/1
|
|
1524
1526
|
*/
|
|
1525
1527
|
setTextTrackVisibility(visible) {
|
|
1526
1528
|
const oldVisibility = this._textTrackVisibility;
|
|
1527
|
-
if (typeof visible !== "boolean") {
|
|
1528
|
-
throw new TypeError("visible parameter must be a boolean");
|
|
1529
|
+
if (typeof visible !== "boolean" && !(visible === 0 || visible === 1)) {
|
|
1530
|
+
throw new TypeError("visible parameter must be a boolean or 0/1");
|
|
1529
1531
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
+
// Convert to boolean in case apps pass 0/1 instead false/true.
|
|
1533
|
+
const newVisibility = !!visible;
|
|
1534
|
+
|
|
1535
|
+
if (oldVisibility === newVisibility) {
|
|
1532
1536
|
return;
|
|
1533
1537
|
}
|
|
1538
|
+
|
|
1534
1539
|
this._textTrackVisibility = newVisibility;
|
|
1535
|
-
if (!
|
|
1540
|
+
if (!this._textTrackVisibility) {
|
|
1536
1541
|
// Setting the visibility to false clears any previous selections user has done
|
|
1537
1542
|
this._selectedSubtitlesTrack = "";
|
|
1538
1543
|
}
|
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
|
|