senza-sdk 4.3.1-e113d43.0 → 4.3.1
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 +9 -8
- package/src/api.js +14 -2
- package/src/implementation/api.js +0 -4
- package/src/implementation/lifecycle.js +9 -10
- package/src/implementation/messageManager.js +0 -33
- package/src/implementation/platformManager.js +0 -19
- package/src/implementation/remotePlayer.js +17 -215
- package/src/implementation/senzaShakaPlayer.js +104 -127
- package/src/interface/alarmManager.js +29 -22
- package/src/interface/devSequence.js +35 -0
- package/src/interface/deviceManager.js +30 -20
- package/src/interface/lifecycle.js +46 -40
- package/src/interface/messageManager.js +36 -28
- package/src/interface/platformManager.js +13 -6
- package/src/interface/remotePlayer.js +208 -180
- package/src/interface/senzaShakaPlayer.js +2 -5
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "senza-sdk",
|
|
3
|
-
"version": "4.3.1
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"main": "./src/api.js",
|
|
5
5
|
"description": "API for Senza application",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,18 +46,19 @@
|
|
|
46
46
|
"global": {
|
|
47
47
|
"branches": 88,
|
|
48
48
|
"functions": 92.36,
|
|
49
|
-
"lines": 93.
|
|
50
|
-
"statements": 93.
|
|
49
|
+
"lines": 93.47,
|
|
50
|
+
"statements": 93.46
|
|
51
51
|
},
|
|
52
52
|
"src/interface": {
|
|
53
|
-
"branches":
|
|
54
|
-
"functions":
|
|
55
|
-
"lines":
|
|
56
|
-
"statements":
|
|
53
|
+
"branches": 68.42,
|
|
54
|
+
"functions": 40.74,
|
|
55
|
+
"lines": 65.96,
|
|
56
|
+
"statements": 66.32
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"shaka-player": "^4.12.5"
|
|
61
|
+
"shaka-player": "^4.12.5",
|
|
62
|
+
"moment": "^2.30.1"
|
|
62
63
|
}
|
|
63
64
|
}
|
package/src/api.js
CHANGED
|
@@ -4,6 +4,11 @@ import { Lifecycle, RemotePlayer, DeviceManager, PlatformManager, AlarmManager,
|
|
|
4
4
|
|
|
5
5
|
const { version } = pack;
|
|
6
6
|
|
|
7
|
+
typeof document !== "undefined" && document.addEventListener("keydown", (event) => {
|
|
8
|
+
sdkLogger.log(`Got ${event.key} key`);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
|
|
7
12
|
let authToken;
|
|
8
13
|
|
|
9
14
|
/** @namespace auth
|
|
@@ -193,6 +198,7 @@ export function getClientAssertion() {
|
|
|
193
198
|
|
|
194
199
|
/**
|
|
195
200
|
* @module
|
|
201
|
+
* @private
|
|
196
202
|
* @type {Lifecycle}
|
|
197
203
|
* @example
|
|
198
204
|
* import { lifecycle } from "senza-sdk";
|
|
@@ -203,6 +209,7 @@ let lifecycle;
|
|
|
203
209
|
|
|
204
210
|
/**
|
|
205
211
|
* @module
|
|
212
|
+
* @private
|
|
206
213
|
* @type {RemotePlayer}
|
|
207
214
|
* @example
|
|
208
215
|
* import { init, remotePlayer } from "senza-sdk";
|
|
@@ -221,6 +228,7 @@ let remotePlayer;
|
|
|
221
228
|
|
|
222
229
|
/**
|
|
223
230
|
* @module
|
|
231
|
+
* @private
|
|
224
232
|
* @type {AlarmManager}
|
|
225
233
|
* @example
|
|
226
234
|
* import { alarmManager } from "senza-sdk";
|
|
@@ -231,6 +239,7 @@ let alarmManager;
|
|
|
231
239
|
|
|
232
240
|
/**
|
|
233
241
|
* @module
|
|
242
|
+
* @private
|
|
234
243
|
* @type {DeviceManager}
|
|
235
244
|
* @example
|
|
236
245
|
* import { deviceManager } from "senza-sdk";
|
|
@@ -246,6 +255,7 @@ let deviceManager;
|
|
|
246
255
|
|
|
247
256
|
/**
|
|
248
257
|
* @module
|
|
258
|
+
* @private
|
|
249
259
|
* @type {PlatformManager}
|
|
250
260
|
* @example
|
|
251
261
|
* import { platformManager } from "senza-sdk";
|
|
@@ -254,11 +264,11 @@ let deviceManager;
|
|
|
254
264
|
*
|
|
255
265
|
* @return {PlatformManager} pointer to the PlatformManager singleton
|
|
256
266
|
*/
|
|
257
|
-
|
|
258
|
-
|
|
259
267
|
let platformManager;
|
|
268
|
+
|
|
260
269
|
/**
|
|
261
270
|
* @module
|
|
271
|
+
* @private
|
|
262
272
|
* @type {MessageManager}
|
|
263
273
|
* @example
|
|
264
274
|
* import { MessageManager } from "senza-sdk";
|
|
@@ -272,6 +282,7 @@ let messageManager;
|
|
|
272
282
|
* ShakaPlayer subclass of Shaka that handles both local and remote playback.
|
|
273
283
|
*
|
|
274
284
|
* @class ShakaPlayer
|
|
285
|
+
* @private
|
|
275
286
|
* @type {new|ShakaPlayer}
|
|
276
287
|
* @example
|
|
277
288
|
* import { ShakaPlayer } from "senza-sdk";
|
|
@@ -291,6 +302,7 @@ let ShakaPlayerImplementation;
|
|
|
291
302
|
|
|
292
303
|
/**
|
|
293
304
|
* @module
|
|
305
|
+
* @private
|
|
294
306
|
* @type {shaka}
|
|
295
307
|
*/
|
|
296
308
|
let shakaImplementation;
|
|
@@ -8,10 +8,6 @@ let authToken;
|
|
|
8
8
|
const API_VERSION = "1.0";
|
|
9
9
|
let interfaceVersion;
|
|
10
10
|
|
|
11
|
-
typeof document !== "undefined" && document.addEventListener("keydown", (event) => {
|
|
12
|
-
sdkLogger.log(`Got ${event.key} key`);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
11
|
/** @namespace auth
|
|
16
12
|
*@example
|
|
17
13
|
* import { auth } from "senza-sdk";
|
|
@@ -20,12 +20,6 @@ const DEFAULT_AUTO_BACKGROUND_VIDEO_DELAY = 30;
|
|
|
20
20
|
const DEFAULT_AUTO_BACKGROUND_UI_DELAY = -1;
|
|
21
21
|
const DEFAULT_AUTO_BACKGROUND_ENABLED = false;
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Lifecycle is a singleton class that manages the application lifecycle states.<br>
|
|
25
|
-
* @fires onstatechange
|
|
26
|
-
* @fires userinactivity
|
|
27
|
-
* @fires userdisconnected
|
|
28
|
-
*/
|
|
29
23
|
class Lifecycle extends LifecycleInterface {
|
|
30
24
|
constructor() {
|
|
31
25
|
super();
|
|
@@ -112,7 +106,8 @@ class Lifecycle extends LifecycleInterface {
|
|
|
112
106
|
});
|
|
113
107
|
}
|
|
114
108
|
|
|
115
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* @private Initialize the lifecycle
|
|
116
111
|
* @param {Object} uiStreamerSettings - UI-streamer portion of the settings taken from session info
|
|
117
112
|
* @param {Object} [uiStreamerSettings.autoBackground] - Auto background mode configuration
|
|
118
113
|
* @param {boolean} [uiStreamerSettings.autoBackground.enabled=false] - Enable/disable auto background
|
|
@@ -209,14 +204,16 @@ class Lifecycle extends LifecycleInterface {
|
|
|
209
204
|
}
|
|
210
205
|
}
|
|
211
206
|
|
|
212
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* @private Checks if auto background is enabled including overrides.
|
|
213
209
|
* @returns {boolean}
|
|
214
210
|
*/
|
|
215
211
|
_isAutoBackgroundEnabled() {
|
|
216
212
|
return this._autoBackgroundOverrides?.enabled ?? this._autoBackground;
|
|
217
213
|
}
|
|
218
214
|
|
|
219
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* @private Gets the auto background video delay including overrides.
|
|
220
217
|
* @returns {number}
|
|
221
218
|
*/
|
|
222
219
|
_getAutoBackgroundOnVideoDelay() {
|
|
@@ -227,7 +224,8 @@ class Lifecycle extends LifecycleInterface {
|
|
|
227
224
|
return this._autoBackgroundOnVideoDelay;
|
|
228
225
|
}
|
|
229
226
|
|
|
230
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* @private Gets the auto background UI delay including overrides.
|
|
231
229
|
* @returns {number}
|
|
232
230
|
*/
|
|
233
231
|
_getAutoBackgroundOnUIDelay() {
|
|
@@ -290,6 +288,7 @@ class Lifecycle extends LifecycleInterface {
|
|
|
290
288
|
}
|
|
291
289
|
|
|
292
290
|
/**
|
|
291
|
+
* @private
|
|
293
292
|
* This method moves the application into standby mode, i.e. last ui frame is displayed and ui resources are released.
|
|
294
293
|
* It should be called whenever the application wishes to go into standby mode and release resources.
|
|
295
294
|
* @example
|
|
@@ -1,35 +1,8 @@
|
|
|
1
1
|
import { MessageManager as MessageManagerInterface } from "../interface/messageManager";
|
|
2
2
|
import { getFCID, sdkLogger } from "./utils";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* MessageManager is a singleton class that manages the external messages received by the application. It fires custom events as "message" with the payload as the content
|
|
6
|
-
* @fires MessageManager#message
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
4
|
class MessageManager extends MessageManagerInterface {
|
|
10
5
|
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {object} MessageDetails - object which contains the content of the message
|
|
13
|
-
* @property {string} eventName - The name of the event message, a property of MessageDetails
|
|
14
|
-
* @property {object} payload - The payload for this event, a property of MessageDetails
|
|
15
|
-
* @property {string} fcid - The flow context for this message, a property of MessageDetails
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* message event
|
|
20
|
-
*
|
|
21
|
-
* @event MessageManager#message
|
|
22
|
-
* @type {CustomEvent}
|
|
23
|
-
* @property {MessageDetails} detail - object containing data related to the event:
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* @description Fired when an external event arrives. This is a generic handler for all messages received for any registered group <br>
|
|
27
|
-
* @example
|
|
28
|
-
* messageManager.addEventListener("message", (e) => {
|
|
29
|
-
* console.log("message arrived with data", e.detail);
|
|
30
|
-
* });
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
6
|
constructor() {
|
|
34
7
|
super();
|
|
35
8
|
typeof document !== "undefined" && document.addEventListener("hs/externalEvent", (e) => {
|
|
@@ -38,12 +11,6 @@ class MessageManager extends MessageManagerInterface {
|
|
|
38
11
|
});
|
|
39
12
|
}
|
|
40
13
|
|
|
41
|
-
/** Register to specific group(s). This function replaces the previously registered groups
|
|
42
|
-
* @param {Array<String>} groups group events to receive messages.
|
|
43
|
-
* @return {Promise} Promise which is resolved when the registerGroups command has been successfully processed.
|
|
44
|
-
* Failure to process the registerGroups command will result in the promise being rejected.
|
|
45
|
-
* messageManager.registerGroups(["A","B"]);
|
|
46
|
-
* */
|
|
47
14
|
async registerGroups(groups) {
|
|
48
15
|
sdkLogger.log(`register called for ${groups}`);
|
|
49
16
|
return new Promise((resolve, reject) => {
|
|
@@ -2,24 +2,12 @@ import { PlatformManager as PlatformManagerInterface } from "../interface/platfo
|
|
|
2
2
|
import { sdkLogger } from "./utils";
|
|
3
3
|
import { sessionInfo } from "./SessionInfo";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* PlatformManager is a singleton class that manages the platform
|
|
8
|
-
*/
|
|
9
5
|
class PlatformManager extends PlatformManagerInterface {
|
|
10
6
|
|
|
11
7
|
constructor() {
|
|
12
8
|
super();
|
|
13
9
|
}
|
|
14
10
|
|
|
15
|
-
/**
|
|
16
|
-
* @returns {Object} appConfig object
|
|
17
|
-
* @property {String[]} territories - a list of territories configured for the tenant.
|
|
18
|
-
* if the list is undefined or empty - there are no restrictions.
|
|
19
|
-
* @example
|
|
20
|
-
* import { platformManager } from "senza-sdk";
|
|
21
|
-
* const appConfig = platformManager.appConfig
|
|
22
|
-
* */
|
|
23
11
|
get appConfig() {
|
|
24
12
|
const sessionInfoObj = sessionInfo.sessionInfoObj;
|
|
25
13
|
const appConfig = sessionInfoObj.homeSessionInfo?.["appConfig"] || {};
|
|
@@ -27,13 +15,6 @@ class PlatformManager extends PlatformManagerInterface {
|
|
|
27
15
|
return appConfig;
|
|
28
16
|
}
|
|
29
17
|
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {string} timezone the timezone to set to
|
|
33
|
-
* the format of the timezone is according to the standard TZ identifier
|
|
34
|
-
* (e.g. America/Los_Angeles, Asia/Tokyo, Europe/Brussels)
|
|
35
|
-
* for a full list of TZ identifiers, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
36
|
-
*/
|
|
37
18
|
setTimezone(timezone) {
|
|
38
19
|
if (window.cefQuery) {
|
|
39
20
|
const request = { message: JSON.stringify({ type: "setTimeZone", timezone }), waitForResponse: false, target: "UI-Streamer" };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line no-unused-vars
|
|
2
|
+
import { RemotePlayer as RemotePlayerInterface, RemotePlayerError as RemotePlayerErrorInterface, Config } from "../interface/remotePlayer";
|
|
2
3
|
import {
|
|
3
4
|
getFCID,
|
|
4
5
|
isAudioSyncConfigured,
|
|
@@ -28,11 +29,7 @@ const cloneDeep = (element) => {
|
|
|
28
29
|
return JSON.parse(JSON.stringify(element));
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
/** Error object to be thrown on remotePlayer api failures.
|
|
33
|
-
* [See error list]{@link RemotePlayer#error}
|
|
34
|
-
*/
|
|
35
|
-
export class RemotePlayerError extends Error {
|
|
32
|
+
export class RemotePlayerError extends RemotePlayerErrorInterface {
|
|
36
33
|
constructor(code, message) {
|
|
37
34
|
super(message);
|
|
38
35
|
this.code = code;
|
|
@@ -64,25 +61,6 @@ function setPlaybackInfo(playbackInfo) {
|
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @typedef {Object} Config
|
|
70
|
-
* @property {string} preferredAudioLanguage
|
|
71
|
-
* @property {string} preferredSubtitlesLanguage
|
|
72
|
-
* @property {boolean} autoPlay - (Not implemented yet) upon loading start playing automatically
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* RemotePlayer a singleton class to communicate with remote player
|
|
77
|
-
* @fires timeupdate
|
|
78
|
-
* @fires tracksupdate
|
|
79
|
-
* @fires ended
|
|
80
|
-
* @fires error
|
|
81
|
-
* @fires onloadmodechange
|
|
82
|
-
* @fires seeking (Not implemented yet)
|
|
83
|
-
* @fires seeked (Not implemented yet)
|
|
84
|
-
* @fires loadedmetadata (Not implemented yet)
|
|
85
|
-
*/
|
|
86
64
|
class RemotePlayer extends RemotePlayerInterface {
|
|
87
65
|
constructor() {
|
|
88
66
|
super();
|
|
@@ -92,7 +70,8 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
92
70
|
*/
|
|
93
71
|
this._config = {
|
|
94
72
|
preferredAudioLanguage: "",
|
|
95
|
-
preferredSubtitlesLanguage: ""
|
|
73
|
+
preferredSubtitlesLanguage: "",
|
|
74
|
+
minSuggestedPresentationDelay: 0
|
|
96
75
|
};
|
|
97
76
|
/**
|
|
98
77
|
* @type {string}
|
|
@@ -162,49 +141,11 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
162
141
|
*/
|
|
163
142
|
this._isPlaying = false;
|
|
164
143
|
|
|
165
|
-
/**
|
|
166
|
-
* @event RemotePlayer#canplay
|
|
167
|
-
* @description canplay event will be dispatched when the remote player can start play the event
|
|
168
|
-
* @example
|
|
169
|
-
* remotePlayer.addEventListener("canplay", () => {
|
|
170
|
-
* console.info("remotePlayer canplay");
|
|
171
|
-
* remotePlayer.play();
|
|
172
|
-
* });
|
|
173
|
-
* */
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* @event RemotePlayer#playing
|
|
177
|
-
* @description playing event will be dispatched when the remote player started playback of the first audio frame. This event can be used to synchronize the local player with the remote player.
|
|
178
|
-
* @example
|
|
179
|
-
* remotePlayer.addEventListener("playing", () => {
|
|
180
|
-
* console.info("remotePlayer playing");
|
|
181
|
-
* });
|
|
182
|
-
* */
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @event RemotePlayer#loadedmetadata
|
|
186
|
-
* @description loadedmetadata event will be dispatched when the remote player metadata is loaded
|
|
187
|
-
* and the audio/video tracks are available
|
|
188
|
-
* @example
|
|
189
|
-
* remotePlayer.addEventListener("loadedmetadata", () => {
|
|
190
|
-
* console.info("remotePlayer loadedmetadata", remotePlayer.getAudioTracks(), remotePlayer.getTextTracks());
|
|
191
|
-
* });
|
|
192
|
-
* */
|
|
193
144
|
typeof document !== "undefined" && document.addEventListener("hs/remotePlayerEvent", (e) => {
|
|
194
145
|
sdkLogger.info("Got hs/remotePlayerEvent event with detail", JSON.stringify(e?.detail));
|
|
195
146
|
this.dispatchEvent(new Event(e?.detail?.eventName));
|
|
196
147
|
});
|
|
197
148
|
|
|
198
|
-
/**
|
|
199
|
-
*
|
|
200
|
-
* @event RemotePlayer#timeupdate
|
|
201
|
-
* @example
|
|
202
|
-
* remotePlayer.addEventListener("timeupdate", () => {
|
|
203
|
-
* console.info("remotePlayer timeupdate", remotePlayer.currentTime);
|
|
204
|
-
* localPlayer.getMediaElement().currentTime = remotePlayer.currentTime || 0;
|
|
205
|
-
* });
|
|
206
|
-
*
|
|
207
|
-
*/
|
|
208
149
|
typeof document !== "undefined" && document.addEventListener("hs/playbackInfoEvent", () => {
|
|
209
150
|
sdkLogger.info("Got hs/playbackInfoEvent");
|
|
210
151
|
// When attached, the sdk controls the synchronization between the local and remote player.
|
|
@@ -218,15 +159,6 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
218
159
|
}
|
|
219
160
|
});
|
|
220
161
|
|
|
221
|
-
/**
|
|
222
|
-
*
|
|
223
|
-
* @event RemotePlayer#tracksupdate
|
|
224
|
-
* @example
|
|
225
|
-
* remotePlayer.addEventListener("tracksupdate", () => {
|
|
226
|
-
* console.info("remotePlayer tracksupdate", remotePlayer.getAudioTracks(), remotePlayer.getTextTracks());
|
|
227
|
-
* });
|
|
228
|
-
*
|
|
229
|
-
*/
|
|
230
162
|
typeof document !== "undefined" && document.addEventListener("hs/playback", (e) => {
|
|
231
163
|
sdkLogger.info("Got hs/playback event with detail", JSON.stringify(e?.detail));
|
|
232
164
|
this._availabilityStartTime = e?.detail?.availabilityStartTime;
|
|
@@ -234,13 +166,6 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
234
166
|
this.dispatchEvent(new Event("tracksupdate"));
|
|
235
167
|
});
|
|
236
168
|
|
|
237
|
-
/**
|
|
238
|
-
* @event RemotePlayer#ended
|
|
239
|
-
* @example
|
|
240
|
-
* remotePlayer.addEventListener("ended", () => {
|
|
241
|
-
* console.info("remotePlayer ended");
|
|
242
|
-
* });
|
|
243
|
-
*/
|
|
244
169
|
typeof document !== "undefined" && document.addEventListener("hs/EOS", () => {
|
|
245
170
|
sdkLogger.info("Got hs/EOS event");
|
|
246
171
|
this.dispatchEvent(new Event("ended"));
|
|
@@ -273,72 +198,7 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
273
198
|
sdkLogger.info(`Adding ${event.detail} seconds, previousTime=${previousCurrentTime} currentTime=${this._videoElement.currentTime}`);
|
|
274
199
|
});
|
|
275
200
|
|
|
276
|
-
|
|
277
|
-
*
|
|
278
|
-
* @event RemotePlayer#error
|
|
279
|
-
* @type {object}
|
|
280
|
-
* @property {int} detail.errorCode
|
|
281
|
-
* @property {string} detail.message
|
|
282
|
-
*
|
|
283
|
-
* @see Possible error codes:
|
|
284
|
-
*
|
|
285
|
-
* | Code | Domain | Description |
|
|
286
|
-
* | :-------- | :---------------- | :-----------------------------------------------------------------------------------------------|
|
|
287
|
-
* | 23 | Player | load() failed due to remote player initialization error |
|
|
288
|
-
* | 98 | Player | load() failed due to remote player failure to send message to the client |
|
|
289
|
-
* | 99 | Player | load() failed due to remote player reporting invalid message |
|
|
290
|
-
* | 1000 | Encrypted content | Failed to create or initialise the CDM |
|
|
291
|
-
* | 1001 | Encrypted content | Failed to create a CDM session |
|
|
292
|
-
* | 1002 | Encrypted content | CDM failed to generate a license request |
|
|
293
|
-
* | 1003 | Encrypted content | The CDM rejected the license server response |
|
|
294
|
-
* | 1004 | Encrypted content | The CDM rejected the license server certificate |
|
|
295
|
-
* | 1005 | Encrypted content | All keys in the license have expired |
|
|
296
|
-
* | 1006 | Encrypted content | Output device is incompatible with the license requirements (HDCP) |
|
|
297
|
-
* | 1007 | Encrypted content | The device has been revoked |
|
|
298
|
-
* | 1008 | Encrypted content | The device secrets aren't available |
|
|
299
|
-
* | 1009 | Encrypted content | Keys are loaded but the KID requested by playback isn't found. The app has likely issued a license for the wrong content or there is a mismatch between the KIDs in the license and the data plane |
|
|
300
|
-
* | 1010 | Encrypted content | The CDM failed to provision, therefore it is not possible to play encrypted content |
|
|
301
|
-
* | 1100 | Encrypted content | The CDM session has already received a license response. The app has likely issued 2, or more, license responses for the same request. The subsequent licenses will be ignored so this error is informational only |
|
|
302
|
-
* | 1101 | Encrypted content | The license has been rejected since an error was received by the CDM. The app has likely sent a non-200 code to `WriteLicenseResponse` |
|
|
303
|
-
* | 1102 | Encrypted content | A license response wasn't received from the app within a pre-defined timeout |
|
|
304
|
-
* | 1103 | Encrypted content | The CDM session associated with this license response is in an invalid state. This is an internal Senza platform error |
|
|
305
|
-
* | 1104 | Encrypted content | The CDM failed to send a license request to the app. This is an internal Senza platform error |
|
|
306
|
-
* | 1999 | Encrypted content | An unknown encrypted content error |
|
|
307
|
-
* | 2000 | Player | Content makes reference to no or unsupported key system |
|
|
308
|
-
* | 3000 | Player | Unexpected problem with playback, only used if no more specific code in 3xxx range applies |
|
|
309
|
-
* | 3001 | Player | Problem accessing content manifest, only used if no more specific code in 8xxx range applies |
|
|
310
|
-
* | 3002 | Player | Unexpectedly stopped playback |
|
|
311
|
-
* | 3100 | Player | Problem parsing MP4 content |
|
|
312
|
-
* | 3200 | Player | Problem with decoder |
|
|
313
|
-
* | 3300 | Player | DRM keys unavailable, player waited for keys but none arrived |
|
|
314
|
-
* | 3400 | Player | Problem accessing segments, only used if no more specific code in 34xx range applies |
|
|
315
|
-
* | 3401 | Player | Problem accessing segments, connection issue or timeout |
|
|
316
|
-
* | 3402 | Player | Problem accessing segments, server returned HTTP error code |
|
|
317
|
-
* | 3403 | Player | Problem accessing segments, server authentication issue |
|
|
318
|
-
* | 3404 | Player | Problem accessing segments, server returned not found |
|
|
319
|
-
* | 3900-3999 | Player | Internal player error |
|
|
320
|
-
* | 6000 | Player | The remote player api call has reached the configurable timeout with no response from the remote player |
|
|
321
|
-
* | 6001 | Player | play() was called while the remote player is not loaded |
|
|
322
|
-
* | 6002 | Player | load() was called while the application was in state 'background' or 'inTransitionToBackground' |
|
|
323
|
-
* | 6500 | Player | remotePlayer api was called before initializing remotePlayer |
|
|
324
|
-
* | 6501 | Player | load() was called while previous load/unload was still in progress |
|
|
325
|
-
* | 6502 | Player | unload() was called while previous unload/load was still in progress |
|
|
326
|
-
* | 8001 | Player | Error pulling manifest. bad parameters |
|
|
327
|
-
* | 8002 | Player | Error pulling manifest. filters returned no data |
|
|
328
|
-
* | 8003 | Player | Error pulling manifest. fetch error |
|
|
329
|
-
* | 8004 | Player | Error pulling manifest. parse error |
|
|
330
|
-
* | 8005 | Player | Error pulling manifest. stale manifest detected |
|
|
331
|
-
* | 8006 | Player | Error updating manifest. internal cache error |
|
|
332
|
-
* | 8007 | Player | Error updating manifest. internal error during backoff |
|
|
333
|
-
* | 8008 | Player | Error pulling manifest. sidx parsing error |
|
|
334
|
-
* | 8009 | Player | Error pulling manifest. internal error |
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* remotePlayer.addEventListener("error", (event) => {
|
|
338
|
-
* console.error("received remotePlayer error:", event.detail.errorCode, event.detail.message);
|
|
339
|
-
* });
|
|
340
|
-
*
|
|
341
|
-
*/
|
|
201
|
+
|
|
342
202
|
typeof document !== "undefined" && document.addEventListener("hs/ERR", (event) => {
|
|
343
203
|
sdkLogger.info("Got hs/ERR event");
|
|
344
204
|
delete event?.detail?.type; // type is always videoPlaybackEvent, so no need to pass it
|
|
@@ -346,58 +206,6 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
346
206
|
this.dispatchEvent(new CustomEvent("error", event));
|
|
347
207
|
});
|
|
348
208
|
|
|
349
|
-
/**
|
|
350
|
-
*
|
|
351
|
-
* @event RemotePlayer#license-request
|
|
352
|
-
* @description Fired whenever the platform requires a license to play encrypted content.
|
|
353
|
-
* The Web App is responsible for passing the (opaque) license request blob to the license server and passing the (opaque) license server response to the CDM by calling the `writeLicenseResponse` method on the event.
|
|
354
|
-
* @type {LicenseRequestEvent}
|
|
355
|
-
* @property {object} detail - Object containing ievent data
|
|
356
|
-
* @property {string} detail.licenseRequest - Base64 coded opaque license request. The app is responsible for decoding the request before sending to the license server. Note that after decoding, the request may still be in Base64 form and this form should be sent to the license server without further decoding
|
|
357
|
-
* @property {writeLicenseResponse} writeLicenseResponse - Write the license server response to the platform
|
|
358
|
-
* @example
|
|
359
|
-
* Whilst the payload structure and access controls are specific to each license server implementation, the Widevine UAT license server requires no authentication and minimal payload formatting and therefore serves as a useful case study that may be adapted.
|
|
360
|
-
*
|
|
361
|
-
* remotePlayer.addEventListener("license-request", async (event) => {
|
|
362
|
-
* console.log("Got license-request event");
|
|
363
|
-
* const requestBuffer = event?.detail?.licenseRequest;
|
|
364
|
-
* const requestBufferStr = String.fromCharCode.apply(null, new Uint8Array(requestBuffer));
|
|
365
|
-
* console.log("License Request in base64:", requestBufferStr);
|
|
366
|
-
* const decodedLicenseRequest = window.atob(requestBufferStr); // from base 64
|
|
367
|
-
* const licenseRequestBytes = Uint8Array.from(decodedLicenseRequest, (l) => l.charCodeAt(0));
|
|
368
|
-
* // call Google API
|
|
369
|
-
* const res = await getLicenseFromServer(licenseRequestBytes.buffer);
|
|
370
|
-
* console.log("Writing response to platform ", res.code, res.responseBody);
|
|
371
|
-
* event.writeLicenseResponse(res.code, res.responseBody);
|
|
372
|
-
* });
|
|
373
|
-
|
|
374
|
-
* async function getLicenseFromServer(licenseRequest) {
|
|
375
|
-
* console.log("Requesting License from Widevine server");
|
|
376
|
-
* const response = await fetch("https://proxy.uat.widevine.com/proxy", {
|
|
377
|
-
* "method": "POST",
|
|
378
|
-
* "body": licenseRequest,
|
|
379
|
-
* "headers" : {
|
|
380
|
-
* "Content-Type": "application/octet-stream"
|
|
381
|
-
* }
|
|
382
|
-
* });
|
|
383
|
-
* const code = response.status;
|
|
384
|
-
* if (code !== 200) {
|
|
385
|
-
* console.error("failed to to get response from widevine:", code);
|
|
386
|
-
* const responseBody = await response.text();
|
|
387
|
-
* console.error(responseBody);
|
|
388
|
-
* return {code, responseBody};
|
|
389
|
-
* }
|
|
390
|
-
* const responseBody = await response.arrayBuffer();
|
|
391
|
-
* console.info("Got response: ");
|
|
392
|
-
* return {code, responseBody};
|
|
393
|
-
* }
|
|
394
|
-
**/
|
|
395
|
-
/**
|
|
396
|
-
* @function writeLicenseResponse
|
|
397
|
-
* @param {number} statusCode - License server HTTP response code, e.g. 200, 401, etc. Must be 200 to indicate a successful license exchange.
|
|
398
|
-
* @param {string} response - License server response as opaque binary data in an ArrayBuffer.
|
|
399
|
-
*
|
|
400
|
-
* */
|
|
401
209
|
typeof document !== "undefined" && document.addEventListener("hs/getLicense", (event) => {
|
|
402
210
|
sdkLogger.info("Got hs/getLicense event");
|
|
403
211
|
const getLicenseEventData = event?.detail;
|
|
@@ -417,20 +225,6 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
417
225
|
});
|
|
418
226
|
}
|
|
419
227
|
|
|
420
|
-
/**
|
|
421
|
-
* @typedef {Object} LoadMode
|
|
422
|
-
* @property {string} NOT_LOADED
|
|
423
|
-
* @property {string} LOADING
|
|
424
|
-
* @property {string} LOADED
|
|
425
|
-
* @property {string} UNLOADING
|
|
426
|
-
*/
|
|
427
|
-
LoadMode = Object.freeze({
|
|
428
|
-
NOT_LOADED: "notLoaded",
|
|
429
|
-
LOADING: "loading",
|
|
430
|
-
LOADED: "loaded",
|
|
431
|
-
UNLOADING: "unloading"
|
|
432
|
-
});
|
|
433
|
-
|
|
434
228
|
/** @private Initialize the remote player
|
|
435
229
|
* @param {Object} uiStreamerSettings ui-streamer portion of the settings taken from session info
|
|
436
230
|
* */
|
|
@@ -525,10 +319,10 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
525
319
|
|
|
526
320
|
/** setting values for properties in the player configuration using an object.
|
|
527
321
|
* If the config does not support a property this is a no-op.
|
|
528
|
-
* @param {
|
|
322
|
+
* @param {Config} props the object with all the different properties to change.
|
|
529
323
|
* @example
|
|
530
324
|
* remotePlayer.configure({ preferredAudioLanguage: 'en-US' })
|
|
531
|
-
*
|
|
325
|
+
* remotePlayer.configure({ minSuggestedPresentationDelay: 6 })
|
|
532
326
|
* */
|
|
533
327
|
configure(props) {
|
|
534
328
|
Object.entries(props).forEach(([key, value]) => {
|
|
@@ -897,6 +691,9 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
897
691
|
this._updateSeekListeners(video);
|
|
898
692
|
}
|
|
899
693
|
this._videoElement = video;
|
|
694
|
+
|
|
695
|
+
// Emit a custom event to notify about the attachment of the video element
|
|
696
|
+
this.dispatchEvent(new Event("videoelementattached"));
|
|
900
697
|
}
|
|
901
698
|
}
|
|
902
699
|
|
|
@@ -912,7 +709,7 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
912
709
|
/** Tell the remote player to load the given URL.
|
|
913
710
|
* @param {string} url url to load
|
|
914
711
|
* @param {number} [position] start position in seconds (if not provided, start from beginning (VOD) or current time (LTV))
|
|
915
|
-
|
|
712
|
+
* @returns {Promise}
|
|
916
713
|
* @throws {RemotePlayerError} error object contains code & msg
|
|
917
714
|
*
|
|
918
715
|
* */
|
|
@@ -977,6 +774,11 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
977
774
|
message.action = "load";
|
|
978
775
|
message.audioLanguage = audioLanguage;
|
|
979
776
|
message.subtitlesLanguage = subtitlesLanguage;
|
|
777
|
+
if (this.getConfiguration().minSuggestedPresentationDelay > 0) {
|
|
778
|
+
message.cloudPlayerParams = {
|
|
779
|
+
"mspd": this.getConfiguration().minSuggestedPresentationDelay
|
|
780
|
+
};
|
|
781
|
+
}
|
|
980
782
|
} else {
|
|
981
783
|
message.type = "setPlayableUri";
|
|
982
784
|
}
|