senza-sdk 4.2.43 → 4.2.44
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 +4 -4
- package/src/remotePlayer.js +17 -10
- package/src/utils.js +1 -1
package/package.json
CHANGED
package/src/lifecycle.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { alarmManager, getPlatformInfo } from "./api";
|
|
2
2
|
import {
|
|
3
3
|
getFCID,
|
|
4
|
-
|
|
4
|
+
isAudioSyncConfigured,
|
|
5
5
|
clearTimer,
|
|
6
6
|
sdkLogger,
|
|
7
7
|
StreamType,
|
|
@@ -364,7 +364,7 @@ class Lifecycle extends EventTarget {
|
|
|
364
364
|
type: "remotePlayer.stop",
|
|
365
365
|
class: "remotePlayer",
|
|
366
366
|
action: "stop",
|
|
367
|
-
streamType:
|
|
367
|
+
streamType: remotePlayer._isAudioSyncEnabled() ? StreamType.VIDEO | StreamType.SUBTITLE : StreamType.AUDIO | StreamType.VIDEO | StreamType.SUBTITLE,
|
|
368
368
|
fcid: FCID
|
|
369
369
|
};
|
|
370
370
|
let timerId = 0;
|
|
@@ -428,7 +428,7 @@ class Lifecycle extends EventTarget {
|
|
|
428
428
|
return Promise.resolve(false);
|
|
429
429
|
}
|
|
430
430
|
// If audio sync is disabled, we only need to sync before remote player starts playing
|
|
431
|
-
if (!
|
|
431
|
+
if (!isAudioSyncConfigured()) {
|
|
432
432
|
remotePlayer._syncRemotePlayerWithLocalPlayer();
|
|
433
433
|
}
|
|
434
434
|
|
|
@@ -454,7 +454,7 @@ class Lifecycle extends EventTarget {
|
|
|
454
454
|
if (this._remotePlayerApiVersion >= 2) {
|
|
455
455
|
message.type = "remotePlayer.play";
|
|
456
456
|
message.class = "remotePlayer";
|
|
457
|
-
message.switchMode =
|
|
457
|
+
message.switchMode = remotePlayer._isAudioSyncEnabled() ? SwitchMode.SEAMLESS : SwitchMode.NON_SEAMLESS;
|
|
458
458
|
message.streamType = StreamType.AUDIO | StreamType.VIDEO | StreamType.SUBTITLE;
|
|
459
459
|
request = {
|
|
460
460
|
target: "TC",
|
package/src/remotePlayer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getFCID,
|
|
3
|
-
|
|
3
|
+
isAudioSyncConfigured,
|
|
4
4
|
clearTimer,
|
|
5
5
|
sdkLogger,
|
|
6
6
|
StreamType,
|
|
@@ -199,8 +199,8 @@ class RemotePlayer extends EventTarget {
|
|
|
199
199
|
sdkLogger.info("Got hs/playbackInfoEvent");
|
|
200
200
|
// When attached, the sdk controls the synchronization between the local and remote player.
|
|
201
201
|
if (this._videoElement) {
|
|
202
|
-
// When audio sync
|
|
203
|
-
if (!
|
|
202
|
+
// When audio sync is configured, the local player is already in sync with the remote player.
|
|
203
|
+
if (!isAudioSyncConfigured() && (lifecycle.state === lifecycle.UiState.BACKGROUND || lifecycle.state === lifecycle.UiState.IN_TRANSITION_TO_BACKGROUND)) {
|
|
204
204
|
this._syncLocalPlayerWithRemotePlayer();
|
|
205
205
|
}
|
|
206
206
|
} else {
|
|
@@ -250,8 +250,8 @@ class RemotePlayer extends EventTarget {
|
|
|
250
250
|
this._videoElement.playbackRate = event.detail.rate;
|
|
251
251
|
});
|
|
252
252
|
typeof document !== "undefined" && document.addEventListener("hs/senzaPlayerSetTime", (event) => {
|
|
253
|
-
// For simplicity, make sure we only accept syncing the current time if audio sync enabled
|
|
254
|
-
if (!this.
|
|
253
|
+
// For simplicity, make sure we only accept syncing the current time if audio sync is enabled
|
|
254
|
+
if (!this._isAudioSyncEnabled()) return;
|
|
255
255
|
if (this._isSeekingByApplication) {
|
|
256
256
|
sdkLogger.info("Skip senzaPlayerSetTime while seek performed");
|
|
257
257
|
return;
|
|
@@ -504,6 +504,13 @@ class RemotePlayer extends EventTarget {
|
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
506
|
|
|
507
|
+
/** @private Audio sync is enabled only when the video element is attached and the audio sync is configured
|
|
508
|
+
* @returns {boolean}
|
|
509
|
+
*/
|
|
510
|
+
_isAudioSyncEnabled() {
|
|
511
|
+
return isAudioSyncConfigured() && this._videoElement;
|
|
512
|
+
}
|
|
513
|
+
|
|
507
514
|
/** get the player configuration.
|
|
508
515
|
* @returns {Config}
|
|
509
516
|
* */
|
|
@@ -708,7 +715,7 @@ class RemotePlayer extends EventTarget {
|
|
|
708
715
|
let waitForResponse = false;
|
|
709
716
|
this._changePlayMode(true);
|
|
710
717
|
if (this._remotePlayerApiVersion >= 2) {
|
|
711
|
-
if (
|
|
718
|
+
if (this._isAudioSyncEnabled()) {
|
|
712
719
|
message.switchMode = SwitchMode.SEAMLESS;
|
|
713
720
|
message.streamType = StreamType.AUDIO;
|
|
714
721
|
waitForResponse = true;
|
|
@@ -756,7 +763,7 @@ class RemotePlayer extends EventTarget {
|
|
|
756
763
|
if (window.cefQuery) {
|
|
757
764
|
this._changePlayMode(false);
|
|
758
765
|
const isForegroundState = lifecycle.state === lifecycle.UiState.FOREGROUND || lifecycle.state === lifecycle.UiState.IN_TRANSITION_TO_FOREGROUND;
|
|
759
|
-
if (this._remotePlayerApiVersion >= 2 && !
|
|
766
|
+
if (this._remotePlayerApiVersion >= 2 && !this._isAudioSyncEnabled() && isForegroundState) {
|
|
760
767
|
sdkLogger.info("remotePlayer pause: application in foreground, remote player is not playing.");
|
|
761
768
|
return Promise.resolve();
|
|
762
769
|
}
|
|
@@ -770,7 +777,7 @@ class RemotePlayer extends EventTarget {
|
|
|
770
777
|
fcid: FCID
|
|
771
778
|
};
|
|
772
779
|
if (this._remotePlayerApiVersion >= 2) {
|
|
773
|
-
message.streamType =
|
|
780
|
+
message.streamType = this._isAudioSyncEnabled() && isForegroundState ? StreamType.AUDIO : StreamType.AUDIO | StreamType.VIDEO | StreamType.SUBTITLE;
|
|
774
781
|
}
|
|
775
782
|
const waitForResponse = this._remotePlayerApiVersion >= 2;
|
|
776
783
|
const request = { target: "TC", waitForResponse: waitForResponse, message: JSON.stringify(message) };
|
|
@@ -831,7 +838,7 @@ class RemotePlayer extends EventTarget {
|
|
|
831
838
|
if (this._videoElement) {
|
|
832
839
|
this.detach();
|
|
833
840
|
}
|
|
834
|
-
if (
|
|
841
|
+
if (isAudioSyncConfigured()) {
|
|
835
842
|
this._handleVideoFrameInfo(video);
|
|
836
843
|
this._updateSeekListeners(video);
|
|
837
844
|
}
|
|
@@ -1063,7 +1070,7 @@ class RemotePlayer extends EventTarget {
|
|
|
1063
1070
|
return Promise.resolve(true);
|
|
1064
1071
|
}
|
|
1065
1072
|
/*
|
|
1066
|
-
else if (this._remotePlayerApiVersion >= 2 &&
|
|
1073
|
+
else if (this._remotePlayerApiVersion >= 2 && this._isAudioSyncEnabled()) {
|
|
1067
1074
|
// If we have the position of the video element, we can sync the remote player with the local player
|
|
1068
1075
|
// before playing audio.
|
|
1069
1076
|
if (this._videoElement.currentTime !== 0) {
|
package/src/utils.js
CHANGED
|
@@ -110,7 +110,7 @@ export function clearTimer(timerId) {
|
|
|
110
110
|
return timerId;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
export function
|
|
113
|
+
export function isAudioSyncConfigured() {
|
|
114
114
|
const clientUiAudioSettings = sessionInfo.sessionInfoObj?.settings?.client?.["ui_audio"];
|
|
115
115
|
return clientUiAudioSettings?.enabled && clientUiAudioSettings?.from_cdn && clientUiAudioSettings?.ui_sync_enabled;
|
|
116
116
|
}
|