senza-sdk 4.2.64 → 4.2.65-54828cd.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/dist/bundle.js +1 -1
- package/package.json +2 -3
- package/src/lifecycle.js +1 -0
- package/src/remotePlayer.js +125 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "senza-sdk",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.65-54828cd.0",
|
|
4
4
|
"main": "./src/api.js",
|
|
5
5
|
"description": "API for Senza application",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"eslint": "eslint --max-warnings 0 src test",
|
|
16
16
|
"build": "npx webpack --config webpack.config.js",
|
|
17
17
|
"test": "jest --coverage --verbose",
|
|
18
|
-
"testall"
|
|
18
|
+
"testall": "jest --coverage --verbose && npm run eslint --fix"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@babel/cli": "^7.13.16",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"jsdoc-to-markdown": "^7.1.1",
|
|
33
33
|
"webpack": "^5.72.1",
|
|
34
34
|
"webpack-cli": "^5.1.4"
|
|
35
|
-
|
|
36
35
|
},
|
|
37
36
|
"jest": {
|
|
38
37
|
"verbose": false,
|
package/src/lifecycle.js
CHANGED
|
@@ -784,6 +784,7 @@ class Lifecycle extends EventTarget {
|
|
|
784
784
|
}
|
|
785
785
|
|
|
786
786
|
// TODO: Need to discuss checking for a valid tenantId in the Senza platform
|
|
787
|
+
remotePlayer._blackoutTime = 0;
|
|
787
788
|
const contentHubTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId;
|
|
788
789
|
const homeTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantId;
|
|
789
790
|
sdkLogger.log(`SwitchTenant for ${tenantId}`);
|
package/src/remotePlayer.js
CHANGED
|
@@ -163,6 +163,13 @@ class RemotePlayer extends EventTarget {
|
|
|
163
163
|
*/
|
|
164
164
|
this._isPlaying = false;
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* @type {string}
|
|
168
|
+
* @description the last set blackout time as epoch seconds.
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
171
|
+
this._blackoutTime = 0;
|
|
172
|
+
|
|
166
173
|
/**
|
|
167
174
|
* @event RemotePlayer#canplay
|
|
168
175
|
* @description canplay event will be dispatched when the remote player can start play the event
|
|
@@ -323,7 +330,8 @@ class RemotePlayer extends EventTarget {
|
|
|
323
330
|
* | 6002 | Player | load() was called while the application was in state 'background' or 'inTransitionToBackground' |
|
|
324
331
|
* | 6500 | Player | remotePlayer api was called before initializing remotePlayer |
|
|
325
332
|
* | 6501 | Player | load() was called while previous load/unload was still in progress |
|
|
326
|
-
* | 6502 | Player | unload() was called while previous unload/load was still in progress
|
|
333
|
+
* | 6502 | Player | unload() was called while previous unload/load was still in progress
|
|
334
|
+
* | 6503 | Player | The remote player api call has invalid parameters |
|
|
327
335
|
* | 8001 | Player | Error pulling manifest. bad parameters |
|
|
328
336
|
* | 8002 | Player | Error pulling manifest. filters returned no data |
|
|
329
337
|
* | 8003 | Player | Error pulling manifest. fetch error |
|
|
@@ -951,6 +959,7 @@ class RemotePlayer extends EventTarget {
|
|
|
951
959
|
this._abortSetAudioLanguage = true;
|
|
952
960
|
this._abortSetSubtitleLanguage = true;
|
|
953
961
|
this._abortSeeking = true;
|
|
962
|
+
this._blackoutTime = 0;
|
|
954
963
|
if (reset) {
|
|
955
964
|
this._reset();
|
|
956
965
|
}
|
|
@@ -1562,6 +1571,121 @@ class RemotePlayer extends EventTarget {
|
|
|
1562
1571
|
}
|
|
1563
1572
|
}
|
|
1564
1573
|
|
|
1574
|
+
setBlackoutTime(date) {
|
|
1575
|
+
|
|
1576
|
+
if (!this._isInitialized) {
|
|
1577
|
+
throw new RemotePlayerError(6500, "Cannot call setBlackoutTime() if remote player is not initialized");
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
if (this._loadMode !== this.LoadMode.LOADED) {
|
|
1581
|
+
throw new RemotePlayerError(6001, "Cannot call setBlackoutTime() if player is not loaded");
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
if (!(date instanceof Date)) {
|
|
1585
|
+
throw new RemotePlayerError(6503, "date param must be a Date object");
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
const blackoutTime = (date.getTime()/1000).toFixed(2)
|
|
1589
|
+
if (window.cefQuery) {
|
|
1590
|
+
const FCID = getFCID();
|
|
1591
|
+
const logger = sdkLogger.withFields({ FCID });
|
|
1592
|
+
logger.log("remotePlayer setBlackoutTime: sending screenBlackout action");
|
|
1593
|
+
const message = {
|
|
1594
|
+
type: "remotePlayer.screenBlackout",
|
|
1595
|
+
class: "remotePlayer",
|
|
1596
|
+
action: "screenBlackout",
|
|
1597
|
+
fcid: FCID,
|
|
1598
|
+
blackoutTime
|
|
1599
|
+
};
|
|
1600
|
+
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
1601
|
+
return new Promise((resolve, reject) => {
|
|
1602
|
+
let timerId = 0;
|
|
1603
|
+
const timeBeforeSendingRequest = Date.now();
|
|
1604
|
+
const queryId = window.cefQuery({
|
|
1605
|
+
request: JSON.stringify(request),
|
|
1606
|
+
persistent: false,
|
|
1607
|
+
onSuccess: () => {
|
|
1608
|
+
this._blackoutTime = blackoutTime;
|
|
1609
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1610
|
+
logger.withFields({ duration }).log(`setBlackoutTime completed successfully after ${duration} ms`);
|
|
1611
|
+
timerId = clearTimer(timerId);
|
|
1612
|
+
resolve();
|
|
1613
|
+
},
|
|
1614
|
+
onFailure: (code, msg) => {
|
|
1615
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1616
|
+
logger.withFields({ duration }).log(`setBlackoutTime failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
|
|
1617
|
+
timerId = clearTimer(timerId);
|
|
1618
|
+
reject(new RemotePlayerError(code, msg));
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
logger.log(`window.cefQuery for setBlackoutTime returned query id ${queryId}`);
|
|
1623
|
+
const timeout = this._remotePlayerConfirmationTimeout + 1000;
|
|
1624
|
+
timerId = setTimeout(() => {
|
|
1625
|
+
logger.log(`setBlackoutTime reached timeout of ${timeout} ms, canceling query id ${queryId}`);
|
|
1626
|
+
window.cefQueryCancel(queryId);
|
|
1627
|
+
reject(new RemotePlayerError(6000, `setBlackoutTime reached timeout of ${timeout} ms`));
|
|
1628
|
+
}, timeout, queryId);
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
sdkLogger.error("remotePlayer setBlackoutTime: window.cefQuery is undefined");
|
|
1632
|
+
return Promise.resolve(undefined);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
resetBlackoutTime() {
|
|
1636
|
+
if (!this._isInitialized) {
|
|
1637
|
+
throw new RemotePlayerError(6500, "Cannot call resetBlackoutTime() if remote player is not initialized");
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
if (this._loadMode !== this.LoadMode.LOADED) {
|
|
1641
|
+
throw new RemotePlayerError(6001, "Cannot call resetBlackoutTime() if player is not loaded");
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
if (window.cefQuery) {
|
|
1645
|
+
const FCID = getFCID();
|
|
1646
|
+
const logger = sdkLogger.withFields({ FCID });
|
|
1647
|
+
logger.log("remotePlayer resetBlackoutTime: sending screenBlackout action");
|
|
1648
|
+
const message = {
|
|
1649
|
+
type: "remotePlayer.screenBlackout",
|
|
1650
|
+
class: "remotePlayer",
|
|
1651
|
+
action: "screenBlackout",
|
|
1652
|
+
fcid: FCID,
|
|
1653
|
+
blackoutTime: 0 // Resetting the blackout time
|
|
1654
|
+
};
|
|
1655
|
+
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
1656
|
+
return new Promise((resolve, reject) => {
|
|
1657
|
+
let timerId = 0;
|
|
1658
|
+
const timeBeforeSendingRequest = Date.now();
|
|
1659
|
+
const queryId = window.cefQuery({
|
|
1660
|
+
request: JSON.stringify(request),
|
|
1661
|
+
persistent: false,
|
|
1662
|
+
onSuccess: () => {
|
|
1663
|
+
this._blackoutTime = 0; // Resetting the blackout time
|
|
1664
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1665
|
+
logger.withFields({ duration }).log(`resetBlackoutTime completed successfully after ${duration} ms`);
|
|
1666
|
+
timerId = clearTimer(timerId);
|
|
1667
|
+
resolve();
|
|
1668
|
+
},
|
|
1669
|
+
onFailure: (code, msg) => {
|
|
1670
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1671
|
+
logger.withFields({ duration }).log(`resetBlackoutTime failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
|
|
1672
|
+
timerId = clearTimer(timerId);
|
|
1673
|
+
reject(new RemotePlayerError(code, msg));
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
logger.log(`window.cefQuery for resetBlackoutTime returned query id ${queryId}`);
|
|
1677
|
+
const timeout = this._remotePlayerConfirmationTimeout + 1000;
|
|
1678
|
+
timerId = setTimeout(() => {
|
|
1679
|
+
logger.log(`resetBlackoutTime reached timeout of ${timeout} ms, canceling query id ${queryId}`);
|
|
1680
|
+
window.cefQueryCancel(queryId);
|
|
1681
|
+
reject(new RemotePlayerError(6000, `resetBlackoutTime reached timeout of ${timeout} ms`));
|
|
1682
|
+
}, timeout, queryId);
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
sdkLogger.error("remotePlayer resetBlackoutTime: window.cefQuery is undefined");
|
|
1686
|
+
return Promise.resolve(undefined);
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1565
1689
|
/**
|
|
1566
1690
|
* Getter/Setter for currentTime
|
|
1567
1691
|
*/
|