senza-sdk 4.3.1 → 4.3.2-f445d5d.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "senza-sdk",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2-f445d5d.0",
|
|
4
4
|
"main": "./src/api.js",
|
|
5
5
|
"description": "API for Senza application",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
},
|
|
52
52
|
"src/interface": {
|
|
53
53
|
"branches": 68.42,
|
|
54
|
-
"functions": 40
|
|
55
|
-
"lines": 65.
|
|
56
|
-
"statements":
|
|
54
|
+
"functions": 40,
|
|
55
|
+
"lines": 65.28,
|
|
56
|
+
"statements": 65.65
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
},
|
|
@@ -623,6 +623,7 @@ class Lifecycle extends LifecycleInterface {
|
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
// TODO: Need to discuss checking for a valid tenantId in the Senza platform
|
|
626
|
+
remotePlayer._blackoutTime = 0;
|
|
626
627
|
const contentHubTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId;
|
|
627
628
|
const homeTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantId;
|
|
628
629
|
sdkLogger.log(`SwitchTenant for ${tenantId}`);
|
|
@@ -141,6 +141,13 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
141
141
|
*/
|
|
142
142
|
this._isPlaying = false;
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @type {string}
|
|
146
|
+
* @description the last set blackout time as epoch seconds.
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
this._blackoutTime = 0;
|
|
150
|
+
|
|
144
151
|
typeof document !== "undefined" && document.addEventListener("hs/remotePlayerEvent", (e) => {
|
|
145
152
|
sdkLogger.info("Got hs/remotePlayerEvent event with detail", JSON.stringify(e?.detail));
|
|
146
153
|
this.dispatchEvent(new Event(e?.detail?.eventName));
|
|
@@ -744,6 +751,7 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
744
751
|
this._abortSetAudioLanguage = true;
|
|
745
752
|
this._abortSetSubtitleLanguage = true;
|
|
746
753
|
this._abortSeeking = true;
|
|
754
|
+
this._blackoutTime = 0;
|
|
747
755
|
if (reset) {
|
|
748
756
|
this._reset();
|
|
749
757
|
}
|
|
@@ -1355,6 +1363,129 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
1355
1363
|
}
|
|
1356
1364
|
}
|
|
1357
1365
|
|
|
1366
|
+
setBlackoutTime(date) {
|
|
1367
|
+
|
|
1368
|
+
if (!this._isInitialized) {
|
|
1369
|
+
throw new RemotePlayerError(6500, "Cannot call setBlackoutTime() if remote player is not initialized");
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
if (this._loadMode !== this.LoadMode.LOADED) {
|
|
1373
|
+
throw new RemotePlayerError(6001, "Cannot call setBlackoutTime() if player is not loaded");
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
if (!(date instanceof Date)) {
|
|
1377
|
+
throw new RemotePlayerError(6503, `date param must be a ${typeof new Date()} object but got ${typeof date}`);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
if (this._remotePlayerApiVersion < 2) {
|
|
1381
|
+
throw new RemotePlayerError(6504, `setBlackoutTime is not supported in remotePlayerApiVersion=${this._remotePlayerApiVersion}. remotePlayerApiVersion >= 2 required`);
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
const blackoutTime = (date.getTime()/1000).toFixed(2);
|
|
1385
|
+
if (window.cefQuery) {
|
|
1386
|
+
const FCID = getFCID();
|
|
1387
|
+
const logger = sdkLogger.withFields({ FCID });
|
|
1388
|
+
logger.log("remotePlayer setBlackoutTime: sending screenBlackout action");
|
|
1389
|
+
const message = {
|
|
1390
|
+
type: "remotePlayer.screenBlackout",
|
|
1391
|
+
class: "remotePlayer",
|
|
1392
|
+
action: "screenBlackout",
|
|
1393
|
+
fcid: FCID,
|
|
1394
|
+
blackoutTime
|
|
1395
|
+
};
|
|
1396
|
+
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
1397
|
+
return new Promise((resolve, reject) => {
|
|
1398
|
+
let timerId = 0;
|
|
1399
|
+
const timeBeforeSendingRequest = Date.now();
|
|
1400
|
+
const queryId = window.cefQuery({
|
|
1401
|
+
request: JSON.stringify(request),
|
|
1402
|
+
persistent: false,
|
|
1403
|
+
onSuccess: () => {
|
|
1404
|
+
this._blackoutTime = blackoutTime;
|
|
1405
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1406
|
+
logger.withFields({ duration }).log(`setBlackoutTime completed successfully after ${duration} ms`);
|
|
1407
|
+
timerId = clearTimer(timerId);
|
|
1408
|
+
resolve();
|
|
1409
|
+
},
|
|
1410
|
+
onFailure: (code, msg) => {
|
|
1411
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1412
|
+
logger.withFields({ duration }).log(`setBlackoutTime failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
|
|
1413
|
+
timerId = clearTimer(timerId);
|
|
1414
|
+
reject(new RemotePlayerError(code, msg));
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
|
|
1418
|
+
logger.log(`window.cefQuery for setBlackoutTime returned query id ${queryId}`);
|
|
1419
|
+
const timeout = this._remotePlayerConfirmationTimeout + 1000;
|
|
1420
|
+
timerId = setTimeout(() => {
|
|
1421
|
+
logger.log(`setBlackoutTime reached timeout of ${timeout} ms, canceling query id ${queryId}`);
|
|
1422
|
+
window.cefQueryCancel(queryId);
|
|
1423
|
+
reject(new RemotePlayerError(6000, `setBlackoutTime reached timeout of ${timeout} ms`));
|
|
1424
|
+
}, timeout, queryId);
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
sdkLogger.error("remotePlayer setBlackoutTime: window.cefQuery is undefined");
|
|
1428
|
+
return Promise.resolve(undefined);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
resetBlackoutTime() {
|
|
1432
|
+
if (!this._isInitialized) {
|
|
1433
|
+
throw new RemotePlayerError(6500, "Cannot call resetBlackoutTime() if remote player is not initialized");
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
if (this._loadMode !== this.LoadMode.LOADED) {
|
|
1437
|
+
throw new RemotePlayerError(6001, "Cannot call resetBlackoutTime() if player is not loaded");
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
if (this._remotePlayerApiVersion < 2) {
|
|
1441
|
+
throw new RemotePlayerError(6504, `resetBlackoutTime is not supported in remotePlayerApiVersion=${this._remotePlayerApiVersion}. remotePlayerApiVersion >= 2 required`);
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
if (window.cefQuery) {
|
|
1445
|
+
const FCID = getFCID();
|
|
1446
|
+
const logger = sdkLogger.withFields({ FCID });
|
|
1447
|
+
logger.log("remotePlayer resetBlackoutTime: sending screenBlackout action");
|
|
1448
|
+
const message = {
|
|
1449
|
+
type: "remotePlayer.screenBlackout",
|
|
1450
|
+
class: "remotePlayer",
|
|
1451
|
+
action: "screenBlackout",
|
|
1452
|
+
fcid: FCID,
|
|
1453
|
+
blackoutTime: 0 // Resetting the blackout time
|
|
1454
|
+
};
|
|
1455
|
+
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
1456
|
+
return new Promise((resolve, reject) => {
|
|
1457
|
+
let timerId = 0;
|
|
1458
|
+
const timeBeforeSendingRequest = Date.now();
|
|
1459
|
+
const queryId = window.cefQuery({
|
|
1460
|
+
request: JSON.stringify(request),
|
|
1461
|
+
persistent: false,
|
|
1462
|
+
onSuccess: () => {
|
|
1463
|
+
this._blackoutTime = 0; // Resetting the blackout time
|
|
1464
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1465
|
+
logger.withFields({ duration }).log(`resetBlackoutTime completed successfully after ${duration} ms`);
|
|
1466
|
+
timerId = clearTimer(timerId);
|
|
1467
|
+
resolve();
|
|
1468
|
+
},
|
|
1469
|
+
onFailure: (code, msg) => {
|
|
1470
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1471
|
+
logger.withFields({ duration }).log(`resetBlackoutTime failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
|
|
1472
|
+
timerId = clearTimer(timerId);
|
|
1473
|
+
reject(new RemotePlayerError(code, msg));
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
logger.log(`window.cefQuery for resetBlackoutTime returned query id ${queryId}`);
|
|
1477
|
+
const timeout = this._remotePlayerConfirmationTimeout + 1000;
|
|
1478
|
+
timerId = setTimeout(() => {
|
|
1479
|
+
logger.log(`resetBlackoutTime reached timeout of ${timeout} ms, canceling query id ${queryId}`);
|
|
1480
|
+
window.cefQueryCancel(queryId);
|
|
1481
|
+
reject(new RemotePlayerError(6000, `resetBlackoutTime reached timeout of ${timeout} ms`));
|
|
1482
|
+
}, timeout, queryId);
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
sdkLogger.error("remotePlayer resetBlackoutTime: window.cefQuery is undefined");
|
|
1486
|
+
return Promise.resolve(undefined);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1358
1489
|
/**
|
|
1359
1490
|
* Getter/Setter for currentTime
|
|
1360
1491
|
*/
|
|
@@ -116,6 +116,8 @@ export class RemotePlayerError extends Error {
|
|
|
116
116
|
* | 6500 | Player | remotePlayer api was called before initializing remotePlayer |
|
|
117
117
|
* | 6501 | Player | load() was called while previous load/unload was still in progress |
|
|
118
118
|
* | 6502 | Player | unload() was called while previous unload/load was still in progress |
|
|
119
|
+
* | 6503 | Player | The remote player api call has invalid parameters |
|
|
120
|
+
* | 6504 | Player | The remote player api call has invalid api version |
|
|
119
121
|
* | 8001 | Player | Error pulling manifest. bad parameters |
|
|
120
122
|
* | 8002 | Player | Error pulling manifest. filters returned no data |
|
|
121
123
|
* | 8003 | Player | Error pulling manifest. fetch error |
|
|
@@ -397,6 +399,25 @@ class RemotePlayer extends EventTarget {
|
|
|
397
399
|
return noop("RemotePlayer.setTextTrackVisibility", visible);
|
|
398
400
|
}
|
|
399
401
|
|
|
402
|
+
/**
|
|
403
|
+
*
|
|
404
|
+
* @param {Date} date
|
|
405
|
+
* @returns {Promise<void>} A Promise that resolves once the blackout time is set.
|
|
406
|
+
* @throws {RemotePlayerError} If the player is not initialized or not loaded. if date is not a Date object or if the remote player api version is less than 2
|
|
407
|
+
*/
|
|
408
|
+
setBlackoutTime(date) {
|
|
409
|
+
return noop("RemotePlayer.setBlackoutTime", date);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
*
|
|
414
|
+
* @returns {Promise<void>} A Promise that resolves once the blackout time is reset.
|
|
415
|
+
* @throws {RemotePlayerError} If the player is not initialized or not loaded. if the remote player api version is less than 2
|
|
416
|
+
*/
|
|
417
|
+
resetBlackoutTime() {
|
|
418
|
+
return noop("RemotePlayer.resetBlackoutTime");
|
|
419
|
+
}
|
|
420
|
+
|
|
400
421
|
/**
|
|
401
422
|
* Getter/Setter for currentTime
|
|
402
423
|
*/
|