senza-sdk 4.4.12 → 4.4.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "senza-sdk",
3
- "version": "4.4.12",
3
+ "version": "4.4.13",
4
4
  "main": "./src/api.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
@@ -62,7 +62,8 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "shaka-player": "4.15.8",
66
- "moment": "^2.30.1"
65
+ "lodash.set": "^4.3.2",
66
+ "moment": "^2.30.1",
67
+ "shaka-player": "4.15.8"
67
68
  }
68
69
  }
@@ -24,7 +24,14 @@ export class EventListenersManager {
24
24
  if (!this.listeners.has(eventType)) {
25
25
  this.listeners.set(eventType, []);
26
26
  }
27
- this.listeners.get(eventType).push(listener);
27
+
28
+ const listenerArray = this.listeners.get(eventType);
29
+ listenerArray.push(listener);
30
+
31
+ // Send registration message to TC when first listener is added for displayinfochanged
32
+ if (listenerArray.length === 1) {
33
+ this._notifyTcIfNeeded(eventType, true);
34
+ }
28
35
  }
29
36
 
30
37
  /**
@@ -39,6 +46,11 @@ export class EventListenersManager {
39
46
  const index = listenerArray.indexOf(listener);
40
47
  if (index !== -1) {
41
48
  listenerArray.splice(index, 1);
49
+
50
+ // Send unregistration message to TC when last listener is removed for displayinfochanged
51
+ if (listenerArray.length === 0) {
52
+ this._notifyTcIfNeeded(eventType, false);
53
+ }
42
54
  }
43
55
  }
44
56
 
@@ -105,4 +117,42 @@ export class EventListenersManager {
105
117
  }
106
118
 
107
119
  }
120
+
121
+ /**
122
+ * Notify TC about listener registration changes if needed for specific events
123
+ * @param {string} eventName - The name of the event
124
+ * @param {*} value - The value associated with the event
125
+ */
126
+ _notifyTcIfNeeded(eventName, value) {
127
+ switch (eventName) {
128
+ case "displayinfochanged":
129
+ this._sendMessageToTc("updateDisplayInfoListener", { registered: value });
130
+ break;
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Send a message to TC using cefQuery
136
+ * @param {string} messageType - The type of message to send
137
+ * @param {Object} messageData - The data to include in the message
138
+ * @private
139
+ */
140
+ _sendMessageToTc(messageType, messageData) {
141
+ if (typeof window !== "undefined" && window.cefQuery) {
142
+ const message = { type: messageType, ...messageData };
143
+ const request = { target: "TC", waitForResponse: false, message: JSON.stringify(message) };
144
+ window.cefQuery({
145
+ request: JSON.stringify(request),
146
+ persistent: false,
147
+ onSuccess: () => {
148
+ sdkLogger.log(`${messageType} request successfully sent to TC`);
149
+ },
150
+ onFailure: (code, msg) => {
151
+ sdkLogger.error(`${messageType} request failed: ${code} ${msg}`);
152
+ }
153
+ });
154
+ } else {
155
+ sdkLogger.warn("cefQuery is not available");
156
+ }
157
+ }
108
158
  }
@@ -3,6 +3,7 @@ import * as shakaDebug from "shaka-player/dist/shaka-player.compiled.debug.js";
3
3
  import { remotePlayer, lifecycle, getPlatformInfo } from "./api";
4
4
  import { sdkLogger } from "./utils";
5
5
  import moment from "moment";
6
+ import set from "lodash.set";
6
7
 
7
8
  // Define custom error category
8
9
  shaka.util.Error.Category.SENZA_PLAYER_ERROR = 50;
@@ -745,7 +746,18 @@ export class SenzaShakaPlayer extends SenzaShakaInterface {
745
746
  });
746
747
  }
747
748
 
748
- configure(config) {
749
+ configure(config, value) {
750
+ // Handle string path configuration like Shaka Player
751
+ if (typeof config === "string") {
752
+ if (config === "") {
753
+ return;
754
+ }
755
+ const configObj = {};
756
+ set(configObj, config, value);
757
+ return this.configure(configObj);
758
+ }
759
+
760
+ // Handle object configuration
749
761
  sdkLogger.log("configure player with: ", JSON.stringify(config));
750
762
 
751
763
  // Handle custom configuration
@@ -151,16 +151,18 @@ export class SenzaShakaPlayer extends shaka.Player {
151
151
  * - shouldStopRemotePlayerOnError: boolean - If true, remote player will be stopped on error
152
152
  *
153
153
  * @override
154
- * @param {Object} config - Configuration object to be merged with existing config
155
- * @param {boolean} [config.shouldStopRemotePlayerOnError=true] - Whether to stop remote player on error
154
+ * @param {Object|string} config - Configuration object to be merged with existing config, or a property path string
155
+ * @param {*} [value] - The value to set (only used when config is a string path)
156
+ * @param {boolean} [config.shouldStopRemotePlayerOnError=true] - Whether to stop remote player on error (when config is object)
156
157
  * @example
157
158
  * player.configure({
158
159
  * shouldStopRemotePlayerOnError: false, // Don't stop remote player on error
159
160
  * // ... other shaka configurations
160
161
  * });
162
+ * player.configure('shouldStopRemotePlayerOnError', false);
161
163
  */
162
- configure(config) {
163
- return super.configure(config);
164
+ configure(config, value) {
165
+ return super.configure(config, value);
164
166
  }
165
167
  }
166
168
 
@@ -1 +1 @@
1
- export const version = "4.4.12";
1
+ export const version = "4.4.13";