@reveldigital/player-client 1.0.15 → 2.0.2
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/README.md +236 -236
- package/esm2022/lib/app-init.service.mjs +113 -0
- package/esm2022/lib/interfaces/client.interface.mjs +2 -0
- package/esm2022/lib/interfaces/command.interface.mjs +2 -0
- package/esm2022/lib/interfaces/config.interface.mjs +50 -0
- package/esm2022/lib/interfaces/device.interface.mjs +2 -0
- package/esm2022/lib/interfaces/event-properties.interface.mjs +2 -0
- package/esm2022/lib/interfaces/location.interface.mjs +2 -0
- package/esm2022/lib/player-client.module.mjs +71 -0
- package/esm2022/lib/player-client.service.mjs +928 -0
- package/esm2022/lib/safe-style.pipe.mjs +41 -0
- package/{esm2020 → esm2022}/lib/version.mjs +3 -3
- package/{esm2020 → esm2022}/public-api.mjs +6 -6
- package/{esm2020 → esm2022}/reveldigital-player-client.mjs +4 -4
- package/{fesm2020 → fesm2022}/reveldigital-player-client.mjs +1132 -1134
- package/fesm2022/reveldigital-player-client.mjs.map +1 -0
- package/{reveldigital-player-client.d.ts → index.d.ts} +5 -5
- package/lib/app-init.service.d.ts +18 -18
- package/lib/app-init.service.d.ts.map +1 -1
- package/lib/interfaces/client.interface.d.ts +406 -406
- package/lib/interfaces/command.interface.d.ts +78 -78
- package/lib/interfaces/config.interface.d.ts +151 -151
- package/lib/interfaces/device.interface.d.ts +139 -139
- package/lib/interfaces/event-properties.interface.d.ts +134 -134
- package/lib/interfaces/location.interface.d.ts +187 -187
- package/lib/player-client.module.d.ts +9 -9
- package/lib/player-client.service.d.ts +640 -640
- package/lib/safe-style.pipe.d.ts +23 -23
- package/lib/safe-style.pipe.d.ts.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.d.ts.map +1 -1
- package/package.json +12 -18
- package/public-api.d.ts +3 -3
- package/schematics/collection.json +15 -15
- package/schematics/ng-add/assets/gadget.yaml +54 -54
- package/schematics/ng-add/index.d.ts +18 -4
- package/schematics/ng-add/index.js +391 -287
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +4 -4
- package/schematics/ng-add/schema.js +2 -2
- package/schematics/ng-add/schema.json +23 -23
- package/schematics/ng-add/templates/index.html +30 -30
- package/schematics/ng-add/templates/polyfills.ts +72 -72
- package/schematics/ng-add/utils/changeBasePath.js +19 -19
- package/schematics/ng-add/utils/yml2xml.js +132 -132
- package/esm2020/lib/app-init.service.mjs +0 -110
- package/esm2020/lib/interfaces/client.interface.mjs +0 -2
- package/esm2020/lib/interfaces/command.interface.mjs +0 -2
- package/esm2020/lib/interfaces/config.interface.mjs +0 -50
- package/esm2020/lib/interfaces/device.interface.mjs +0 -2
- package/esm2020/lib/interfaces/event-properties.interface.mjs +0 -2
- package/esm2020/lib/interfaces/location.interface.mjs +0 -2
- package/esm2020/lib/player-client.module.mjs +0 -73
- package/esm2020/lib/player-client.service.mjs +0 -928
- package/esm2020/lib/safe-style.pipe.mjs +0 -40
- package/fesm2015/reveldigital-player-client.mjs +0 -1219
- package/fesm2015/reveldigital-player-client.mjs.map +0 -1
- package/fesm2020/reveldigital-player-client.mjs.map +0 -1
|
@@ -1,641 +1,641 @@
|
|
|
1
|
-
import { NgZone, OnDestroy } from '@angular/core';
|
|
2
|
-
import { gadgets } from '@reveldigital/gadget-types';
|
|
3
|
-
import { BehaviorSubject, Subject } from 'rxjs';
|
|
4
|
-
import { IClient } from './interfaces/client.interface';
|
|
5
|
-
import { ICommand } from './interfaces/command.interface';
|
|
6
|
-
import { IDictionary } from './interfaces/config.interface';
|
|
7
|
-
import { IDevice } from './interfaces/device.interface';
|
|
8
|
-
import { IEventProperties } from './interfaces/event-properties.interface';
|
|
9
|
-
import * as i0 from "@angular/core";
|
|
10
|
-
/** @ignore */
|
|
11
|
-
declare global {
|
|
12
|
-
var Client: IClient;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Service for interacting with the Revel Digital player client.
|
|
16
|
-
*
|
|
17
|
-
* This service provides a comprehensive interface for gadgets and web applications
|
|
18
|
-
* to communicate with the Revel Digital player environment. It handles device
|
|
19
|
-
* information, commands, events, analytics tracking, and configuration management.
|
|
20
|
-
*
|
|
21
|
-
* The service supports both direct API calls and event-based communication patterns,
|
|
22
|
-
* allowing gadgets to respond to player lifecycle events (start, stop, commands) and
|
|
23
|
-
* send data back to the player or remote devices.
|
|
24
|
-
*
|
|
25
|
-
* ```typescript
|
|
26
|
-
* constructor(private client: PlayerClientService) {
|
|
27
|
-
* // Subscribe to player events
|
|
28
|
-
* this.client.onStart$.subscribe(() => {
|
|
29
|
-
* console.log('Gadget started');
|
|
30
|
-
* });
|
|
31
|
-
*
|
|
32
|
-
* this.client.onCommand$.subscribe(command => {
|
|
33
|
-
* console.log('Received command:', command);
|
|
34
|
-
* });
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
* async ngOnInit() {
|
|
38
|
-
* // Get device information
|
|
39
|
-
* const device = await this.client.getDevice();
|
|
40
|
-
* const deviceTime = await this.client.getDeviceTime();
|
|
41
|
-
*
|
|
42
|
-
* // Track analytics
|
|
43
|
-
* this.client.track('gadget_loaded', { version: '1.0' });
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @since 1.0.0
|
|
48
|
-
*/
|
|
49
|
-
export declare class PlayerClientService implements OnDestroy {
|
|
50
|
-
/** @ignore */
|
|
51
|
-
private clientPromise;
|
|
52
|
-
/**
|
|
53
|
-
* Observable stream of commands sent to this player from the Revel Digital platform.
|
|
54
|
-
* Subscribe to this to handle custom commands sent from templates, playlists, or remote devices.
|
|
55
|
-
*
|
|
56
|
-
* ```typescript
|
|
57
|
-
* this.client.onCommand$.subscribe(command => {
|
|
58
|
-
* if (command.name === 'customAction') {
|
|
59
|
-
* this.handleCustomAction(command.arg);
|
|
60
|
-
* }
|
|
61
|
-
* });
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
onCommand$: Subject<ICommand>;
|
|
65
|
-
/**
|
|
66
|
-
* Observable that signals when the gadget has been loaded and is ready to start.
|
|
67
|
-
* Emits `true` when ready, `false` when destroyed.
|
|
68
|
-
*
|
|
69
|
-
* ```typescript
|
|
70
|
-
* this.client.onReady$.subscribe(isReady => {
|
|
71
|
-
* if (isReady) {
|
|
72
|
-
* console.log('Client is ready');
|
|
73
|
-
* this.initializeGadget();
|
|
74
|
-
* }
|
|
75
|
-
* });
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
onReady$: BehaviorSubject<boolean>;
|
|
79
|
-
/**
|
|
80
|
-
* Observable that signals when the gadget has been started by the player.
|
|
81
|
-
* This event occurs when the player begins execution of the gadget content.
|
|
82
|
-
*
|
|
83
|
-
* ```typescript
|
|
84
|
-
* this.client.onStart$.subscribe(() => {
|
|
85
|
-
* console.log('Gadget started');
|
|
86
|
-
* this.startAnimation();
|
|
87
|
-
* });
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
onStart$: Subject<unknown>;
|
|
91
|
-
/**
|
|
92
|
-
* Observable that signals when the gadget has been stopped by the player.
|
|
93
|
-
* This event occurs when the player stops execution, typically when moving
|
|
94
|
-
* to the next item in a playlist or when the content duration expires.
|
|
95
|
-
*
|
|
96
|
-
* ```typescript
|
|
97
|
-
* this.client.onStop$.subscribe(() => {
|
|
98
|
-
* console.log('Gadget stopped');
|
|
99
|
-
* this.cleanup();
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
onStop$: Subject<unknown>;
|
|
104
|
-
/**
|
|
105
|
-
* Observable that signals when the gadget should open the configuration window.
|
|
106
|
-
* This allows gadgets to respond to configuration requests from the player.
|
|
107
|
-
*
|
|
108
|
-
* ```typescript
|
|
109
|
-
* this.client.onConfig$.subscribe(() => {
|
|
110
|
-
* this.openConfigurationDialog();
|
|
111
|
-
* });
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
onConfig$: Subject<unknown>;
|
|
115
|
-
/**
|
|
116
|
-
* Observable that signals when the gadget has received a postMessage event from the player.
|
|
117
|
-
* This handles communication between the gadget and player via the postMessage API.
|
|
118
|
-
*
|
|
119
|
-
* ```typescript
|
|
120
|
-
* this.client.onPostMessage$.subscribe(message => {
|
|
121
|
-
* console.log('Received message:', message);
|
|
122
|
-
* this.handlePlayerMessage(message);
|
|
123
|
-
* });
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
onPostMessage$: Subject<unknown>;
|
|
127
|
-
/** @ignore */
|
|
128
|
-
private onStartSub;
|
|
129
|
-
/** @ignore */
|
|
130
|
-
private onStartEvt$;
|
|
131
|
-
/** @ignore */
|
|
132
|
-
private onStopSub;
|
|
133
|
-
/** @ignore */
|
|
134
|
-
private onStopEvt$;
|
|
135
|
-
/** @ignore */
|
|
136
|
-
private onCommandSub;
|
|
137
|
-
/** @ignore */
|
|
138
|
-
private onCommandEvt$;
|
|
139
|
-
/** @ignore */
|
|
140
|
-
private onPostMessageSub;
|
|
141
|
-
private onPostMessageEvt$;
|
|
142
|
-
/** @ignore */
|
|
143
|
-
constructor(zone: NgZone);
|
|
144
|
-
/** @ignore */
|
|
145
|
-
ngOnDestroy(): void;
|
|
146
|
-
/** @ignore */
|
|
147
|
-
static init(data: any): void;
|
|
148
|
-
/**
|
|
149
|
-
* Sends a callback to player scripting with variable arguments.
|
|
150
|
-
*
|
|
151
|
-
* This method allows the gadget to communicate with player scripting.
|
|
152
|
-
* If the appropriate scripting is in place in the currently running template,
|
|
153
|
-
* calling this method will initiate a callback which can be acted upon in player script.
|
|
154
|
-
*
|
|
155
|
-
* @param args - Variable number of arguments to pass to the callback (max 5 arguments)
|
|
156
|
-
*
|
|
157
|
-
* ```typescript
|
|
158
|
-
* // Send a simple callback
|
|
159
|
-
* this.client.callback('test', 'data');
|
|
160
|
-
*
|
|
161
|
-
* // Send multiple parameters
|
|
162
|
-
* this.client.callback('action', 'value1', 'value2', { data: 'object' });
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
callback(...args: any[]): void;
|
|
166
|
-
/**
|
|
167
|
-
* Gets the user preferences interface exposed by the Google Gadgets API.
|
|
168
|
-
*
|
|
169
|
-
* This method provides access to gadget preferences which can be configured
|
|
170
|
-
* in the Revel Digital CMS. Use this to retrieve user-configurable settings
|
|
171
|
-
* for your gadget.
|
|
172
|
-
*
|
|
173
|
-
* @returns The Gadgets API Prefs object for accessing preference values
|
|
174
|
-
*
|
|
175
|
-
* ```typescript
|
|
176
|
-
* constructor(public client: PlayerClientService) {
|
|
177
|
-
* const prefs = client.getPrefs();
|
|
178
|
-
* const myString = prefs.getString('myStringPref');
|
|
179
|
-
* const myNumber = prefs.getInt('myNumberPref');
|
|
180
|
-
* const myBool = prefs.getBool('myBoolPref');
|
|
181
|
-
* }
|
|
182
|
-
* ```
|
|
183
|
-
*
|
|
184
|
-
* @see {@link https://developers.google.com/gadgets/docs/basic} Google Gadgets API documentation
|
|
185
|
-
*/
|
|
186
|
-
getPrefs(): gadgets.Prefs;
|
|
187
|
-
/**
|
|
188
|
-
* Gets the current device time in ISO8601 format.
|
|
189
|
-
*
|
|
190
|
-
* Current device time is determined by the device timezone assigned to the device in the CMS.
|
|
191
|
-
* This is useful for displaying time-sensitive content or scheduling operations based on
|
|
192
|
-
* the device's local time rather than browser time.
|
|
193
|
-
*
|
|
194
|
-
* @param date - Optional. If supplied, will translate the supplied date/time to device time based on respective timezones
|
|
195
|
-
* @returns Promise resolving to date/time in ISO8601 format
|
|
196
|
-
*
|
|
197
|
-
* ```typescript
|
|
198
|
-
* // Get current device time
|
|
199
|
-
* const currentTime = await this.client.getDeviceTime();
|
|
200
|
-
* console.log('Device time:', currentTime);
|
|
201
|
-
*
|
|
202
|
-
* // Convert a specific date to device time
|
|
203
|
-
* const specificDate = new Date('2023-01-01T12:00:00Z');
|
|
204
|
-
* const deviceTime = await this.client.getDeviceTime(specificDate);
|
|
205
|
-
* ```
|
|
206
|
-
*/
|
|
207
|
-
getDeviceTime(date?: Date): Promise<string>;
|
|
208
|
-
/**
|
|
209
|
-
* Gets the timezone name currently assigned to the device.
|
|
210
|
-
*
|
|
211
|
-
* @returns Promise resolving to the timezone name (e.g., "America/New_York")
|
|
212
|
-
*
|
|
213
|
-
* ```typescript
|
|
214
|
-
* const timezoneName = await this.client.getDeviceTimeZoneName();
|
|
215
|
-
* console.log('Device timezone:', timezoneName);
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
getDeviceTimeZoneName(): Promise<string>;
|
|
219
|
-
/**
|
|
220
|
-
* Gets the timezone ID currently assigned to the device.
|
|
221
|
-
*
|
|
222
|
-
* @returns Promise resolving to the timezone ID
|
|
223
|
-
*
|
|
224
|
-
* ```typescript
|
|
225
|
-
* const timezoneId = await this.client.getDeviceTimeZoneID();
|
|
226
|
-
* console.log('Device timezone ID:', timezoneId);
|
|
227
|
-
* ```
|
|
228
|
-
*/
|
|
229
|
-
getDeviceTimeZoneID(): Promise<string>;
|
|
230
|
-
/**
|
|
231
|
-
* Gets the numerical offset from GMT of the timezone currently assigned to the device.
|
|
232
|
-
*
|
|
233
|
-
* @returns Promise resolving to the timezone offset in hours (e.g., -5 for EST)
|
|
234
|
-
*
|
|
235
|
-
* ```typescript
|
|
236
|
-
* const offset = await this.client.getDeviceTimeZoneOffset();
|
|
237
|
-
* console.log('Device timezone offset:', offset, 'hours from GMT');
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
getDeviceTimeZoneOffset(): Promise<number>;
|
|
241
|
-
/**
|
|
242
|
-
* Gets the language code of the language currently assigned to the device.
|
|
243
|
-
*
|
|
244
|
-
* @returns Promise resolving to the language code (e.g., "en-US", "fr-FR")
|
|
245
|
-
*
|
|
246
|
-
* ```typescript
|
|
247
|
-
* const languageCode = await this.client.getLanguageCode();
|
|
248
|
-
* console.log('Device language:', languageCode);
|
|
249
|
-
* // Use for localization
|
|
250
|
-
* this.loadLanguageResources(languageCode);
|
|
251
|
-
* ```
|
|
252
|
-
*/
|
|
253
|
-
getLanguageCode(): Promise<string>;
|
|
254
|
-
/**
|
|
255
|
-
* Gets the unique Revel Digital device key associated with the device.
|
|
256
|
-
*
|
|
257
|
-
* The device key is a unique identifier for this specific player device
|
|
258
|
-
* and can be used for device-specific operations or remote commands.
|
|
259
|
-
*
|
|
260
|
-
* @returns Promise resolving to the device key string
|
|
261
|
-
*
|
|
262
|
-
* ```typescript
|
|
263
|
-
* const deviceKey = await this.client.getDeviceKey();
|
|
264
|
-
* console.log('Device key:', deviceKey);
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
getDeviceKey(): Promise<string>;
|
|
268
|
-
/**
|
|
269
|
-
* Sends a command to the local player device.
|
|
270
|
-
*
|
|
271
|
-
* Commands can be used to control various aspects of the player or trigger
|
|
272
|
-
* specific behaviors. The command is processed by the local player only.
|
|
273
|
-
*
|
|
274
|
-
* @param name - The command name/identifier
|
|
275
|
-
* @param arg - The command argument/payload
|
|
276
|
-
*
|
|
277
|
-
* ```typescript
|
|
278
|
-
* // Send a simple command
|
|
279
|
-
* this.client.sendCommand('refresh', '');
|
|
280
|
-
*
|
|
281
|
-
* // Send a command with data
|
|
282
|
-
* this.client.sendCommand('setVolume', '50');
|
|
283
|
-
*
|
|
284
|
-
* // Send a command with JSON data
|
|
285
|
-
* this.client.sendCommand('configure', JSON.stringify({ setting: 'value' }));
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
|
-
sendCommand(name: string, arg: string): void;
|
|
289
|
-
/**
|
|
290
|
-
* Sends a command to remote player devices with the specified device keys.
|
|
291
|
-
*
|
|
292
|
-
* Remote commands allow cross-device communication within the same Revel Digital account.
|
|
293
|
-
* This is useful for synchronized displays, device coordination, or remote control scenarios.
|
|
294
|
-
*
|
|
295
|
-
* Note: Remote commands can only be delivered to devices within the same account as the sender device.
|
|
296
|
-
*
|
|
297
|
-
* @param deviceKeys - Array of target device keys to send the command to
|
|
298
|
-
* @param name - The command name/identifier
|
|
299
|
-
* @param arg - The command argument/payload
|
|
300
|
-
*
|
|
301
|
-
* ```typescript
|
|
302
|
-
* // Send command to specific devices
|
|
303
|
-
* const targetDevices = ['device-key-1', 'device-key-2'];
|
|
304
|
-
* this.client.sendRemoteCommand(targetDevices, 'syncAction', 'start');
|
|
305
|
-
*
|
|
306
|
-
* // Broadcast to multiple devices
|
|
307
|
-
* this.client.sendRemoteCommand(
|
|
308
|
-
* ['lobby-display', 'kiosk-1', 'kiosk-2'],
|
|
309
|
-
* 'updateContent',
|
|
310
|
-
* JSON.stringify({ contentId: '12345' })
|
|
311
|
-
* );
|
|
312
|
-
* ```
|
|
313
|
-
*/
|
|
314
|
-
sendRemoteCommand(deviceKeys: string[], name: string, arg: string): void;
|
|
315
|
-
/**
|
|
316
|
-
* Logs an analytics event for use with AdHawk analytics and reporting.
|
|
317
|
-
*
|
|
318
|
-
* Events are used for tracking various metrics including usage statistics,
|
|
319
|
-
* player condition, state changes, user interactions, and custom business metrics.
|
|
320
|
-
* These events can be viewed in the Revel Digital analytics dashboard.
|
|
321
|
-
*
|
|
322
|
-
* @param eventName - Unique name for this event (should be descriptive and consistent)
|
|
323
|
-
* @param properties - Optional map of user-defined properties to associate with this event
|
|
324
|
-
*
|
|
325
|
-
* ```typescript
|
|
326
|
-
* // Simple event tracking
|
|
327
|
-
* this.client.track('gadget_loaded');
|
|
328
|
-
*
|
|
329
|
-
* // Event with properties
|
|
330
|
-
* this.client.track('user_interaction', {
|
|
331
|
-
* action: 'button_click',
|
|
332
|
-
* button_id: 'start_button',
|
|
333
|
-
* timestamp: new Date().toISOString()
|
|
334
|
-
* });
|
|
335
|
-
*
|
|
336
|
-
* // Performance tracking
|
|
337
|
-
* this.client.track('content_displayed', {
|
|
338
|
-
* content_type: 'video',
|
|
339
|
-
* duration: 30,
|
|
340
|
-
* quality: 'HD'
|
|
341
|
-
* });
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
track(eventName: string, properties?: IEventProperties): void;
|
|
345
|
-
/**
|
|
346
|
-
* Initiates a timed event for duration tracking.
|
|
347
|
-
*
|
|
348
|
-
* Timed events are useful for tracking the duration of operations or user interactions.
|
|
349
|
-
* This method must be followed by a call to track() with the same event name to complete
|
|
350
|
-
* the timing measurement. The duration will be automatically calculated and included
|
|
351
|
-
* in the event properties.
|
|
352
|
-
*
|
|
353
|
-
* @param eventName - Unique name for this timed event (must match the subsequent track() call)
|
|
354
|
-
*
|
|
355
|
-
* ```typescript
|
|
356
|
-
* // Start timing an event
|
|
357
|
-
* this.client.timeEvent('video_playback');
|
|
358
|
-
*
|
|
359
|
-
* // ... video plays for some duration ...
|
|
360
|
-
*
|
|
361
|
-
* // End timing and log the event with duration
|
|
362
|
-
* this.client.track('video_playback', {
|
|
363
|
-
* video_id: 'abc123',
|
|
364
|
-
* quality: 'HD'
|
|
365
|
-
* }); // Duration will be automatically added
|
|
366
|
-
*
|
|
367
|
-
* // Example for user interaction timing
|
|
368
|
-
* this.client.timeEvent('form_completion');
|
|
369
|
-
* // ... user fills out form ...
|
|
370
|
-
* this.client.track('form_completion', { form_type: 'contact' });
|
|
371
|
-
* ```
|
|
372
|
-
*/
|
|
373
|
-
timeEvent(eventName: string): void;
|
|
374
|
-
/**
|
|
375
|
-
* Creates a new analytics event session for grouping related events.
|
|
376
|
-
*
|
|
377
|
-
* A session is a way of grouping events together for analysis. Each event tracked
|
|
378
|
-
* after calling this method will have the same session ID until a new session is created.
|
|
379
|
-
* Session IDs are randomly generated unless explicitly provided.
|
|
380
|
-
*
|
|
381
|
-
* This is useful for tracking user journeys, workflow completion, or grouping
|
|
382
|
-
* related interactions within a specific time period.
|
|
383
|
-
*
|
|
384
|
-
* @param id - Optional user-supplied session ID. If not provided, a random session ID will be generated
|
|
385
|
-
*
|
|
386
|
-
* ```typescript
|
|
387
|
-
* // Start a new session with auto-generated ID
|
|
388
|
-
* this.client.newEventSession();
|
|
389
|
-
* this.client.track('session_start');
|
|
390
|
-
* this.client.track('user_action_1');
|
|
391
|
-
* this.client.track('user_action_2');
|
|
392
|
-
*
|
|
393
|
-
* // Start a session with custom ID
|
|
394
|
-
* this.client.newEventSession('user-workflow-12345');
|
|
395
|
-
* this.client.track('workflow_start');
|
|
396
|
-
* this.client.track('step_completed', { step: 1 });
|
|
397
|
-
*
|
|
398
|
-
* // Start a new session for different workflow
|
|
399
|
-
* this.client.newEventSession();
|
|
400
|
-
* this.client.track('different_workflow_start');
|
|
401
|
-
* ```
|
|
402
|
-
*/
|
|
403
|
-
newEventSession(id?: string): void;
|
|
404
|
-
/**
|
|
405
|
-
* Gets the root folder path utilized by this player device.
|
|
406
|
-
*
|
|
407
|
-
* This returns the base directory path where the Revel Digital player
|
|
408
|
-
* stores its files and resources on the local device.
|
|
409
|
-
*
|
|
410
|
-
* @returns Promise resolving to the path of the root folder
|
|
411
|
-
*
|
|
412
|
-
* ```typescript
|
|
413
|
-
* const rootPath = await this.client.getRevelRoot();
|
|
414
|
-
* console.log('Player root directory:', rootPath);
|
|
415
|
-
* // Use for constructing file paths or understanding storage structure
|
|
416
|
-
* ```
|
|
417
|
-
*/
|
|
418
|
-
getRevelRoot(): Promise<string>;
|
|
419
|
-
/**
|
|
420
|
-
* Gets a map of commands currently active for this device.
|
|
421
|
-
*
|
|
422
|
-
* This returns the current command configuration that defines how the device
|
|
423
|
-
* responds to various command triggers and remote commands.
|
|
424
|
-
*
|
|
425
|
-
* @returns Promise resolving to a map of currently active commands
|
|
426
|
-
*
|
|
427
|
-
* ```typescript
|
|
428
|
-
* const commandMap = await this.client.getCommandMap();
|
|
429
|
-
* console.log('Active commands:', commandMap);
|
|
430
|
-
*
|
|
431
|
-
* // Check if specific command is available
|
|
432
|
-
* if (commandMap['customCommand']) {
|
|
433
|
-
* console.log('Custom command is available');
|
|
434
|
-
* }
|
|
435
|
-
* ```
|
|
436
|
-
*/
|
|
437
|
-
getCommandMap(): Promise<any>;
|
|
438
|
-
/**
|
|
439
|
-
* Signals to the player that this gadget has completed its visualization.
|
|
440
|
-
*
|
|
441
|
-
* This method notifies the player that the current gadget has finished its
|
|
442
|
-
* content display or interaction cycle. The player can then proceed with
|
|
443
|
-
* the next item in a playlist if applicable, or handle the completion
|
|
444
|
-
* according to its configuration.
|
|
445
|
-
*
|
|
446
|
-
* Call this method when your gadget has completed its intended function,
|
|
447
|
-
* such as finishing an animation, completing a form, or reaching a natural
|
|
448
|
-
* stopping point.
|
|
449
|
-
*
|
|
450
|
-
* ```typescript
|
|
451
|
-
* // After completing an animation
|
|
452
|
-
* private onAnimationComplete(): void {
|
|
453
|
-
* this.client.finish();
|
|
454
|
-
* }
|
|
455
|
-
*
|
|
456
|
-
* // After user interaction is complete
|
|
457
|
-
* private onFormSubmitted(): void {
|
|
458
|
-
* this.saveFormData();
|
|
459
|
-
* this.client.finish();
|
|
460
|
-
* }
|
|
461
|
-
*
|
|
462
|
-
* // After a timed display period
|
|
463
|
-
* setTimeout(() => {
|
|
464
|
-
* this.client.finish();
|
|
465
|
-
* }, 30000); // 30 seconds
|
|
466
|
-
* ```
|
|
467
|
-
*/
|
|
468
|
-
finish(): void;
|
|
469
|
-
/**
|
|
470
|
-
* Checks if the gadget is running in preview mode.
|
|
471
|
-
*
|
|
472
|
-
* Preview mode is enabled when the gadget is being edited in the Revel Digital CMS,
|
|
473
|
-
* tested in the gadget editor, or otherwise not running in a normal player environment.
|
|
474
|
-
* This is useful for providing different behavior during development/testing versus
|
|
475
|
-
* production deployment.
|
|
476
|
-
*
|
|
477
|
-
* @returns Promise resolving to true if running in preview mode, false if running on actual player
|
|
478
|
-
*
|
|
479
|
-
* ```typescript
|
|
480
|
-
* const isPreview = await this.client.isPreviewMode();
|
|
481
|
-
*
|
|
482
|
-
* if (isPreview) {
|
|
483
|
-
* console.log('Running in preview mode - using mock data');
|
|
484
|
-
* this.loadMockData();
|
|
485
|
-
* } else {
|
|
486
|
-
* console.log('Running on player device - using live data');
|
|
487
|
-
* this.loadLiveData();
|
|
488
|
-
* }
|
|
489
|
-
*
|
|
490
|
-
* // Show different UI in preview
|
|
491
|
-
* this.showPreviewIndicator = isPreview;
|
|
492
|
-
* ```
|
|
493
|
-
*/
|
|
494
|
-
isPreviewMode(): Promise<boolean>;
|
|
495
|
-
/**
|
|
496
|
-
* Gets detailed information about the device running the player.
|
|
497
|
-
*
|
|
498
|
-
* Returns comprehensive device details including name, registration key, type,
|
|
499
|
-
* service date, language, timezone, tags, and location information. This data
|
|
500
|
-
* is configured in the Revel Digital CMS for each device.
|
|
501
|
-
*
|
|
502
|
-
* @returns Promise resolving to device details object, or null if not available
|
|
503
|
-
*
|
|
504
|
-
* ```typescript
|
|
505
|
-
* const device = await this.client.getDevice();
|
|
506
|
-
*
|
|
507
|
-
* if (device) {
|
|
508
|
-
* console.log('Device name:', device.name);
|
|
509
|
-
* console.log('Device type:', device.deviceType);
|
|
510
|
-
* console.log('Location:', device.location.city, device.location.state);
|
|
511
|
-
* console.log('Tags:', device.tags);
|
|
512
|
-
*
|
|
513
|
-
* // Use device info for customization
|
|
514
|
-
* if (device.location.country === 'US') {
|
|
515
|
-
* this.loadUSContent();
|
|
516
|
-
* }
|
|
517
|
-
*
|
|
518
|
-
* // Check device capabilities based on type
|
|
519
|
-
* if (device.deviceType === 'android') {
|
|
520
|
-
* this.enableTouchFeatures();
|
|
521
|
-
* }
|
|
522
|
-
* }
|
|
523
|
-
* ```
|
|
524
|
-
*/
|
|
525
|
-
getDevice(): Promise<IDevice | null>;
|
|
526
|
-
/**
|
|
527
|
-
* Gets the width of the visualization area in pixels.
|
|
528
|
-
*
|
|
529
|
-
* This returns the available width for content display, which may be
|
|
530
|
-
* different from the full screen width depending on player configuration
|
|
531
|
-
* and template layout.
|
|
532
|
-
*
|
|
533
|
-
* @returns Promise resolving to width in pixels, or null if not available
|
|
534
|
-
*
|
|
535
|
-
* ```typescript
|
|
536
|
-
* const width = await this.client.getWidth();
|
|
537
|
-
*
|
|
538
|
-
* if (width) {
|
|
539
|
-
* console.log('Available width:', width, 'pixels');
|
|
540
|
-
*
|
|
541
|
-
* // Adapt content layout based on width
|
|
542
|
-
* if (width < 800) {
|
|
543
|
-
* this.enableMobileLayout();
|
|
544
|
-
* } else {
|
|
545
|
-
* this.enableDesktopLayout();
|
|
546
|
-
* }
|
|
547
|
-
* }
|
|
548
|
-
* ```
|
|
549
|
-
*/
|
|
550
|
-
getWidth(): Promise<number | null>;
|
|
551
|
-
/**
|
|
552
|
-
* Gets the height of the visualization area in pixels.
|
|
553
|
-
*
|
|
554
|
-
* This returns the available height for content display, which may be
|
|
555
|
-
* different from the full screen height depending on player configuration
|
|
556
|
-
* and template layout.
|
|
557
|
-
*
|
|
558
|
-
* @returns Promise resolving to height in pixels, or null if not available
|
|
559
|
-
*
|
|
560
|
-
* ```typescript
|
|
561
|
-
* const height = await this.client.getHeight();
|
|
562
|
-
*
|
|
563
|
-
* if (height) {
|
|
564
|
-
* console.log('Available height:', height, 'pixels');
|
|
565
|
-
*
|
|
566
|
-
* // Calculate aspect ratio for responsive design
|
|
567
|
-
* const width = await this.client.getWidth();
|
|
568
|
-
* const aspectRatio = width / height;
|
|
569
|
-
* this.adjustContentForAspectRatio(aspectRatio);
|
|
570
|
-
* }
|
|
571
|
-
* ```
|
|
572
|
-
*/
|
|
573
|
-
getHeight(): Promise<number | null>;
|
|
574
|
-
/**
|
|
575
|
-
* Gets the duration of the currently playing content item.
|
|
576
|
-
*
|
|
577
|
-
* This method is only applicable when the gadget is associated with a playlist
|
|
578
|
-
* and returns the duration assigned to the current playlist item. The duration
|
|
579
|
-
* determines how long the content should be displayed before moving to the next item.
|
|
580
|
-
*
|
|
581
|
-
* @returns Promise resolving to duration in milliseconds, or null if not applicable/available
|
|
582
|
-
*
|
|
583
|
-
* ```typescript
|
|
584
|
-
* const duration = await this.client.getDuration();
|
|
585
|
-
*
|
|
586
|
-
* if (duration) {
|
|
587
|
-
* console.log('Content duration:', duration, 'milliseconds');
|
|
588
|
-
*
|
|
589
|
-
* // Set up auto-finish timer
|
|
590
|
-
* setTimeout(() => {
|
|
591
|
-
* this.client.finish();
|
|
592
|
-
* }, duration);
|
|
593
|
-
*
|
|
594
|
-
* // Show progress indicator
|
|
595
|
-
* this.startProgressIndicator(duration);
|
|
596
|
-
* }
|
|
597
|
-
* ```
|
|
598
|
-
*/
|
|
599
|
-
getDuration(): Promise<number | null>;
|
|
600
|
-
/**
|
|
601
|
-
* Gets the current version of the Revel Digital SDK.
|
|
602
|
-
*
|
|
603
|
-
* @returns Promise resolving to the SDK version string
|
|
604
|
-
*
|
|
605
|
-
* ```typescript
|
|
606
|
-
* const version = await this.client.getSdkVersion();
|
|
607
|
-
* console.log('SDK Version:', version);
|
|
608
|
-
*
|
|
609
|
-
* // Use for compatibility checks or logging
|
|
610
|
-
* this.client.track('gadget_loaded', { sdkVersion: version });
|
|
611
|
-
* ```
|
|
612
|
-
*/
|
|
613
|
-
getSdkVersion(): Promise<string>;
|
|
614
|
-
/**
|
|
615
|
-
* Applies configuration preferences to the gadget (preview mode only).
|
|
616
|
-
*
|
|
617
|
-
* This method is only available when running in preview mode (typically during
|
|
618
|
-
* gadget development or testing in the CMS). It allows applying configuration
|
|
619
|
-
* changes that would normally come from the gadget's preference settings.
|
|
620
|
-
*
|
|
621
|
-
* @param prefs - Dictionary of preference key-value pairs to apply
|
|
622
|
-
*
|
|
623
|
-
* ```typescript
|
|
624
|
-
* if (await this.client.isPreviewMode()) {
|
|
625
|
-
* // Apply test configuration in preview
|
|
626
|
-
* await this.client.applyConfig({
|
|
627
|
-
* 'title': 'Test Title',
|
|
628
|
-
* 'backgroundColor': '#ff0000',
|
|
629
|
-
* 'showBorder': true,
|
|
630
|
-
* 'refreshInterval': 30
|
|
631
|
-
* });
|
|
632
|
-
* }
|
|
633
|
-
* ```
|
|
634
|
-
*/
|
|
635
|
-
applyConfig(prefs: IDictionary<any>): Promise<void>;
|
|
636
|
-
/** @ignore */
|
|
637
|
-
private getClient;
|
|
638
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<PlayerClientService, never>;
|
|
639
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<PlayerClientService>;
|
|
640
|
-
}
|
|
1
|
+
import { NgZone, OnDestroy } from '@angular/core';
|
|
2
|
+
import { gadgets } from '@reveldigital/gadget-types';
|
|
3
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
4
|
+
import { IClient } from './interfaces/client.interface';
|
|
5
|
+
import { ICommand } from './interfaces/command.interface';
|
|
6
|
+
import { IDictionary } from './interfaces/config.interface';
|
|
7
|
+
import { IDevice } from './interfaces/device.interface';
|
|
8
|
+
import { IEventProperties } from './interfaces/event-properties.interface';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
/** @ignore */
|
|
11
|
+
declare global {
|
|
12
|
+
var Client: IClient;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Service for interacting with the Revel Digital player client.
|
|
16
|
+
*
|
|
17
|
+
* This service provides a comprehensive interface for gadgets and web applications
|
|
18
|
+
* to communicate with the Revel Digital player environment. It handles device
|
|
19
|
+
* information, commands, events, analytics tracking, and configuration management.
|
|
20
|
+
*
|
|
21
|
+
* The service supports both direct API calls and event-based communication patterns,
|
|
22
|
+
* allowing gadgets to respond to player lifecycle events (start, stop, commands) and
|
|
23
|
+
* send data back to the player or remote devices.
|
|
24
|
+
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* constructor(private client: PlayerClientService) {
|
|
27
|
+
* // Subscribe to player events
|
|
28
|
+
* this.client.onStart$.subscribe(() => {
|
|
29
|
+
* console.log('Gadget started');
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* this.client.onCommand$.subscribe(command => {
|
|
33
|
+
* console.log('Received command:', command);
|
|
34
|
+
* });
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* async ngOnInit() {
|
|
38
|
+
* // Get device information
|
|
39
|
+
* const device = await this.client.getDevice();
|
|
40
|
+
* const deviceTime = await this.client.getDeviceTime();
|
|
41
|
+
*
|
|
42
|
+
* // Track analytics
|
|
43
|
+
* this.client.track('gadget_loaded', { version: '1.0' });
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @since 1.0.0
|
|
48
|
+
*/
|
|
49
|
+
export declare class PlayerClientService implements OnDestroy {
|
|
50
|
+
/** @ignore */
|
|
51
|
+
private clientPromise;
|
|
52
|
+
/**
|
|
53
|
+
* Observable stream of commands sent to this player from the Revel Digital platform.
|
|
54
|
+
* Subscribe to this to handle custom commands sent from templates, playlists, or remote devices.
|
|
55
|
+
*
|
|
56
|
+
* ```typescript
|
|
57
|
+
* this.client.onCommand$.subscribe(command => {
|
|
58
|
+
* if (command.name === 'customAction') {
|
|
59
|
+
* this.handleCustomAction(command.arg);
|
|
60
|
+
* }
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
onCommand$: Subject<ICommand>;
|
|
65
|
+
/**
|
|
66
|
+
* Observable that signals when the gadget has been loaded and is ready to start.
|
|
67
|
+
* Emits `true` when ready, `false` when destroyed.
|
|
68
|
+
*
|
|
69
|
+
* ```typescript
|
|
70
|
+
* this.client.onReady$.subscribe(isReady => {
|
|
71
|
+
* if (isReady) {
|
|
72
|
+
* console.log('Client is ready');
|
|
73
|
+
* this.initializeGadget();
|
|
74
|
+
* }
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
onReady$: BehaviorSubject<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* Observable that signals when the gadget has been started by the player.
|
|
81
|
+
* This event occurs when the player begins execution of the gadget content.
|
|
82
|
+
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* this.client.onStart$.subscribe(() => {
|
|
85
|
+
* console.log('Gadget started');
|
|
86
|
+
* this.startAnimation();
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
onStart$: Subject<unknown>;
|
|
91
|
+
/**
|
|
92
|
+
* Observable that signals when the gadget has been stopped by the player.
|
|
93
|
+
* This event occurs when the player stops execution, typically when moving
|
|
94
|
+
* to the next item in a playlist or when the content duration expires.
|
|
95
|
+
*
|
|
96
|
+
* ```typescript
|
|
97
|
+
* this.client.onStop$.subscribe(() => {
|
|
98
|
+
* console.log('Gadget stopped');
|
|
99
|
+
* this.cleanup();
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
onStop$: Subject<unknown>;
|
|
104
|
+
/**
|
|
105
|
+
* Observable that signals when the gadget should open the configuration window.
|
|
106
|
+
* This allows gadgets to respond to configuration requests from the player.
|
|
107
|
+
*
|
|
108
|
+
* ```typescript
|
|
109
|
+
* this.client.onConfig$.subscribe(() => {
|
|
110
|
+
* this.openConfigurationDialog();
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
onConfig$: Subject<unknown>;
|
|
115
|
+
/**
|
|
116
|
+
* Observable that signals when the gadget has received a postMessage event from the player.
|
|
117
|
+
* This handles communication between the gadget and player via the postMessage API.
|
|
118
|
+
*
|
|
119
|
+
* ```typescript
|
|
120
|
+
* this.client.onPostMessage$.subscribe(message => {
|
|
121
|
+
* console.log('Received message:', message);
|
|
122
|
+
* this.handlePlayerMessage(message);
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
onPostMessage$: Subject<unknown>;
|
|
127
|
+
/** @ignore */
|
|
128
|
+
private onStartSub;
|
|
129
|
+
/** @ignore */
|
|
130
|
+
private onStartEvt$;
|
|
131
|
+
/** @ignore */
|
|
132
|
+
private onStopSub;
|
|
133
|
+
/** @ignore */
|
|
134
|
+
private onStopEvt$;
|
|
135
|
+
/** @ignore */
|
|
136
|
+
private onCommandSub;
|
|
137
|
+
/** @ignore */
|
|
138
|
+
private onCommandEvt$;
|
|
139
|
+
/** @ignore */
|
|
140
|
+
private onPostMessageSub;
|
|
141
|
+
private onPostMessageEvt$;
|
|
142
|
+
/** @ignore */
|
|
143
|
+
constructor(zone: NgZone);
|
|
144
|
+
/** @ignore */
|
|
145
|
+
ngOnDestroy(): void;
|
|
146
|
+
/** @ignore */
|
|
147
|
+
static init(data: any): void;
|
|
148
|
+
/**
|
|
149
|
+
* Sends a callback to player scripting with variable arguments.
|
|
150
|
+
*
|
|
151
|
+
* This method allows the gadget to communicate with player scripting.
|
|
152
|
+
* If the appropriate scripting is in place in the currently running template,
|
|
153
|
+
* calling this method will initiate a callback which can be acted upon in player script.
|
|
154
|
+
*
|
|
155
|
+
* @param args - Variable number of arguments to pass to the callback (max 5 arguments)
|
|
156
|
+
*
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Send a simple callback
|
|
159
|
+
* this.client.callback('test', 'data');
|
|
160
|
+
*
|
|
161
|
+
* // Send multiple parameters
|
|
162
|
+
* this.client.callback('action', 'value1', 'value2', { data: 'object' });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
callback(...args: any[]): void;
|
|
166
|
+
/**
|
|
167
|
+
* Gets the user preferences interface exposed by the Google Gadgets API.
|
|
168
|
+
*
|
|
169
|
+
* This method provides access to gadget preferences which can be configured
|
|
170
|
+
* in the Revel Digital CMS. Use this to retrieve user-configurable settings
|
|
171
|
+
* for your gadget.
|
|
172
|
+
*
|
|
173
|
+
* @returns The Gadgets API Prefs object for accessing preference values
|
|
174
|
+
*
|
|
175
|
+
* ```typescript
|
|
176
|
+
* constructor(public client: PlayerClientService) {
|
|
177
|
+
* const prefs = client.getPrefs();
|
|
178
|
+
* const myString = prefs.getString('myStringPref');
|
|
179
|
+
* const myNumber = prefs.getInt('myNumberPref');
|
|
180
|
+
* const myBool = prefs.getBool('myBoolPref');
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @see {@link https://developers.google.com/gadgets/docs/basic} Google Gadgets API documentation
|
|
185
|
+
*/
|
|
186
|
+
getPrefs(): gadgets.Prefs;
|
|
187
|
+
/**
|
|
188
|
+
* Gets the current device time in ISO8601 format.
|
|
189
|
+
*
|
|
190
|
+
* Current device time is determined by the device timezone assigned to the device in the CMS.
|
|
191
|
+
* This is useful for displaying time-sensitive content or scheduling operations based on
|
|
192
|
+
* the device's local time rather than browser time.
|
|
193
|
+
*
|
|
194
|
+
* @param date - Optional. If supplied, will translate the supplied date/time to device time based on respective timezones
|
|
195
|
+
* @returns Promise resolving to date/time in ISO8601 format
|
|
196
|
+
*
|
|
197
|
+
* ```typescript
|
|
198
|
+
* // Get current device time
|
|
199
|
+
* const currentTime = await this.client.getDeviceTime();
|
|
200
|
+
* console.log('Device time:', currentTime);
|
|
201
|
+
*
|
|
202
|
+
* // Convert a specific date to device time
|
|
203
|
+
* const specificDate = new Date('2023-01-01T12:00:00Z');
|
|
204
|
+
* const deviceTime = await this.client.getDeviceTime(specificDate);
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
getDeviceTime(date?: Date): Promise<string>;
|
|
208
|
+
/**
|
|
209
|
+
* Gets the timezone name currently assigned to the device.
|
|
210
|
+
*
|
|
211
|
+
* @returns Promise resolving to the timezone name (e.g., "America/New_York")
|
|
212
|
+
*
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const timezoneName = await this.client.getDeviceTimeZoneName();
|
|
215
|
+
* console.log('Device timezone:', timezoneName);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
getDeviceTimeZoneName(): Promise<string>;
|
|
219
|
+
/**
|
|
220
|
+
* Gets the timezone ID currently assigned to the device.
|
|
221
|
+
*
|
|
222
|
+
* @returns Promise resolving to the timezone ID
|
|
223
|
+
*
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const timezoneId = await this.client.getDeviceTimeZoneID();
|
|
226
|
+
* console.log('Device timezone ID:', timezoneId);
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
getDeviceTimeZoneID(): Promise<string>;
|
|
230
|
+
/**
|
|
231
|
+
* Gets the numerical offset from GMT of the timezone currently assigned to the device.
|
|
232
|
+
*
|
|
233
|
+
* @returns Promise resolving to the timezone offset in hours (e.g., -5 for EST)
|
|
234
|
+
*
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const offset = await this.client.getDeviceTimeZoneOffset();
|
|
237
|
+
* console.log('Device timezone offset:', offset, 'hours from GMT');
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
getDeviceTimeZoneOffset(): Promise<number>;
|
|
241
|
+
/**
|
|
242
|
+
* Gets the language code of the language currently assigned to the device.
|
|
243
|
+
*
|
|
244
|
+
* @returns Promise resolving to the language code (e.g., "en-US", "fr-FR")
|
|
245
|
+
*
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const languageCode = await this.client.getLanguageCode();
|
|
248
|
+
* console.log('Device language:', languageCode);
|
|
249
|
+
* // Use for localization
|
|
250
|
+
* this.loadLanguageResources(languageCode);
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
getLanguageCode(): Promise<string>;
|
|
254
|
+
/**
|
|
255
|
+
* Gets the unique Revel Digital device key associated with the device.
|
|
256
|
+
*
|
|
257
|
+
* The device key is a unique identifier for this specific player device
|
|
258
|
+
* and can be used for device-specific operations or remote commands.
|
|
259
|
+
*
|
|
260
|
+
* @returns Promise resolving to the device key string
|
|
261
|
+
*
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const deviceKey = await this.client.getDeviceKey();
|
|
264
|
+
* console.log('Device key:', deviceKey);
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
getDeviceKey(): Promise<string>;
|
|
268
|
+
/**
|
|
269
|
+
* Sends a command to the local player device.
|
|
270
|
+
*
|
|
271
|
+
* Commands can be used to control various aspects of the player or trigger
|
|
272
|
+
* specific behaviors. The command is processed by the local player only.
|
|
273
|
+
*
|
|
274
|
+
* @param name - The command name/identifier
|
|
275
|
+
* @param arg - The command argument/payload
|
|
276
|
+
*
|
|
277
|
+
* ```typescript
|
|
278
|
+
* // Send a simple command
|
|
279
|
+
* this.client.sendCommand('refresh', '');
|
|
280
|
+
*
|
|
281
|
+
* // Send a command with data
|
|
282
|
+
* this.client.sendCommand('setVolume', '50');
|
|
283
|
+
*
|
|
284
|
+
* // Send a command with JSON data
|
|
285
|
+
* this.client.sendCommand('configure', JSON.stringify({ setting: 'value' }));
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
sendCommand(name: string, arg: string): void;
|
|
289
|
+
/**
|
|
290
|
+
* Sends a command to remote player devices with the specified device keys.
|
|
291
|
+
*
|
|
292
|
+
* Remote commands allow cross-device communication within the same Revel Digital account.
|
|
293
|
+
* This is useful for synchronized displays, device coordination, or remote control scenarios.
|
|
294
|
+
*
|
|
295
|
+
* Note: Remote commands can only be delivered to devices within the same account as the sender device.
|
|
296
|
+
*
|
|
297
|
+
* @param deviceKeys - Array of target device keys to send the command to
|
|
298
|
+
* @param name - The command name/identifier
|
|
299
|
+
* @param arg - The command argument/payload
|
|
300
|
+
*
|
|
301
|
+
* ```typescript
|
|
302
|
+
* // Send command to specific devices
|
|
303
|
+
* const targetDevices = ['device-key-1', 'device-key-2'];
|
|
304
|
+
* this.client.sendRemoteCommand(targetDevices, 'syncAction', 'start');
|
|
305
|
+
*
|
|
306
|
+
* // Broadcast to multiple devices
|
|
307
|
+
* this.client.sendRemoteCommand(
|
|
308
|
+
* ['lobby-display', 'kiosk-1', 'kiosk-2'],
|
|
309
|
+
* 'updateContent',
|
|
310
|
+
* JSON.stringify({ contentId: '12345' })
|
|
311
|
+
* );
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
sendRemoteCommand(deviceKeys: string[], name: string, arg: string): void;
|
|
315
|
+
/**
|
|
316
|
+
* Logs an analytics event for use with AdHawk analytics and reporting.
|
|
317
|
+
*
|
|
318
|
+
* Events are used for tracking various metrics including usage statistics,
|
|
319
|
+
* player condition, state changes, user interactions, and custom business metrics.
|
|
320
|
+
* These events can be viewed in the Revel Digital analytics dashboard.
|
|
321
|
+
*
|
|
322
|
+
* @param eventName - Unique name for this event (should be descriptive and consistent)
|
|
323
|
+
* @param properties - Optional map of user-defined properties to associate with this event
|
|
324
|
+
*
|
|
325
|
+
* ```typescript
|
|
326
|
+
* // Simple event tracking
|
|
327
|
+
* this.client.track('gadget_loaded');
|
|
328
|
+
*
|
|
329
|
+
* // Event with properties
|
|
330
|
+
* this.client.track('user_interaction', {
|
|
331
|
+
* action: 'button_click',
|
|
332
|
+
* button_id: 'start_button',
|
|
333
|
+
* timestamp: new Date().toISOString()
|
|
334
|
+
* });
|
|
335
|
+
*
|
|
336
|
+
* // Performance tracking
|
|
337
|
+
* this.client.track('content_displayed', {
|
|
338
|
+
* content_type: 'video',
|
|
339
|
+
* duration: 30,
|
|
340
|
+
* quality: 'HD'
|
|
341
|
+
* });
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
track(eventName: string, properties?: IEventProperties): void;
|
|
345
|
+
/**
|
|
346
|
+
* Initiates a timed event for duration tracking.
|
|
347
|
+
*
|
|
348
|
+
* Timed events are useful for tracking the duration of operations or user interactions.
|
|
349
|
+
* This method must be followed by a call to track() with the same event name to complete
|
|
350
|
+
* the timing measurement. The duration will be automatically calculated and included
|
|
351
|
+
* in the event properties.
|
|
352
|
+
*
|
|
353
|
+
* @param eventName - Unique name for this timed event (must match the subsequent track() call)
|
|
354
|
+
*
|
|
355
|
+
* ```typescript
|
|
356
|
+
* // Start timing an event
|
|
357
|
+
* this.client.timeEvent('video_playback');
|
|
358
|
+
*
|
|
359
|
+
* // ... video plays for some duration ...
|
|
360
|
+
*
|
|
361
|
+
* // End timing and log the event with duration
|
|
362
|
+
* this.client.track('video_playback', {
|
|
363
|
+
* video_id: 'abc123',
|
|
364
|
+
* quality: 'HD'
|
|
365
|
+
* }); // Duration will be automatically added
|
|
366
|
+
*
|
|
367
|
+
* // Example for user interaction timing
|
|
368
|
+
* this.client.timeEvent('form_completion');
|
|
369
|
+
* // ... user fills out form ...
|
|
370
|
+
* this.client.track('form_completion', { form_type: 'contact' });
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
timeEvent(eventName: string): void;
|
|
374
|
+
/**
|
|
375
|
+
* Creates a new analytics event session for grouping related events.
|
|
376
|
+
*
|
|
377
|
+
* A session is a way of grouping events together for analysis. Each event tracked
|
|
378
|
+
* after calling this method will have the same session ID until a new session is created.
|
|
379
|
+
* Session IDs are randomly generated unless explicitly provided.
|
|
380
|
+
*
|
|
381
|
+
* This is useful for tracking user journeys, workflow completion, or grouping
|
|
382
|
+
* related interactions within a specific time period.
|
|
383
|
+
*
|
|
384
|
+
* @param id - Optional user-supplied session ID. If not provided, a random session ID will be generated
|
|
385
|
+
*
|
|
386
|
+
* ```typescript
|
|
387
|
+
* // Start a new session with auto-generated ID
|
|
388
|
+
* this.client.newEventSession();
|
|
389
|
+
* this.client.track('session_start');
|
|
390
|
+
* this.client.track('user_action_1');
|
|
391
|
+
* this.client.track('user_action_2');
|
|
392
|
+
*
|
|
393
|
+
* // Start a session with custom ID
|
|
394
|
+
* this.client.newEventSession('user-workflow-12345');
|
|
395
|
+
* this.client.track('workflow_start');
|
|
396
|
+
* this.client.track('step_completed', { step: 1 });
|
|
397
|
+
*
|
|
398
|
+
* // Start a new session for different workflow
|
|
399
|
+
* this.client.newEventSession();
|
|
400
|
+
* this.client.track('different_workflow_start');
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
newEventSession(id?: string): void;
|
|
404
|
+
/**
|
|
405
|
+
* Gets the root folder path utilized by this player device.
|
|
406
|
+
*
|
|
407
|
+
* This returns the base directory path where the Revel Digital player
|
|
408
|
+
* stores its files and resources on the local device.
|
|
409
|
+
*
|
|
410
|
+
* @returns Promise resolving to the path of the root folder
|
|
411
|
+
*
|
|
412
|
+
* ```typescript
|
|
413
|
+
* const rootPath = await this.client.getRevelRoot();
|
|
414
|
+
* console.log('Player root directory:', rootPath);
|
|
415
|
+
* // Use for constructing file paths or understanding storage structure
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
getRevelRoot(): Promise<string>;
|
|
419
|
+
/**
|
|
420
|
+
* Gets a map of commands currently active for this device.
|
|
421
|
+
*
|
|
422
|
+
* This returns the current command configuration that defines how the device
|
|
423
|
+
* responds to various command triggers and remote commands.
|
|
424
|
+
*
|
|
425
|
+
* @returns Promise resolving to a map of currently active commands
|
|
426
|
+
*
|
|
427
|
+
* ```typescript
|
|
428
|
+
* const commandMap = await this.client.getCommandMap();
|
|
429
|
+
* console.log('Active commands:', commandMap);
|
|
430
|
+
*
|
|
431
|
+
* // Check if specific command is available
|
|
432
|
+
* if (commandMap['customCommand']) {
|
|
433
|
+
* console.log('Custom command is available');
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
getCommandMap(): Promise<any>;
|
|
438
|
+
/**
|
|
439
|
+
* Signals to the player that this gadget has completed its visualization.
|
|
440
|
+
*
|
|
441
|
+
* This method notifies the player that the current gadget has finished its
|
|
442
|
+
* content display or interaction cycle. The player can then proceed with
|
|
443
|
+
* the next item in a playlist if applicable, or handle the completion
|
|
444
|
+
* according to its configuration.
|
|
445
|
+
*
|
|
446
|
+
* Call this method when your gadget has completed its intended function,
|
|
447
|
+
* such as finishing an animation, completing a form, or reaching a natural
|
|
448
|
+
* stopping point.
|
|
449
|
+
*
|
|
450
|
+
* ```typescript
|
|
451
|
+
* // After completing an animation
|
|
452
|
+
* private onAnimationComplete(): void {
|
|
453
|
+
* this.client.finish();
|
|
454
|
+
* }
|
|
455
|
+
*
|
|
456
|
+
* // After user interaction is complete
|
|
457
|
+
* private onFormSubmitted(): void {
|
|
458
|
+
* this.saveFormData();
|
|
459
|
+
* this.client.finish();
|
|
460
|
+
* }
|
|
461
|
+
*
|
|
462
|
+
* // After a timed display period
|
|
463
|
+
* setTimeout(() => {
|
|
464
|
+
* this.client.finish();
|
|
465
|
+
* }, 30000); // 30 seconds
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
finish(): void;
|
|
469
|
+
/**
|
|
470
|
+
* Checks if the gadget is running in preview mode.
|
|
471
|
+
*
|
|
472
|
+
* Preview mode is enabled when the gadget is being edited in the Revel Digital CMS,
|
|
473
|
+
* tested in the gadget editor, or otherwise not running in a normal player environment.
|
|
474
|
+
* This is useful for providing different behavior during development/testing versus
|
|
475
|
+
* production deployment.
|
|
476
|
+
*
|
|
477
|
+
* @returns Promise resolving to true if running in preview mode, false if running on actual player
|
|
478
|
+
*
|
|
479
|
+
* ```typescript
|
|
480
|
+
* const isPreview = await this.client.isPreviewMode();
|
|
481
|
+
*
|
|
482
|
+
* if (isPreview) {
|
|
483
|
+
* console.log('Running in preview mode - using mock data');
|
|
484
|
+
* this.loadMockData();
|
|
485
|
+
* } else {
|
|
486
|
+
* console.log('Running on player device - using live data');
|
|
487
|
+
* this.loadLiveData();
|
|
488
|
+
* }
|
|
489
|
+
*
|
|
490
|
+
* // Show different UI in preview
|
|
491
|
+
* this.showPreviewIndicator = isPreview;
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
isPreviewMode(): Promise<boolean>;
|
|
495
|
+
/**
|
|
496
|
+
* Gets detailed information about the device running the player.
|
|
497
|
+
*
|
|
498
|
+
* Returns comprehensive device details including name, registration key, type,
|
|
499
|
+
* service date, language, timezone, tags, and location information. This data
|
|
500
|
+
* is configured in the Revel Digital CMS for each device.
|
|
501
|
+
*
|
|
502
|
+
* @returns Promise resolving to device details object, or null if not available
|
|
503
|
+
*
|
|
504
|
+
* ```typescript
|
|
505
|
+
* const device = await this.client.getDevice();
|
|
506
|
+
*
|
|
507
|
+
* if (device) {
|
|
508
|
+
* console.log('Device name:', device.name);
|
|
509
|
+
* console.log('Device type:', device.deviceType);
|
|
510
|
+
* console.log('Location:', device.location.city, device.location.state);
|
|
511
|
+
* console.log('Tags:', device.tags);
|
|
512
|
+
*
|
|
513
|
+
* // Use device info for customization
|
|
514
|
+
* if (device.location.country === 'US') {
|
|
515
|
+
* this.loadUSContent();
|
|
516
|
+
* }
|
|
517
|
+
*
|
|
518
|
+
* // Check device capabilities based on type
|
|
519
|
+
* if (device.deviceType === 'android') {
|
|
520
|
+
* this.enableTouchFeatures();
|
|
521
|
+
* }
|
|
522
|
+
* }
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
getDevice(): Promise<IDevice | null>;
|
|
526
|
+
/**
|
|
527
|
+
* Gets the width of the visualization area in pixels.
|
|
528
|
+
*
|
|
529
|
+
* This returns the available width for content display, which may be
|
|
530
|
+
* different from the full screen width depending on player configuration
|
|
531
|
+
* and template layout.
|
|
532
|
+
*
|
|
533
|
+
* @returns Promise resolving to width in pixels, or null if not available
|
|
534
|
+
*
|
|
535
|
+
* ```typescript
|
|
536
|
+
* const width = await this.client.getWidth();
|
|
537
|
+
*
|
|
538
|
+
* if (width) {
|
|
539
|
+
* console.log('Available width:', width, 'pixels');
|
|
540
|
+
*
|
|
541
|
+
* // Adapt content layout based on width
|
|
542
|
+
* if (width < 800) {
|
|
543
|
+
* this.enableMobileLayout();
|
|
544
|
+
* } else {
|
|
545
|
+
* this.enableDesktopLayout();
|
|
546
|
+
* }
|
|
547
|
+
* }
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
getWidth(): Promise<number | null>;
|
|
551
|
+
/**
|
|
552
|
+
* Gets the height of the visualization area in pixels.
|
|
553
|
+
*
|
|
554
|
+
* This returns the available height for content display, which may be
|
|
555
|
+
* different from the full screen height depending on player configuration
|
|
556
|
+
* and template layout.
|
|
557
|
+
*
|
|
558
|
+
* @returns Promise resolving to height in pixels, or null if not available
|
|
559
|
+
*
|
|
560
|
+
* ```typescript
|
|
561
|
+
* const height = await this.client.getHeight();
|
|
562
|
+
*
|
|
563
|
+
* if (height) {
|
|
564
|
+
* console.log('Available height:', height, 'pixels');
|
|
565
|
+
*
|
|
566
|
+
* // Calculate aspect ratio for responsive design
|
|
567
|
+
* const width = await this.client.getWidth();
|
|
568
|
+
* const aspectRatio = width / height;
|
|
569
|
+
* this.adjustContentForAspectRatio(aspectRatio);
|
|
570
|
+
* }
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
573
|
+
getHeight(): Promise<number | null>;
|
|
574
|
+
/**
|
|
575
|
+
* Gets the duration of the currently playing content item.
|
|
576
|
+
*
|
|
577
|
+
* This method is only applicable when the gadget is associated with a playlist
|
|
578
|
+
* and returns the duration assigned to the current playlist item. The duration
|
|
579
|
+
* determines how long the content should be displayed before moving to the next item.
|
|
580
|
+
*
|
|
581
|
+
* @returns Promise resolving to duration in milliseconds, or null if not applicable/available
|
|
582
|
+
*
|
|
583
|
+
* ```typescript
|
|
584
|
+
* const duration = await this.client.getDuration();
|
|
585
|
+
*
|
|
586
|
+
* if (duration) {
|
|
587
|
+
* console.log('Content duration:', duration, 'milliseconds');
|
|
588
|
+
*
|
|
589
|
+
* // Set up auto-finish timer
|
|
590
|
+
* setTimeout(() => {
|
|
591
|
+
* this.client.finish();
|
|
592
|
+
* }, duration);
|
|
593
|
+
*
|
|
594
|
+
* // Show progress indicator
|
|
595
|
+
* this.startProgressIndicator(duration);
|
|
596
|
+
* }
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
getDuration(): Promise<number | null>;
|
|
600
|
+
/**
|
|
601
|
+
* Gets the current version of the Revel Digital SDK.
|
|
602
|
+
*
|
|
603
|
+
* @returns Promise resolving to the SDK version string
|
|
604
|
+
*
|
|
605
|
+
* ```typescript
|
|
606
|
+
* const version = await this.client.getSdkVersion();
|
|
607
|
+
* console.log('SDK Version:', version);
|
|
608
|
+
*
|
|
609
|
+
* // Use for compatibility checks or logging
|
|
610
|
+
* this.client.track('gadget_loaded', { sdkVersion: version });
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
getSdkVersion(): Promise<string>;
|
|
614
|
+
/**
|
|
615
|
+
* Applies configuration preferences to the gadget (preview mode only).
|
|
616
|
+
*
|
|
617
|
+
* This method is only available when running in preview mode (typically during
|
|
618
|
+
* gadget development or testing in the CMS). It allows applying configuration
|
|
619
|
+
* changes that would normally come from the gadget's preference settings.
|
|
620
|
+
*
|
|
621
|
+
* @param prefs - Dictionary of preference key-value pairs to apply
|
|
622
|
+
*
|
|
623
|
+
* ```typescript
|
|
624
|
+
* if (await this.client.isPreviewMode()) {
|
|
625
|
+
* // Apply test configuration in preview
|
|
626
|
+
* await this.client.applyConfig({
|
|
627
|
+
* 'title': 'Test Title',
|
|
628
|
+
* 'backgroundColor': '#ff0000',
|
|
629
|
+
* 'showBorder': true,
|
|
630
|
+
* 'refreshInterval': 30
|
|
631
|
+
* });
|
|
632
|
+
* }
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
635
|
+
applyConfig(prefs: IDictionary<any>): Promise<void>;
|
|
636
|
+
/** @ignore */
|
|
637
|
+
private getClient;
|
|
638
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PlayerClientService, never>;
|
|
639
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PlayerClientService>;
|
|
640
|
+
}
|
|
641
641
|
//# sourceMappingURL=player-client.service.d.ts.map
|