@signageos/front-applet 6.0.0 → 6.1.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/CHANGELOG.md +13 -1
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/docs/js-api/js-video-stream.md +235 -26
- package/es6/FrontApplet/Input/Input.js +7 -1
- package/es6/FrontApplet/Input/Input.js.map +1 -1
- package/es6/FrontApplet/Stream/IStreamMessage.d.ts +2 -4
- package/es6/FrontApplet/Stream/IStreamTrackInfo.d.ts +23 -0
- package/es6/FrontApplet/Stream/{IStreamEventListener.js → IStreamTrackInfo.js} +1 -1
- package/es6/FrontApplet/Stream/IStreamTrackInfo.js.map +1 -0
- package/es6/FrontApplet/Stream/Stream.d.ts +13 -7
- package/es6/FrontApplet/Stream/Stream.js +85 -20
- package/es6/FrontApplet/Stream/Stream.js.map +1 -1
- package/es6/FrontApplet/Stream/streamEventProperties.d.ts +21 -0
- package/es6/FrontApplet/Stream/{IStreamEventProperties.js → streamEventProperties.js} +1 -1
- package/es6/FrontApplet/Stream/streamEventProperties.js.map +1 -0
- package/es6/FrontApplet/Stream/streamEvents.d.ts +13 -0
- package/es6/FrontApplet/Stream/streamEvents.js +3 -0
- package/es6/FrontApplet/Stream/streamEvents.js.map +1 -0
- package/es6/FrontApplet/Stream/streamListeners.d.ts +10 -0
- package/es6/FrontApplet/Stream/streamListeners.js +3 -0
- package/es6/FrontApplet/Stream/streamListeners.js.map +1 -0
- package/es6/FrontApplet/Video/IOptions.d.ts +24 -1
- package/package.json +9 -8
- package/es6/FrontApplet/Stream/IStreamEvent.d.ts +0 -9
- package/es6/FrontApplet/Stream/IStreamEvent.js +0 -5
- package/es6/FrontApplet/Stream/IStreamEvent.js.map +0 -1
- package/es6/FrontApplet/Stream/IStreamEventListener.d.ts +0 -5
- package/es6/FrontApplet/Stream/IStreamEventListener.js.map +0 -1
- package/es6/FrontApplet/Stream/IStreamEventProperties.d.ts +0 -10
- package/es6/FrontApplet/Stream/IStreamEventProperties.js.map +0 -1
|
@@ -21,18 +21,27 @@ Methods to play or stop video streams.
|
|
|
21
21
|
| `prepare()` | Prepare video stream in the background | 4.7.0 |
|
|
22
22
|
| `play()` | Start playing video stream | 1.0.18 |
|
|
23
23
|
| `stop()` | Stop video stream | 1.0.18 |
|
|
24
|
+
| `getTracks()` | Get all tracks of the stream | 6.1.0 |
|
|
25
|
+
| `selectTrack()` | Select track of the stream | 6.1.0 |
|
|
26
|
+
| `resetTrack()` | Reset track of the stream | 6.1.0 |
|
|
24
27
|
| `onConnected()` | Calls a listener callback when stream connects | 1.0.20 |
|
|
25
28
|
| `onDisconnected()` | Calls a listener callback when stream disconnects | 1.0.20 |
|
|
26
29
|
| `onError()` | Calls a listener callback when an unexpected stream error occurs | 1.0.20 |
|
|
27
30
|
| `onPlay()` | Calls a listener callback when stream starts playing | 5.12.0 |
|
|
28
31
|
| `onStop()` | Calls a listener callback when stream stops | 5.12.0 |
|
|
29
32
|
| `onPrepare()` | Calls a listener callback when stream prepares | 5.12.0 |
|
|
33
|
+
| `onTracksChanged()`| Calls a listener callback when stream tracks change | 6.1.0 |
|
|
30
34
|
:::
|
|
31
35
|
|
|
32
36
|
::: alert alert--warning
|
|
33
37
|
Are you using **Samsung Tizen** to play streams? [Read more about limitation and Tizen-specific details](https://docs.signageos.io/hc/en-us/articles/4405387373458).
|
|
34
38
|
:::
|
|
35
39
|
|
|
40
|
+
::: alert alert--danger
|
|
41
|
+
Be aware version of JS API (v6.0.0+) changed how stream functions `play()` and `prepare()` work. For using an options object
|
|
42
|
+
you need to our latest core app versions. If you are using older core app versions, you need to use deprecated format.
|
|
43
|
+
:::
|
|
44
|
+
|
|
36
45
|
## prepare()
|
|
37
46
|
Calls the internal player and prepares a video stream in memory, so it can later start playing instantaneously.
|
|
38
47
|
|
|
@@ -49,18 +58,44 @@ If you want to play a video stream in full screen mode, use x = y = 0 and width
|
|
|
49
58
|
| `y` | Number | <div class="red">Yes</div> | Stream y-position on the screen |
|
|
50
59
|
| `width` | Number | <div class="red">Yes</div> | Stream width on the screen |
|
|
51
60
|
| `height` | Number | <div class="red">Yes</div> | Stream height on the screen |
|
|
52
|
-
| `options` | Object | <div class="red">Yes</div> | Additional options for the stream
|
|
61
|
+
| `options` | Object | <div class="red">Yes</div> | Additional options for the stream |
|
|
53
62
|
:::
|
|
54
63
|
|
|
55
64
|
### Options object
|
|
56
65
|
::: table-responsive
|
|
57
66
|
| Key | Type | Required | Description |
|
|
58
67
|
| ------------ | --------------------------- | :--------------------------: | --------------------------------------------- |
|
|
59
|
-
| `protocol` | String | <div class="red">Yes</div>
|
|
68
|
+
| `protocol` | String | <div class="red">Yes</div> | Protocol that the stream is using |
|
|
60
69
|
|^^|^^|^^| Types: `HLS`, `RTP`, `HTTP`, `UDP`, `RTMP`, `RTSP`. |
|
|
61
|
-
| `background` | Boolean | <div class="yellow">No</div> | Prepare stream in the background
|
|
70
|
+
| `background` | Boolean | <div class="yellow">No</div> | Prepare stream in the background |
|
|
71
|
+
| `trackSelection`| Object | <div class="yellow">No</div> | Track selection options |
|
|
72
|
+
| `drm` | Object | <div class="yellow">No</div> | DRM options |
|
|
73
|
+
:::
|
|
74
|
+
|
|
75
|
+
### Track selection object
|
|
76
|
+
::: table-responsive
|
|
77
|
+
| Key | Type | Required | Description |
|
|
78
|
+
| ------------ | --------------------------- | :--------------------------: | --------------------------------------------- |
|
|
79
|
+
| `maxAudioChannelCount` | Number | <div class="yellow">No</div> | Maximum number of audio channels to play |
|
|
80
|
+
| `minVideoSize` | Object | <div class="yellow">No</div> | Minimum video size to play |
|
|
81
|
+
|^^|^^|^^| Object with `width` and `height` properties |
|
|
82
|
+
| `maxVideoSize` | Object | <div class="yellow">No</div> | Maximum video size to play |
|
|
83
|
+
|^^|^^|^^| Object with `width` and `height` properties |
|
|
84
|
+
| `preferredAudioLanguages` | Array of strings | <div class="yellow">No</div> | Preferred audio languages to play |
|
|
85
|
+
| `preferredTextLanguages` | Array of strings | <div class="yellow">No</div> | Preferred text languages to play |
|
|
86
|
+
:::
|
|
87
|
+
|
|
88
|
+
### DRM object
|
|
89
|
+
::: table-responsive
|
|
90
|
+
| Key | Type | Required | Description |
|
|
91
|
+
| ------------ | --------------------------- | :--------------------------: | --------------------------------------------- |
|
|
92
|
+
| `scheme` | String | <div class="red">Yes</div> | DRM scheme |
|
|
93
|
+
|^^|^^|^^| Types: `CommonPSSH`, `ClearKey`, `Widevine`, `PlayReady` or own value |
|
|
94
|
+
| `licenseUri` | String | <div class="red">Yes</div> | DRM license URI |
|
|
95
|
+
| `licenseRequestHeaders` | Object | <div class="yellow">No</div> | DRM license request headers |
|
|
62
96
|
:::
|
|
63
97
|
|
|
98
|
+
|
|
64
99
|
### Javascript syntax
|
|
65
100
|
```javascript
|
|
66
101
|
// Example with specific protocol type
|
|
@@ -118,6 +153,9 @@ If you want to play a video stream in full screen mode, use x = y = 0 and width
|
|
|
118
153
|
|^^|^^|^^| Default value: false |
|
|
119
154
|
| `autoReconnectInterval` | Number | <div class="yellow">No</div> | Interval in miliseconds between reconnect attempts |
|
|
120
155
|
|^^|^^|^^| Default value: 30000 ms |
|
|
156
|
+
| `volume` | Number | <div class="yellow">No</div> | Volume of the stream |
|
|
157
|
+
| `trackSelection`| Object | <div class="yellow">No</div> | Track selection options |
|
|
158
|
+
| `drm` | Object | <div class="yellow">No</div> | DRM options |
|
|
121
159
|
:::
|
|
122
160
|
|
|
123
161
|
### Javascript syntax
|
|
@@ -170,6 +208,84 @@ await sos.stream.stop(uri, x, y, width, height);
|
|
|
170
208
|
| `height` | Number | <div class="red">Yes</div> | Stream height on the screen |
|
|
171
209
|
:::
|
|
172
210
|
|
|
211
|
+
## getTracks()
|
|
212
|
+
Get all tracks of the selected stream.
|
|
213
|
+
|
|
214
|
+
### Javascript syntax
|
|
215
|
+
```javascript
|
|
216
|
+
const videoId = {
|
|
217
|
+
uri: 'http://example.com/stream.m3u8',
|
|
218
|
+
x: 0,
|
|
219
|
+
y: 0,
|
|
220
|
+
width: 1920,
|
|
221
|
+
height: 1080,
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const tracks = await sos.stream.getTracks(videoId); // Promise<ITrackInfo[]>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Parameters:
|
|
228
|
+
::: table-responsive
|
|
229
|
+
| Param | Type | Required | Description |
|
|
230
|
+
| -------------- | --------------------------- | :------------------------: | --------------------------------------------- |
|
|
231
|
+
| `videoId` | Object | <div class="red">Yes</div> | Video ID object of selected stream |
|
|
232
|
+
:::
|
|
233
|
+
|
|
234
|
+
### Example of returned value
|
|
235
|
+
```javascript
|
|
236
|
+
[
|
|
237
|
+
{
|
|
238
|
+
trackType: 'VIDEO', // string - AUDIO, VIDEO, TEXT
|
|
239
|
+
mimeType: 'video/mp4', // string
|
|
240
|
+
videoSize: { // object
|
|
241
|
+
width: 1920, // number
|
|
242
|
+
height: 1080, // number
|
|
243
|
+
},
|
|
244
|
+
groupId: '1', // string
|
|
245
|
+
trackIndex: 1, // number
|
|
246
|
+
selected: true, // boolean
|
|
247
|
+
language: 'en', // string
|
|
248
|
+
supported: true, // boolean
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## selectTrack()
|
|
254
|
+
Select track of the selected stream.
|
|
255
|
+
|
|
256
|
+
### Javascript syntax
|
|
257
|
+
```javascript
|
|
258
|
+
await sos.stream.selectTrack(videoId, trackType, groupId, trackIndex); // Promise<void>
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Parameters:
|
|
262
|
+
::: table-responsive
|
|
263
|
+
| Param | Type | Required | Description |
|
|
264
|
+
| -------------- | --------------------------- | :------------------------: | --------------------------------------------- |
|
|
265
|
+
| `videoId` | Object | <div class="red">Yes</div> | Video ID object of selected stream |
|
|
266
|
+
| `trackType` | String | <div class="red">Yes</div> | Track type - `AUDIO`, `VIDEO`, `TEXT` |
|
|
267
|
+
| `groupId` | String | <div class="red">Yes</div> | Group ID of selected track |
|
|
268
|
+
| `trackIndex` | Number | <div class="red">Yes</div> | Index of selected track |
|
|
269
|
+
:::
|
|
270
|
+
|
|
271
|
+
## resetTrack()
|
|
272
|
+
Reset track of the selected stream.
|
|
273
|
+
|
|
274
|
+
### Javascript syntax
|
|
275
|
+
```javascript
|
|
276
|
+
await sos.stream.resetTrack(videoId, trackType); // Promise<void>
|
|
277
|
+
await sos.stream.resetTrack(videoId, trackType, groupId); // Promise<void>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Parameters:
|
|
281
|
+
::: table-responsive
|
|
282
|
+
| Param | Type | Required | Description |
|
|
283
|
+
| -------------- | --------------------------- | :------------------------: | --------------------------------------------- |
|
|
284
|
+
| `videoId` | Object | <div class="red">Yes</div> | Video ID object of selected stream |
|
|
285
|
+
| `trackType` | String | <div class="red">Yes</div> | Track type - `AUDIO`, `VIDEO`, `TEXT` |
|
|
286
|
+
| `groupId` | String | <div class="yellow">No</div> | Group ID of selected track |
|
|
287
|
+
:::
|
|
288
|
+
|
|
173
289
|
## Event onConnected()
|
|
174
290
|
Calls a listener callback everytime `connected` event is emitted.
|
|
175
291
|
|
|
@@ -230,38 +346,76 @@ sos.stream.onPrepare((event) => {
|
|
|
230
346
|
});
|
|
231
347
|
```
|
|
232
348
|
|
|
349
|
+
## Event onTracksChanged()
|
|
350
|
+
Calls a listener callback everytime `tracks_changed` event is emitted.
|
|
351
|
+
|
|
352
|
+
### Javascript syntax
|
|
353
|
+
```javascript
|
|
354
|
+
sos.stream.onTracksChanged((event) => {
|
|
355
|
+
// do something
|
|
356
|
+
});
|
|
357
|
+
```
|
|
358
|
+
|
|
233
359
|
## Stream events
|
|
234
360
|
All stream events have the same format.
|
|
235
361
|
|
|
236
|
-
`type` property contains string with the event type. Type can be `connected`, `disconnected` or `
|
|
362
|
+
`type` property contains string with the event type. Type can be `connected`, `disconnected`, `error` or `tracks_changed`.
|
|
237
363
|
|
|
238
364
|
`srcArguments` property contains parameters of the source stream, that emitted the event.
|
|
239
365
|
That way, if multiple streams are playing at once, you can associate the events with each stream instance.
|
|
240
366
|
|
|
241
|
-
Example event:
|
|
367
|
+
Example of **connected**, **disconnected** event:
|
|
242
368
|
```json
|
|
243
369
|
{
|
|
244
|
-
"type": "
|
|
370
|
+
"type": "<type>",
|
|
245
371
|
"srcArguments": {
|
|
246
372
|
"uri": "<uri>",
|
|
247
373
|
"x": 0,
|
|
248
374
|
"y": 0,
|
|
249
375
|
"width": 1920,
|
|
250
376
|
"height": 1080,
|
|
251
|
-
"
|
|
252
|
-
"protocol": "RTP",
|
|
253
|
-
"background": false,
|
|
254
|
-
"autoReconnect": true,
|
|
255
|
-
"autoReconnectInterval": 30000,
|
|
256
|
-
},
|
|
377
|
+
"protocol": "HTTP"
|
|
257
378
|
}
|
|
258
379
|
}
|
|
259
380
|
```
|
|
260
381
|
|
|
382
|
+
Example of **tracks_changed** event:
|
|
383
|
+
```json
|
|
384
|
+
{
|
|
385
|
+
"type": "tracks_changed",
|
|
386
|
+
"srcArguments": {
|
|
387
|
+
"uri": "<uri>",
|
|
388
|
+
"x": 0,
|
|
389
|
+
"y": 0,
|
|
390
|
+
"width": 1920,
|
|
391
|
+
"height": 1080,
|
|
392
|
+
"tracks": [] // Array of ITrackInfo
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Example of **error** event:
|
|
398
|
+
```json
|
|
399
|
+
{
|
|
400
|
+
"type": "error",
|
|
401
|
+
"srcArguments": {
|
|
402
|
+
"uri": "<uri>",
|
|
403
|
+
"x": 0,
|
|
404
|
+
"y": 0,
|
|
405
|
+
"width": 1920,
|
|
406
|
+
"height": 1080,
|
|
407
|
+
"protocol": "HTTP"
|
|
408
|
+
},
|
|
409
|
+
"errorMessage": "Some error message"
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
261
413
|
## Usage with Typescript
|
|
262
414
|
You can also use all these methods with [signageOS TypeScript](https://docs.signageos.io/hc/en-us/articles/4405069154962#signageos-typescript).
|
|
263
415
|
|
|
264
416
|
```typescript
|
|
417
|
+
type StreamProtocol = 'HLS' | 'RTP' | 'HTTP' | 'UDP' | 'RTMP' | 'RTSP';
|
|
418
|
+
type DrmScheme = "CommonPSSH" | "ClearKey" | "Widevine" | "PlayReady" | string;
|
|
265
419
|
interface StreamEvent {
|
|
266
420
|
type: 'connected' | 'disconnected' | 'error' | 'stop' | 'prepare' | 'play',
|
|
267
421
|
srcArguments: {
|
|
@@ -270,40 +424,91 @@ interface StreamEvent {
|
|
|
270
424
|
y: number;
|
|
271
425
|
width: number;
|
|
272
426
|
height: number;
|
|
427
|
+
protocol?: StreamProtocol;
|
|
273
428
|
},
|
|
429
|
+
}
|
|
430
|
+
interface IVideoProperties {
|
|
431
|
+
uri: string;
|
|
432
|
+
x: number;
|
|
433
|
+
y: number;
|
|
434
|
+
width: number;
|
|
435
|
+
height: number;
|
|
436
|
+
}
|
|
437
|
+
type TrackType = 'AUDIO' | 'VIDEO' | 'TEXT';
|
|
438
|
+
type ITrackInfo = IVideoTrack | IAudioTrack | ITextTrack;
|
|
439
|
+
interface ITrack<T extends TrackType> {
|
|
440
|
+
trackType: T;
|
|
441
|
+
mimeType: string;
|
|
442
|
+
groupId: string;
|
|
443
|
+
trackIndex: number;
|
|
444
|
+
selected: boolean;
|
|
445
|
+
language: string | null;
|
|
446
|
+
supported: boolean;
|
|
447
|
+
}
|
|
448
|
+
interface IVideoTrack extends ITrack<'VIDEO'> {
|
|
449
|
+
videoSize: { width: number; height: number };
|
|
450
|
+
}
|
|
451
|
+
interface IAudioTrack extends ITrack<'AUDIO'> {
|
|
452
|
+
channelCount: number;
|
|
453
|
+
}
|
|
454
|
+
interface ITextTrack extends ITrack<'TEXT'> {
|
|
455
|
+
selection: 'default' | 'forced' | 'autoselect';
|
|
456
|
+
}
|
|
457
|
+
prepare(
|
|
458
|
+
uri: string;
|
|
459
|
+
x: number;
|
|
460
|
+
y: number;
|
|
461
|
+
width: number;
|
|
462
|
+
height: number;
|
|
274
463
|
options: {
|
|
275
|
-
protocol:
|
|
464
|
+
protocol: StreamProtocol;
|
|
276
465
|
background?: boolean;
|
|
277
466
|
autoReconnect?: boolean;
|
|
278
467
|
autoReconnectInterval?: number;
|
|
468
|
+
trackSelection?: {
|
|
469
|
+
maxAudioChannelCount?: number;
|
|
470
|
+
minVideoSize?: { width: number; height: number };
|
|
471
|
+
maxVideoSize?: { width: number; height: number };
|
|
472
|
+
preferredAudioLanguages?: string[];
|
|
473
|
+
preferredTextLanguages?: string[];
|
|
474
|
+
};
|
|
475
|
+
drm?: {
|
|
476
|
+
scheme: DrmScheme;
|
|
477
|
+
licenseUri: string;
|
|
478
|
+
licenseRequestHeaders: { [key: string]: string };
|
|
479
|
+
};
|
|
279
480
|
}
|
|
280
|
-
|
|
481
|
+
): Promise<void>;
|
|
281
482
|
play(
|
|
282
|
-
uri:
|
|
283
|
-
x:
|
|
284
|
-
y:
|
|
285
|
-
width:
|
|
286
|
-
height:
|
|
483
|
+
uri: string;
|
|
484
|
+
x: number;
|
|
485
|
+
y: number;
|
|
486
|
+
width: number;
|
|
487
|
+
height: number;
|
|
287
488
|
options: {
|
|
288
|
-
protocol:
|
|
489
|
+
protocol: StreamProtocol;
|
|
289
490
|
background?: boolean;
|
|
290
491
|
autoReconnect?: boolean;
|
|
291
492
|
autoReconnectInterval?: number;
|
|
292
493
|
}
|
|
293
494
|
): Promise<void>;
|
|
294
495
|
stop(
|
|
295
|
-
uri:
|
|
296
|
-
x:
|
|
297
|
-
y:
|
|
298
|
-
width:
|
|
299
|
-
height:
|
|
496
|
+
uri: string,
|
|
497
|
+
x: number,
|
|
498
|
+
y: number,
|
|
499
|
+
width: number,
|
|
500
|
+
height: number
|
|
300
501
|
): Promise<void>;
|
|
502
|
+
getTracks(videoId: IVideoProperties): Promise<ITrackInfo[]>;
|
|
503
|
+
selectTrack(videoId: IVideoProperties, trackType: TrackType, groupId: string, trackIndex: number): Promise<void>;
|
|
504
|
+
resetTrack(videoId: IVideoProperties, trackType: TrackType, groupId?: string): Promise<void>;
|
|
301
505
|
onConnected(listener: (event: StreamEvent) => void): void;
|
|
302
506
|
onDisconnected(listener: (event: StreamEvent) => void): void;
|
|
303
|
-
onError(listener: (event:
|
|
507
|
+
onError(listener: (event: StreamErrorEvent) => void): void;
|
|
304
508
|
onPlay(listener: (event: StreamEvent) => void): void;
|
|
305
509
|
onStop(listener: (event: StreamEvent) => void): void;
|
|
306
510
|
onPrepare(listener: (event: StreamEvent) => void): void;
|
|
511
|
+
onTracksChanged(listener: (event: StreamTracksChangedEvent) => void): void;
|
|
307
512
|
```
|
|
308
513
|
|
|
309
514
|
## Errors
|
|
@@ -315,4 +520,8 @@ Although we are doing our best, following errors may occur when working with the
|
|
|
315
520
|
| 41401 | AppletStreamError | Invalid stream protocol type: `protocol` |
|
|
316
521
|
| 51301 | InternalStreamError | Couldn't stop the stream before playing the new one. |
|
|
317
522
|
| 51301 | InternalStreamError | Couldn't stop the stream. |
|
|
523
|
+
| 51302 | InternalStreamError | Couldn't prepare the stream. |
|
|
524
|
+
| 51303 | InternalStreamError | Couldn't get stream tracks. |
|
|
525
|
+
| 51304 | InternalStreamError | Couldn't select stream track. |
|
|
526
|
+
| 51305 | InternalStreamError | Couldn't reset stream track. |
|
|
318
527
|
:::
|
|
@@ -39,8 +39,14 @@ class Input {
|
|
|
39
39
|
this.eventEmitter.removeAllListeners();
|
|
40
40
|
}
|
|
41
41
|
dispatchEventToParent(event) {
|
|
42
|
+
var _a, _b, _c;
|
|
42
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
this.window.parent.document.dispatchEvent
|
|
44
|
+
if ((_c = (_b = (_a = this.window) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.document) === null || _c === void 0 ? void 0 : _c.dispatchEvent) {
|
|
45
|
+
this.window.parent.document.dispatchEvent(new KeyboardEvent('keyup', event));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.warn('Parent window or document is not defined');
|
|
49
|
+
}
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
getMessage(name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/FrontApplet/Input/Input.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAsC;AAItC,mDAA4C;AAE5C,MAAqB,KAAK;IAIzB,YAA4B,MAAc,EAAU,aAAqB;QAA7C,WAAM,GAAN,MAAM,CAAQ;QAAU,kBAAa,GAAb,aAAa,CAAQ;QACxE,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAY,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;IACpG,CAAC;IAEM,OAAO,CAAC,QAA6B;QAC3C,kBAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IAEM,iBAAiB,CAAC,IAAsB;QAC9C,QAAQ,IAAI,CAAC,IAAI,EAAE;YAClB,KAAK,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBAC5B,MAAM,UAAU,GAAgB;oBAC/B,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,OAAO,EAAE,IAAI,CAAC,OAAO;iBACrB,CAAC;gBACF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAC5C,MAAM;YACP,QAAQ;SACR;IACF,CAAC;IAEM,oBAAoB;QAC1B,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC;IACxC,CAAC;IAEa,qBAAqB,CAAC,KAAoB
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/FrontApplet/Input/Input.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAsC;AAItC,mDAA4C;AAE5C,MAAqB,KAAK;IAIzB,YAA4B,MAAc,EAAU,aAAqB;QAA7C,WAAM,GAAN,MAAM,CAAQ;QAAU,kBAAa,GAAb,aAAa,CAAQ;QACxE,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAY,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;IACpG,CAAC;IAEM,OAAO,CAAC,QAA6B;QAC3C,kBAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;IAEM,iBAAiB,CAAC,IAAsB;QAC9C,QAAQ,IAAI,CAAC,IAAI,EAAE;YAClB,KAAK,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBAC5B,MAAM,UAAU,GAAgB;oBAC/B,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,OAAO,EAAE,IAAI,CAAC,OAAO;iBACrB,CAAC;gBACF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAC5C,MAAM;YACP,QAAQ;SACR;IACF,CAAC;IAEM,oBAAoB;QAC1B,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC;IACxC,CAAC;IAEa,qBAAqB,CAAC,KAAoB;;;YACvD,IAAI,MAAA,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,MAAM,0CAAE,QAAQ,0CAAE,aAAa,EAAE;gBACjD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;aAC7E;iBAAM;gBACN,OAAO,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;aACzD;;KACD;IAEO,UAAU,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,aAAa,GAAG,GAAG,GAAG,KAAK,CAAC,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC;IACrE,CAAC;;AA1CF,wBA2CC;AA1Cc,oBAAc,GAAW,OAAO,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import IMessage from '../IMessage';
|
|
2
|
-
import IStreamEventProperties from './
|
|
3
|
-
declare type IStreamMessage = IMessage & IStreamEventProperties &
|
|
4
|
-
errorMessage?: string;
|
|
5
|
-
};
|
|
2
|
+
import { IStreamErrorEventProperties, IStreamEventProperties, IStreamTracksChangedEventProperties } from './streamEventProperties';
|
|
3
|
+
declare type IStreamMessage = IMessage & IStreamEventProperties & IStreamErrorEventProperties & IStreamTracksChangedEventProperties;
|
|
6
4
|
export default IStreamMessage;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO';
|
|
2
|
+
export declare type ITrackInfo = ITrackVideoInfo | ITrackAudioInfo | ITrackTextInfo;
|
|
3
|
+
export interface ITrack<T extends TrackType> {
|
|
4
|
+
trackType: T;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
groupId: string;
|
|
7
|
+
trackIndex: number;
|
|
8
|
+
selected: boolean;
|
|
9
|
+
language: string | null;
|
|
10
|
+
supported: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ITrackVideoInfo extends ITrack<'VIDEO'> {
|
|
13
|
+
videoSize: {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface ITrackAudioInfo extends ITrack<'AUDIO'> {
|
|
19
|
+
channelCount: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ITrackTextInfo extends ITrack<'TEXT'> {
|
|
22
|
+
selection: string[];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IStreamTrackInfo.js","sourceRoot":"","sources":["../../../src/FrontApplet/Stream/IStreamTrackInfo.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import IPostMessage from '../IPostMessage';
|
|
2
2
|
import StreamProtocol from './StreamProtocol';
|
|
3
3
|
import IStreamMessage from './IStreamMessage';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { IStreamOptions, IStreamPrepareOptions } from '../Video/IOptions';
|
|
5
|
+
import { ITrackInfo, TrackType } from './IStreamTrackInfo';
|
|
6
|
+
import { IStreamErrorEventListener, IStreamEventListener, IStreamTracksChangedEventListener } from './streamListeners';
|
|
7
|
+
import IVideoProperties from '../Video/IVideoProperties';
|
|
6
8
|
export default class Stream {
|
|
7
9
|
private messagePrefix;
|
|
8
10
|
private postMessage;
|
|
9
11
|
static MESSAGE_PREFIX: string;
|
|
10
12
|
private eventEmitter;
|
|
11
|
-
constructor(messagePrefix: string, postMessage: IPostMessage<
|
|
12
|
-
prepare(uri: string, x: number, y: number, width: number, height: number, options?:
|
|
13
|
-
play(uri: string, x: number, y: number, width: number, height: number, options?: IStreamOptions | keyof typeof StreamProtocol): Promise<
|
|
14
|
-
stop(uri: string, x: number, y: number, width: number, height: number): Promise<
|
|
15
|
-
|
|
13
|
+
constructor(messagePrefix: string, postMessage: IPostMessage<any>);
|
|
14
|
+
prepare(uri: string, x: number, y: number, width: number, height: number, options?: IStreamPrepareOptions | keyof typeof StreamProtocol): Promise<any>;
|
|
15
|
+
play(uri: string, x: number, y: number, width: number, height: number, options?: IStreamOptions | keyof typeof StreamProtocol): Promise<any>;
|
|
16
|
+
stop(uri: string, x: number, y: number, width: number, height: number): Promise<any>;
|
|
17
|
+
getTracks(videoId: IVideoProperties): Promise<ITrackInfo[]>;
|
|
18
|
+
selectTrack(videoId: IVideoProperties, trackType: TrackType, groupId: string, trackIndex: number): Promise<void>;
|
|
19
|
+
resetTrack(videoId: IVideoProperties, trackType: TrackType, groupId?: string): Promise<void>;
|
|
20
|
+
onTracksChanged(listener: IStreamTracksChangedEventListener): void;
|
|
21
|
+
onError(listener: IStreamErrorEventListener): void;
|
|
16
22
|
onConnected(listener: IStreamEventListener<'connected'>): void;
|
|
17
23
|
onDisconnected(listener: IStreamEventListener<'disconnected'>): void;
|
|
18
24
|
onPrepare(listener: IStreamEventListener<'prepare'>): void;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const events_1 = require("events");
|
|
4
|
-
const StreamProtocol_1 = require("./StreamProtocol");
|
|
5
13
|
const AppletStreamError_1 = require("../Error/AppletStreamError");
|
|
6
14
|
const ErrorCodes_1 = require("../Error/ErrorCodes");
|
|
7
15
|
const Validate_1 = require("../Validate/Validate");
|
|
@@ -13,13 +21,24 @@ class Stream {
|
|
|
13
21
|
this.eventEmitter = new events_1.EventEmitter();
|
|
14
22
|
}
|
|
15
23
|
prepare(uri, x, y, width, height, options) {
|
|
16
|
-
let streamOptions
|
|
24
|
+
let streamOptions;
|
|
17
25
|
if (typeof options === 'string') {
|
|
18
26
|
streamOptions = { protocol: options };
|
|
19
27
|
}
|
|
20
|
-
else
|
|
28
|
+
else {
|
|
21
29
|
streamOptions = options;
|
|
22
30
|
}
|
|
31
|
+
let protocol = undefined;
|
|
32
|
+
if ((streamOptions === null || streamOptions === void 0 ? void 0 : streamOptions.protocol) && streamOptions.protocol !== undefined) {
|
|
33
|
+
protocol = streamOptions.protocol;
|
|
34
|
+
}
|
|
35
|
+
if (protocol && typeof protocol !== 'string') {
|
|
36
|
+
throw new AppletStreamError_1.default({
|
|
37
|
+
kind: 'appletStreamError',
|
|
38
|
+
message: 'Invalid format of protocol, must be string.',
|
|
39
|
+
code: ErrorCodes_1.default.STREAM_INVALID_PROTOCOL_TYPE,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
23
42
|
this.checkParamsValidity(uri, x, y, width, height);
|
|
24
43
|
this.createAndEmitEvent('prepare', {
|
|
25
44
|
type: 'prepare',
|
|
@@ -29,7 +48,7 @@ class Stream {
|
|
|
29
48
|
y,
|
|
30
49
|
width,
|
|
31
50
|
height,
|
|
32
|
-
|
|
51
|
+
protocol,
|
|
33
52
|
},
|
|
34
53
|
});
|
|
35
54
|
return this.postMessage({
|
|
@@ -39,31 +58,32 @@ class Stream {
|
|
|
39
58
|
y,
|
|
40
59
|
width,
|
|
41
60
|
height,
|
|
61
|
+
protocol,
|
|
42
62
|
options: streamOptions,
|
|
43
63
|
});
|
|
44
64
|
}
|
|
45
65
|
play(uri, x, y, width, height, options) {
|
|
46
|
-
let streamOptions
|
|
66
|
+
let streamOptions;
|
|
47
67
|
if (typeof options === 'string') {
|
|
48
68
|
// Legacy format
|
|
49
69
|
streamOptions = { protocol: options };
|
|
50
70
|
}
|
|
51
|
-
else
|
|
71
|
+
else {
|
|
52
72
|
// New format
|
|
53
73
|
streamOptions = options;
|
|
54
74
|
}
|
|
75
|
+
let protocol = undefined;
|
|
76
|
+
if ((streamOptions === null || streamOptions === void 0 ? void 0 : streamOptions.protocol) && streamOptions.protocol !== undefined) {
|
|
77
|
+
protocol = streamOptions.protocol;
|
|
78
|
+
}
|
|
55
79
|
this.checkParamsValidity(uri, x, y, width, height);
|
|
56
80
|
({ x, y, width, height } = coordinationsHelper_1.sanitizeCoordinations({ x, y, width, height }));
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
message: 'Invalid stream protocol type: ' + streamOptions.protocol,
|
|
64
|
-
code: ErrorCodes_1.default.STREAM_INVALID_PROTOCOL_TYPE,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
81
|
+
if (protocol && typeof protocol !== 'string') {
|
|
82
|
+
throw new AppletStreamError_1.default({
|
|
83
|
+
kind: 'appletStreamError',
|
|
84
|
+
message: 'Invalid format of protocol, must be string.',
|
|
85
|
+
code: ErrorCodes_1.default.STREAM_INVALID_PROTOCOL_TYPE,
|
|
86
|
+
});
|
|
67
87
|
}
|
|
68
88
|
this.createAndEmitEvent('play', {
|
|
69
89
|
type: 'play',
|
|
@@ -73,7 +93,7 @@ class Stream {
|
|
|
73
93
|
y,
|
|
74
94
|
width,
|
|
75
95
|
height,
|
|
76
|
-
|
|
96
|
+
protocol,
|
|
77
97
|
},
|
|
78
98
|
});
|
|
79
99
|
return this.postMessage({
|
|
@@ -83,6 +103,7 @@ class Stream {
|
|
|
83
103
|
y,
|
|
84
104
|
width,
|
|
85
105
|
height,
|
|
106
|
+
protocol,
|
|
86
107
|
options: streamOptions,
|
|
87
108
|
});
|
|
88
109
|
}
|
|
@@ -108,6 +129,36 @@ class Stream {
|
|
|
108
129
|
height,
|
|
109
130
|
});
|
|
110
131
|
}
|
|
132
|
+
getTracks(videoId) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
Validate_1.default({ videoId }).required().object();
|
|
135
|
+
const { tracks } = yield this.postMessage({ type: this.getMessage('get_tracks'), videoId });
|
|
136
|
+
return tracks;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
selectTrack(videoId, trackType, groupId, trackIndex) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
Validate_1.default({ videoId }).required().object();
|
|
142
|
+
Validate_1.default({ trackType }).required().string();
|
|
143
|
+
Validate_1.default({ groupId }).required().string();
|
|
144
|
+
Validate_1.default({ trackIndex }).required().number();
|
|
145
|
+
return this.postMessage({ type: this.getMessage('select_track'), videoId, trackType, groupId, trackIndex });
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
resetTrack(videoId, trackType, groupId) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
Validate_1.default({ videoId }).required().object();
|
|
151
|
+
Validate_1.default({ trackType }).required().string();
|
|
152
|
+
if (groupId) {
|
|
153
|
+
Validate_1.default({ groupId }).string();
|
|
154
|
+
}
|
|
155
|
+
return this.postMessage({ type: this.getMessage('reset_track'), videoId, trackType, groupId });
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
onTracksChanged(listener) {
|
|
159
|
+
Validate_1.default({ listener }).required().function();
|
|
160
|
+
this.eventEmitter.on('tracks_changed', listener);
|
|
161
|
+
}
|
|
111
162
|
onError(listener) {
|
|
112
163
|
Validate_1.default({ listener }).required().function();
|
|
113
164
|
this.eventEmitter.on('error', listener);
|
|
@@ -133,6 +184,7 @@ class Stream {
|
|
|
133
184
|
this.eventEmitter.on('stop', listener);
|
|
134
185
|
}
|
|
135
186
|
handleMessageData(data) {
|
|
187
|
+
var _a, _b, _c, _d, _e, _f;
|
|
136
188
|
switch (data.type) {
|
|
137
189
|
case this.getMessage('error'):
|
|
138
190
|
this.createAndEmitEvent('error', {
|
|
@@ -143,7 +195,7 @@ class Stream {
|
|
|
143
195
|
y: data.y,
|
|
144
196
|
width: data.width,
|
|
145
197
|
height: data.height,
|
|
146
|
-
options: data.
|
|
198
|
+
protocol: (_b = (_a = data.options) === null || _a === void 0 ? void 0 : _a.protocol) !== null && _b !== void 0 ? _b : data.protocol,
|
|
147
199
|
},
|
|
148
200
|
errorMessage: data.errorMessage,
|
|
149
201
|
});
|
|
@@ -157,7 +209,7 @@ class Stream {
|
|
|
157
209
|
y: data.y,
|
|
158
210
|
width: data.width,
|
|
159
211
|
height: data.height,
|
|
160
|
-
options: data.
|
|
212
|
+
protocol: (_d = (_c = data.options) === null || _c === void 0 ? void 0 : _c.protocol) !== null && _d !== void 0 ? _d : data.protocol,
|
|
161
213
|
},
|
|
162
214
|
});
|
|
163
215
|
break;
|
|
@@ -170,8 +222,21 @@ class Stream {
|
|
|
170
222
|
y: data.y,
|
|
171
223
|
width: data.width,
|
|
172
224
|
height: data.height,
|
|
173
|
-
options: data.
|
|
225
|
+
protocol: (_f = (_e = data.options) === null || _e === void 0 ? void 0 : _e.protocol) !== null && _f !== void 0 ? _f : data.protocol,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
break;
|
|
229
|
+
case this.getMessage('tracks_changed'):
|
|
230
|
+
this.createAndEmitEvent('tracks_changed', {
|
|
231
|
+
type: 'tracks_changed',
|
|
232
|
+
srcArguments: {
|
|
233
|
+
uri: data.uri,
|
|
234
|
+
x: data.x,
|
|
235
|
+
y: data.y,
|
|
236
|
+
width: data.width,
|
|
237
|
+
height: data.height,
|
|
174
238
|
},
|
|
239
|
+
tracks: data.tracks,
|
|
175
240
|
});
|
|
176
241
|
break;
|
|
177
242
|
default:
|