senza-sdk 4.2.64 → 4.2.65-4527e57.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 +123 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "senza-sdk",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.65-4527e57.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
|
|
@@ -951,6 +958,7 @@ class RemotePlayer extends EventTarget {
|
|
|
951
958
|
this._abortSetAudioLanguage = true;
|
|
952
959
|
this._abortSetSubtitleLanguage = true;
|
|
953
960
|
this._abortSeeking = true;
|
|
961
|
+
this._blackoutTime = 0;
|
|
954
962
|
if (reset) {
|
|
955
963
|
this._reset();
|
|
956
964
|
}
|
|
@@ -1562,6 +1570,121 @@ class RemotePlayer extends EventTarget {
|
|
|
1562
1570
|
}
|
|
1563
1571
|
}
|
|
1564
1572
|
|
|
1573
|
+
setBlackoutTime(date) {
|
|
1574
|
+
|
|
1575
|
+
if (!this._isInitialized) {
|
|
1576
|
+
throw new RemotePlayerError(6500, "Cannot call setBlackoutTime() if remote player is not initialized");
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
if (this._loadMode !== this.LoadMode.LOADED) {
|
|
1580
|
+
throw new RemotePlayerError(6001, "Cannot call setBlackoutTime() if player is not loaded");
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
if (!(date instanceof Date)) {
|
|
1584
|
+
throw new TypeError("blackoutTime must be a Date object"); // remotePlayer error
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
const blackoutTime = (date.getTime()/1000).toFixed(2)
|
|
1588
|
+
if (window.cefQuery) {
|
|
1589
|
+
const FCID = getFCID();
|
|
1590
|
+
const logger = sdkLogger.withFields({ FCID });
|
|
1591
|
+
logger.log("remotePlayer setBlackoutTime: sending screenBlackout action");
|
|
1592
|
+
const message = {
|
|
1593
|
+
type: "remotePlayer.screenBlackout",
|
|
1594
|
+
class: "remotePlayer",
|
|
1595
|
+
action: "screenBlackout",
|
|
1596
|
+
fcid: FCID,
|
|
1597
|
+
blackoutTime
|
|
1598
|
+
};
|
|
1599
|
+
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
1600
|
+
return new Promise((resolve, reject) => {
|
|
1601
|
+
let timerId = 0;
|
|
1602
|
+
const timeBeforeSendingRequest = Date.now();
|
|
1603
|
+
const queryId = window.cefQuery({
|
|
1604
|
+
request: JSON.stringify(request),
|
|
1605
|
+
persistent: false,
|
|
1606
|
+
onSuccess: () => {
|
|
1607
|
+
this._blackoutTime = blackoutTime;
|
|
1608
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1609
|
+
logger.withFields({ duration }).log(`setBlackoutTime completed successfully after ${duration} ms`);
|
|
1610
|
+
timerId = clearTimer(timerId);
|
|
1611
|
+
resolve();
|
|
1612
|
+
},
|
|
1613
|
+
onFailure: (code, msg) => {
|
|
1614
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1615
|
+
logger.withFields({ duration }).log(`setBlackoutTime failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
|
|
1616
|
+
timerId = clearTimer(timerId);
|
|
1617
|
+
reject(new RemotePlayerError(code, msg));
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
|
|
1621
|
+
logger.log(`window.cefQuery for setBlackoutTime returned query id ${queryId}`);
|
|
1622
|
+
const timeout = this._remotePlayerConfirmationTimeout + 1000;
|
|
1623
|
+
timerId = setTimeout(() => {
|
|
1624
|
+
logger.log(`setBlackoutTime reached timeout of ${timeout} ms, canceling query id ${queryId}`);
|
|
1625
|
+
window.cefQueryCancel(queryId);
|
|
1626
|
+
reject(new RemotePlayerError(6000, `setBlackoutTime reached timeout of ${timeout} ms`));
|
|
1627
|
+
}, timeout, queryId);
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
sdkLogger.error("remotePlayer setBlackoutTime: window.cefQuery is undefined");
|
|
1631
|
+
return Promise.resolve(undefined);
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
resetBlackoutTime() {
|
|
1635
|
+
if (!this._isInitialized) {
|
|
1636
|
+
throw new RemotePlayerError(6500, "Cannot call resetBlackoutTime() if remote player is not initialized");
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
if (this._loadMode !== this.LoadMode.LOADED) {
|
|
1640
|
+
throw new RemotePlayerError(6001, "Cannot call resetBlackoutTime() if player is not loaded");
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
if (window.cefQuery) {
|
|
1644
|
+
const FCID = getFCID();
|
|
1645
|
+
const logger = sdkLogger.withFields({ FCID });
|
|
1646
|
+
logger.log("remotePlayer resetBlackoutTime: sending screenBlackout action");
|
|
1647
|
+
const message = {
|
|
1648
|
+
type: "remotePlayer.screenBlackout",
|
|
1649
|
+
class: "remotePlayer",
|
|
1650
|
+
action: "screenBlackout",
|
|
1651
|
+
fcid: FCID,
|
|
1652
|
+
blackoutTime: 0 // Resetting the blackout time
|
|
1653
|
+
};
|
|
1654
|
+
const request = { target: "TC", waitForResponse: true, message: JSON.stringify(message) };
|
|
1655
|
+
return new Promise((resolve, reject) => {
|
|
1656
|
+
let timerId = 0;
|
|
1657
|
+
const timeBeforeSendingRequest = Date.now();
|
|
1658
|
+
const queryId = window.cefQuery({
|
|
1659
|
+
request: JSON.stringify(request),
|
|
1660
|
+
persistent: false,
|
|
1661
|
+
onSuccess: () => {
|
|
1662
|
+
this._blackoutTime = 0; // Resetting the blackout time
|
|
1663
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1664
|
+
logger.withFields({ duration }).log(`resetBlackoutTime completed successfully after ${duration} ms`);
|
|
1665
|
+
timerId = clearTimer(timerId);
|
|
1666
|
+
resolve();
|
|
1667
|
+
},
|
|
1668
|
+
onFailure: (code, msg) => {
|
|
1669
|
+
const duration = Date.now() - timeBeforeSendingRequest;
|
|
1670
|
+
logger.withFields({ duration }).log(`resetBlackoutTime failed after ${duration} ms. Error code: ${code}, error message: ${msg}`);
|
|
1671
|
+
timerId = clearTimer(timerId);
|
|
1672
|
+
reject(new RemotePlayerError(code, msg));
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
logger.log(`window.cefQuery for resetBlackoutTime returned query id ${queryId}`);
|
|
1676
|
+
const timeout = this._remotePlayerConfirmationTimeout + 1000;
|
|
1677
|
+
timerId = setTimeout(() => {
|
|
1678
|
+
logger.log(`resetBlackoutTime reached timeout of ${timeout} ms, canceling query id ${queryId}`);
|
|
1679
|
+
window.cefQueryCancel(queryId);
|
|
1680
|
+
reject(new RemotePlayerError(6000, `resetBlackoutTime reached timeout of ${timeout} ms`));
|
|
1681
|
+
}, timeout, queryId);
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
sdkLogger.error("remotePlayer resetBlackoutTime: window.cefQuery is undefined");
|
|
1685
|
+
return Promise.resolve(undefined);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1565
1688
|
/**
|
|
1566
1689
|
* Getter/Setter for currentTime
|
|
1567
1690
|
*/
|