senza-sdk 4.3.2-f445d5d.0 → 4.3.2
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/dist/implementation.bundle.js +2 -0
- package/dist/implementation.bundle.js.LICENSE.txt +57 -0
- package/package.json +1 -1
- package/src/implementation/alarmManager.js +23 -0
- package/src/implementation/api.js +15 -9
- package/src/implementation/deviceManager.js +22 -1
- package/src/implementation/lifecycle.js +63 -49
- package/src/implementation/messageManager.js +22 -0
- package/src/implementation/remotePlayer.js +144 -162
- package/src/interface/remotePlayer.js +14 -9
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
@license
|
|
3
|
+
Copyright 2006 The Closure Library Authors
|
|
4
|
+
SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
@license
|
|
9
|
+
Copyright 2008 The Closure Library Authors
|
|
10
|
+
SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
@license
|
|
15
|
+
EME Encryption Scheme Polyfill
|
|
16
|
+
Copyright 2019 Google LLC
|
|
17
|
+
SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
@license
|
|
22
|
+
MSS Transmuxer
|
|
23
|
+
Copyright 2015 Dash Industry Forum
|
|
24
|
+
SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
@license
|
|
29
|
+
Shaka Player
|
|
30
|
+
Copyright 2016 Google LLC
|
|
31
|
+
SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
@license
|
|
36
|
+
Shaka Player
|
|
37
|
+
Copyright 2022 Google LLC
|
|
38
|
+
SPDX-License-Identifier: Apache-2.0
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
@license
|
|
43
|
+
Shaka Player
|
|
44
|
+
Copyright 2023 Google LLC
|
|
45
|
+
SPDX-License-Identifier: Apache-2.0
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
@license
|
|
50
|
+
tXml
|
|
51
|
+
Copyright 2015 Tobias Nickel
|
|
52
|
+
SPDX-License-Identifier: MIT
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
//! moment.js
|
|
56
|
+
|
|
57
|
+
//! moment.js locale configuration
|
package/package.json
CHANGED
|
@@ -16,6 +16,28 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
16
16
|
timeoutMs: 15000 // Default timeout of 15 seconds, can be overridden by _setDefaultTimeout
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @type {boolean}
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
this._isInitialized = false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
_init() {
|
|
30
|
+
sdkLogger.log("Initializing AlarmManager");
|
|
31
|
+
if (!this._isInitialized) {
|
|
32
|
+
this._isInitialized = true;
|
|
33
|
+
this._addSenzaEventListeners();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @private Add event listeners for system events
|
|
39
|
+
*/
|
|
40
|
+
_addSenzaEventListeners() {
|
|
19
41
|
typeof document !== "undefined" && document.addEventListener("hs/alarmFiredEvent", async (e) => {
|
|
20
42
|
|
|
21
43
|
if (e.detail?.alarmName) {
|
|
@@ -73,6 +95,7 @@ class AlarmManager extends AlarmManagerInterface {
|
|
|
73
95
|
}
|
|
74
96
|
}
|
|
75
97
|
);
|
|
98
|
+
sdkLogger.log("[AlarmManager] Added event listeners for system events");
|
|
76
99
|
}
|
|
77
100
|
|
|
78
101
|
/**
|
|
@@ -2,7 +2,17 @@ import { getFCID, sdkLogger, getVersion } from "./utils.js";
|
|
|
2
2
|
import { sessionInfo } from "./SessionInfo.js";
|
|
3
3
|
import { lifecycle } from "./lifecycle.js";
|
|
4
4
|
import { alarmManager } from "./alarmManager.js";
|
|
5
|
+
import { remotePlayer } from "./remotePlayer.js";
|
|
6
|
+
import { deviceManager } from "./deviceManager.js";
|
|
7
|
+
import { messageManager } from "./messageManager.js";
|
|
5
8
|
|
|
9
|
+
export { remotePlayer };
|
|
10
|
+
export { lifecycle } from "./lifecycle.js";
|
|
11
|
+
export { deviceManager };
|
|
12
|
+
export { platformManager } from "./platformManager.js";
|
|
13
|
+
export { alarmManager };
|
|
14
|
+
export { messageManager };
|
|
15
|
+
export { SenzaShakaPlayer as ShakaPlayer, shaka } from "./senzaShakaPlayer.js";
|
|
6
16
|
let authToken;
|
|
7
17
|
|
|
8
18
|
const API_VERSION = "1.0";
|
|
@@ -24,8 +34,6 @@ export const auth = {
|
|
|
24
34
|
|
|
25
35
|
};
|
|
26
36
|
|
|
27
|
-
import { remotePlayer } from "./remotePlayer.js";
|
|
28
|
-
export { remotePlayer };
|
|
29
37
|
|
|
30
38
|
/** Should be called once to init the library
|
|
31
39
|
*@example
|
|
@@ -123,6 +131,11 @@ export async function init(interfaceApiVersion, showSequenceFunc, initSequenceFu
|
|
|
123
131
|
// Initialize lifecycle first to make sure the state is updated.
|
|
124
132
|
await lifecycle._init(sessionInfoObj?.settings?.["ui-streamer"], triggerEvent);
|
|
125
133
|
await remotePlayer._init(sessionInfoObj?.settings?.["ui-streamer"], triggerEvent);
|
|
134
|
+
alarmManager._init();
|
|
135
|
+
deviceManager._init();
|
|
136
|
+
messageManager._init();
|
|
137
|
+
sdkLogger.log("All submodules initialized");
|
|
138
|
+
|
|
126
139
|
|
|
127
140
|
const devSequence = sessionInfoObj?.settings?.["ui-streamer"]?.devSequence;
|
|
128
141
|
if (devSequence) {
|
|
@@ -255,13 +268,6 @@ export function uiReady() {
|
|
|
255
268
|
}
|
|
256
269
|
}
|
|
257
270
|
|
|
258
|
-
export { lifecycle } from "./lifecycle.js";
|
|
259
|
-
export { deviceManager } from "./deviceManager.js";
|
|
260
|
-
export { platformManager } from "./platformManager.js";
|
|
261
|
-
export { alarmManager };
|
|
262
|
-
export { messageManager } from "./messageManager.js";
|
|
263
|
-
export { SenzaShakaPlayer as ShakaPlayer, shaka } from "./senzaShakaPlayer.js";
|
|
264
|
-
|
|
265
271
|
import "./devHelper.js";
|
|
266
272
|
|
|
267
273
|
/**
|
|
@@ -43,7 +43,28 @@ class DeviceManager extends DeviceManagerInterface {
|
|
|
43
43
|
wifiInfo.quality = 0;
|
|
44
44
|
wifiInfo.ssid = "unknown";
|
|
45
45
|
wifiInfo.bssid = "unknown";
|
|
46
|
+
/**
|
|
47
|
+
* @type {boolean}
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
this._isInitialized = false;
|
|
51
|
+
}
|
|
46
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
_init() {
|
|
57
|
+
sdkLogger.log("Initializing DeviceManager");
|
|
58
|
+
if (!this._isInitialized) {
|
|
59
|
+
this._isInitialized = true;
|
|
60
|
+
this._addSenzaEventListeners();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @private Add event listeners for system events
|
|
66
|
+
*/
|
|
67
|
+
_addSenzaEventListeners() {
|
|
47
68
|
typeof document !== "undefined" && document.addEventListener("wifiSignalReport", (e) => {
|
|
48
69
|
wifiInfo.level = e.detail.level;
|
|
49
70
|
wifiInfo.quality = e.detail.quality;
|
|
@@ -51,7 +72,7 @@ class DeviceManager extends DeviceManagerInterface {
|
|
|
51
72
|
wifiInfo.bssid = e.detail.bssid;
|
|
52
73
|
this.dispatchEvent(new Event("wifiInfoUpdated"));
|
|
53
74
|
});
|
|
54
|
-
|
|
75
|
+
sdkLogger.log("[DeviceManager] Added event listeners for system events");
|
|
55
76
|
}
|
|
56
77
|
|
|
57
78
|
get deviceInfo() {
|
|
@@ -57,53 +57,6 @@ class Lifecycle extends LifecycleInterface {
|
|
|
57
57
|
* @private
|
|
58
58
|
*/
|
|
59
59
|
this._autoBackgroundOnUIDelay = DEFAULT_AUTO_BACKGROUND_UI_DELAY;
|
|
60
|
-
|
|
61
|
-
typeof document !== "undefined" && document.addEventListener("hs/uistatechange", (e) => {
|
|
62
|
-
sdkLogger.log("Got hs/uistatechange", e.detail);
|
|
63
|
-
const event = new Event("onstatechange");
|
|
64
|
-
event.state = e.detail;
|
|
65
|
-
this._state = event.state;
|
|
66
|
-
if (this._isAutoBackgroundEnabled() && this.state === this.UiState.FOREGROUND) {
|
|
67
|
-
this._startCountdown();
|
|
68
|
-
}
|
|
69
|
-
this.dispatchEvent(event);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
typeof document !== "undefined" && document.addEventListener("hs/systemInactivity", (e) => {
|
|
73
|
-
sdkLogger.log("Got hs/systemInactivity", e.detail);
|
|
74
|
-
const event = new Event("userinactivity");
|
|
75
|
-
event.timeout = e.detail.timeout;
|
|
76
|
-
this.dispatchEvent(event);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
typeof document !== "undefined" && document.addEventListener("hs/endOfSession", async () => {
|
|
80
|
-
// Create the event
|
|
81
|
-
const event = new Event("userdisconnected");
|
|
82
|
-
|
|
83
|
-
// Use the event manager to dispatch the event and wait for all listeners
|
|
84
|
-
await this._eventManager.dispatch("userdisconnected", event);
|
|
85
|
-
|
|
86
|
-
this._sendTerminatingMessage();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
typeof document !== "undefined" && document.addEventListener("keydown", () => {
|
|
90
|
-
if (this._isAutoBackgroundEnabled()) {
|
|
91
|
-
if (this.state === this.UiState.BACKGROUND ||
|
|
92
|
-
this.state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
|
|
93
|
-
this.moveToForeground();
|
|
94
|
-
} else {
|
|
95
|
-
this._startCountdown();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Add playModeChange listener
|
|
101
|
-
remotePlayer.addEventListener("playModeChange", (event) => {
|
|
102
|
-
if (this._isAutoBackgroundEnabled() && this.state === this.UiState.FOREGROUND) {
|
|
103
|
-
sdkLogger.log("Resetting auto background timer due to play mode change", event.detail.isPlaying);
|
|
104
|
-
this._startCountdown(event.detail.isPlaying);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
60
|
}
|
|
108
61
|
|
|
109
62
|
/**
|
|
@@ -118,6 +71,7 @@ class Lifecycle extends LifecycleInterface {
|
|
|
118
71
|
* @param {number} [uiStreamerSettings.remotePlayerApiVersion=1] - Remote player API version
|
|
119
72
|
*/
|
|
120
73
|
async _init(uiStreamerSettings, triggerEvent) {
|
|
74
|
+
sdkLogger.log("Initializing Lifecycle");
|
|
121
75
|
if (window.cefQuery) {
|
|
122
76
|
|
|
123
77
|
// Get UI state
|
|
@@ -186,6 +140,11 @@ class Lifecycle extends LifecycleInterface {
|
|
|
186
140
|
this._triggerEventFcid = triggerEvent.fcid;
|
|
187
141
|
}
|
|
188
142
|
|
|
143
|
+
// Make sure that the event listeners are registered only once
|
|
144
|
+
if (!this._isInitialized) {
|
|
145
|
+
this._addSenzaEventListeners();
|
|
146
|
+
}
|
|
147
|
+
|
|
189
148
|
this._isInitialized = true;
|
|
190
149
|
this._remotePlayerConfirmationTimeout = uiStreamerSettings?.remotePlayerConfirmationTimeout ?? DEFAULT_REMOTE_PLAYER_CONFIRMATION_TIMEOUT;
|
|
191
150
|
this._remotePlayerApiVersion = uiStreamerSettings?.remotePlayerApiVersion || 1;
|
|
@@ -204,6 +163,59 @@ class Lifecycle extends LifecycleInterface {
|
|
|
204
163
|
}
|
|
205
164
|
}
|
|
206
165
|
|
|
166
|
+
/**
|
|
167
|
+
* @private Add event listeners for system events
|
|
168
|
+
*/
|
|
169
|
+
_addSenzaEventListeners() {
|
|
170
|
+
typeof document !== "undefined" && document.addEventListener("hs/uistatechange", (e) => {
|
|
171
|
+
sdkLogger.log("Got hs/uistatechange", e.detail);
|
|
172
|
+
const event = new Event("onstatechange");
|
|
173
|
+
event.state = e.detail;
|
|
174
|
+
this._state = event.state;
|
|
175
|
+
if (this._isAutoBackgroundEnabled() && this.state === this.UiState.FOREGROUND) {
|
|
176
|
+
this._startCountdown();
|
|
177
|
+
}
|
|
178
|
+
this.dispatchEvent(event);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
typeof document !== "undefined" && document.addEventListener("hs/systemInactivity", (e) => {
|
|
182
|
+
sdkLogger.log("Got hs/systemInactivity", e.detail);
|
|
183
|
+
const event = new Event("userinactivity");
|
|
184
|
+
event.timeout = e.detail.timeout;
|
|
185
|
+
this.dispatchEvent(event);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
typeof document !== "undefined" && document.addEventListener("hs/endOfSession", async () => {
|
|
189
|
+
// Create the event
|
|
190
|
+
const event = new Event("userdisconnected");
|
|
191
|
+
|
|
192
|
+
// Use the event manager to dispatch the event and wait for all listeners
|
|
193
|
+
await this._eventManager.dispatch("userdisconnected", event);
|
|
194
|
+
|
|
195
|
+
this._sendTerminatingMessage();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
typeof document !== "undefined" && document.addEventListener("keydown", () => {
|
|
199
|
+
if (this._isAutoBackgroundEnabled()) {
|
|
200
|
+
if (this.state === this.UiState.BACKGROUND ||
|
|
201
|
+
this.state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
|
|
202
|
+
this.moveToForeground();
|
|
203
|
+
} else {
|
|
204
|
+
this._startCountdown();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Add playModeChange listener
|
|
210
|
+
remotePlayer.addEventListener("playModeChange", (event) => {
|
|
211
|
+
if (this._isAutoBackgroundEnabled() && this.state === this.UiState.FOREGROUND) {
|
|
212
|
+
sdkLogger.log("Resetting auto background timer due to play mode change", event.detail.isPlaying);
|
|
213
|
+
this._startCountdown(event.detail.isPlaying);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
sdkLogger.log("[Lifecycle] Added event listeners for system events");
|
|
217
|
+
}
|
|
218
|
+
|
|
207
219
|
/**
|
|
208
220
|
* @private Checks if auto background is enabled including overrides.
|
|
209
221
|
* @returns {boolean}
|
|
@@ -623,7 +635,6 @@ class Lifecycle extends LifecycleInterface {
|
|
|
623
635
|
}
|
|
624
636
|
|
|
625
637
|
// TODO: Need to discuss checking for a valid tenantId in the Senza platform
|
|
626
|
-
remotePlayer._blackoutTime = 0;
|
|
627
638
|
const contentHubTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId;
|
|
628
639
|
const homeTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantId;
|
|
629
640
|
sdkLogger.log(`SwitchTenant for ${tenantId}`);
|
|
@@ -636,6 +647,7 @@ class Lifecycle extends LifecycleInterface {
|
|
|
636
647
|
fcid: FCID,
|
|
637
648
|
session: btoa(JSON.stringify({
|
|
638
649
|
tenantId,
|
|
650
|
+
tenantSwitchInfo: {startTime: new Date().toISOString(), tenantOrigin: getPlatformInfo().sessionInfo?.tenant},
|
|
639
651
|
...getPlatformInfo().sessionInfo?.tenantId === contentHubTenantId && tenantId !== homeTenantId && { returnToTenantId: contentHubTenantId }
|
|
640
652
|
}))
|
|
641
653
|
};
|
|
@@ -676,12 +688,14 @@ class Lifecycle extends LifecycleInterface {
|
|
|
676
688
|
splashUrl: sessionInfoObj?.homeSessionInfo.tenantInfo.tenantSettings.applicationSwitchSplashUrl,
|
|
677
689
|
fcid: FCID
|
|
678
690
|
};
|
|
691
|
+
const session = {tenantSwitchInfo: {startTime: new Date().toISOString(), tenantOrigin: getPlatformInfo().sessionInfo?.tenant}};
|
|
679
692
|
if (sessionInfoObj?.returnToTenantId) {
|
|
680
693
|
if (sessionInfoObj?.returnToTenantId === sessionInfoObj?.homeSessionInfo.tenantInfo.contentHubTenantId) {
|
|
681
694
|
message.splashUrl = sessionInfoObj?.homeSessionInfo.contentHubTenantInfo.tenantSettings.applicationSwitchSplashUrl;
|
|
682
695
|
}
|
|
683
|
-
|
|
696
|
+
session.tenantId = sessionInfoObj?.returnToTenantId;
|
|
684
697
|
}
|
|
698
|
+
message.session = btoa(JSON.stringify(session));
|
|
685
699
|
request = { target: "TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
686
700
|
} else {
|
|
687
701
|
message = {
|
|
@@ -5,10 +5,32 @@ class MessageManager extends MessageManagerInterface {
|
|
|
5
5
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super();
|
|
8
|
+
/**
|
|
9
|
+
* @type {boolean}
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
this._isInitialized = false;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
_init() {
|
|
18
|
+
sdkLogger.log("Initializing MessageManager");
|
|
19
|
+
if (!this._isInitialized) {
|
|
20
|
+
this._isInitialized = true;
|
|
21
|
+
this._addSenzaEventListeners();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @private Add event listeners for system events
|
|
27
|
+
*/
|
|
28
|
+
_addSenzaEventListeners() {
|
|
8
29
|
typeof document !== "undefined" && document.addEventListener("hs/externalEvent", (e) => {
|
|
9
30
|
sdkLogger.log("Got hs/externalEvent", JSON.stringify(e.detail));
|
|
10
31
|
this.dispatchEvent(new CustomEvent("message", { detail: { eventName: e.detail.eventName, payload: e.detail.payload, fcid: e.detail.fcid } }));
|
|
11
32
|
});
|
|
33
|
+
sdkLogger.log("[MessageManager] Added event listeners for system events");
|
|
12
34
|
}
|
|
13
35
|
|
|
14
36
|
async registerGroups(groups) {
|