@signageos/front-applet 8.1.1 → 8.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/docs/sos/browser.md +66 -14
- package/docs/sos/command.md +52 -6
- package/docs/sos/debug.md +17 -2
- package/docs/sos/deviceInfo.md +27 -0
- package/docs/sos/display.md +34 -3
- package/docs/sos/fileSystem.md +1135 -59
- package/docs/sos/index.md +36 -12
- package/docs/sos/input.md +42 -1
- package/docs/sos/native/mdc.md +65 -19
- package/docs/sos/offline/cache.md +14 -8
- package/docs/sos/stream.md +1172 -37
- package/docs/sos/sync.md +2 -2
- package/docs/sos/video.md +515 -22
- package/docs/sos_management/security.md +4 -2
- package/docs/sos_management/wifi.md +9 -9
- package/es6/FrontApplet/Browser/Browser.d.ts +25 -9
- package/es6/FrontApplet/Browser/Browser.js +25 -9
- package/es6/FrontApplet/Browser/Browser.js.map +1 -1
- package/es6/FrontApplet/Browser/IOpenLinkOptions.d.ts +7 -0
- package/es6/FrontApplet/Browser/IOpenLinkOptions.js.map +1 -1
- package/es6/FrontApplet/Browser/events.d.ts +6 -0
- package/es6/FrontApplet/Browser/events.js.map +1 -1
- package/es6/FrontApplet/Command/Command.d.ts +15 -6
- package/es6/FrontApplet/Command/Command.js +15 -6
- package/es6/FrontApplet/Command/Command.js.map +1 -1
- package/es6/FrontApplet/Command/ICommand.d.ts +7 -0
- package/es6/FrontApplet/Command/ICommandEvent.d.ts +6 -0
- package/es6/FrontApplet/Debug/Debug.d.ts +11 -3
- package/es6/FrontApplet/Debug/Debug.js +11 -3
- package/es6/FrontApplet/Debug/Debug.js.map +1 -1
- package/es6/FrontApplet/DeviceInfo/DeviceInfo.d.ts +15 -0
- package/es6/FrontApplet/DeviceInfo/DeviceInfo.js +16 -2
- package/es6/FrontApplet/DeviceInfo/DeviceInfo.js.map +1 -1
- package/es6/FrontApplet/Display/Display.d.ts +22 -14
- package/es6/FrontApplet/Display/Display.js +22 -14
- package/es6/FrontApplet/Display/Display.js.map +1 -1
- package/es6/FrontApplet/Display/IDisplay.d.ts +4 -0
- package/es6/FrontApplet/FileSystem/FileSystem.d.ts +429 -41
- package/es6/FrontApplet/FileSystem/FileSystem.js +427 -39
- package/es6/FrontApplet/FileSystem/FileSystem.js.map +1 -1
- package/es6/FrontApplet/FileSystem/HashAlgorithm.d.ts +4 -1
- package/es6/FrontApplet/FileSystem/types.d.ts +46 -0
- package/es6/FrontApplet/FileSystem/types.js.map +1 -1
- package/es6/FrontApplet/FrontApplet.d.ts +31 -7
- package/es6/FrontApplet/FrontApplet.js +32 -8
- package/es6/FrontApplet/FrontApplet.js.map +1 -1
- package/es6/FrontApplet/Input/IKeyUpEvent.d.ts +9 -0
- package/es6/FrontApplet/Input/IKeyUpEvent.js +6 -0
- package/es6/FrontApplet/Input/IKeyUpEvent.js.map +1 -1
- package/es6/FrontApplet/Input/Input.d.ts +17 -1
- package/es6/FrontApplet/Input/Input.js +17 -1
- package/es6/FrontApplet/Input/Input.js.map +1 -1
- package/es6/FrontApplet/NativeCommands/MDC/Mdc.d.ts +32 -11
- package/es6/FrontApplet/NativeCommands/MDC/Mdc.js +14 -11
- package/es6/FrontApplet/NativeCommands/MDC/Mdc.js.map +1 -1
- package/es6/FrontApplet/Stream/IStreamTrackInfo.d.ts +34 -0
- package/es6/FrontApplet/Stream/Stream.d.ts +245 -20
- package/es6/FrontApplet/Stream/Stream.js +245 -20
- package/es6/FrontApplet/Stream/Stream.js.map +1 -1
- package/es6/FrontApplet/Stream/StreamProtocol.d.ts +4 -0
- package/es6/FrontApplet/Stream/StreamProtocol.js +4 -0
- package/es6/FrontApplet/Stream/StreamProtocol.js.map +1 -1
- package/es6/FrontApplet/Stream/streamEventProperties.d.ts +11 -1
- package/es6/FrontApplet/Stream/streamEvents.d.ts +26 -0
- package/es6/FrontApplet/Video/IOptions.d.ts +41 -0
- package/es6/FrontApplet/Video/IVideoEvent.d.ts +8 -0
- package/es6/FrontApplet/Video/IVideoEvent.js.map +1 -1
- package/es6/FrontApplet/Video/IVideoProperties.d.ts +3 -0
- package/es6/FrontApplet/Video/Video.d.ts +256 -19
- package/es6/FrontApplet/Video/Video.js +258 -22
- package/es6/FrontApplet/Video/Video.js.map +1 -1
- package/package.json +1 -1
package/docs/sos/stream.md
CHANGED
|
@@ -4,39 +4,33 @@ sidebar_position: 0
|
|
|
4
4
|
|
|
5
5
|
# stream
|
|
6
6
|
|
|
7
|
-
The `sos.
|
|
7
|
+
The `sos.stream` API groups together methods for streaming videos from different sources. There are various methods for preparing, playing, stopping, pausing, and resuming streams.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Streams are identified by their URI and their position on the screen (x, y, width, height).
|
|
10
|
+
|
|
11
|
+
This API allows you to play video stream from:
|
|
12
|
+
- URL (e.g., HTTP, RTSP, RTP, UDP, RTMP)
|
|
13
|
+
- HDMI (e.g., Picture-in-Picture, Internal ports) streams
|
|
10
14
|
|
|
15
|
+
:::warning
|
|
11
16
|
Are you using **Samsung Tizen** to play streams? Read more about limitation and
|
|
12
17
|
[Tizen-specific details](https://docs.signageos.io/hc/en-us/articles/4405387373458).
|
|
13
|
-
|
|
14
18
|
:::
|
|
15
19
|
|
|
16
20
|
:::danger
|
|
17
|
-
|
|
18
21
|
Be aware version of JS API (v6.0.0+) changed how stream functions `play()` and `prepare()` work. For using an options object you need to
|
|
19
22
|
our latest core app versions. If you are using older core app versions, you need to use deprecated format.
|
|
20
|
-
|
|
21
23
|
:::
|
|
22
24
|
|
|
23
25
|
## Methods
|
|
24
26
|
|
|
25
27
|
### getTracks()
|
|
26
28
|
|
|
27
|
-
The `getTracks()` method returns a
|
|
29
|
+
The `getTracks()` method returns a list of subtitles, video, and audio tracks of a stream.
|
|
28
30
|
|
|
29
31
|
```ts expandable
|
|
30
32
|
getTracks(videoId: IVideoProperties): Promise<ITrackInfo[]>;
|
|
31
33
|
// show-more
|
|
32
|
-
interface IVideoProperties {
|
|
33
|
-
uri: string;
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
width: number;
|
|
37
|
-
height: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
34
|
type ITrackInfo = ITrackVideoInfo | ITrackAudioInfo | ITrackTextInfo;
|
|
41
35
|
|
|
42
36
|
interface ITrackVideoInfo extends ITrack<'VIDEO'> {
|
|
@@ -46,26 +40,90 @@ interface ITrackVideoInfo extends ITrack<'VIDEO'> {
|
|
|
46
40
|
};
|
|
47
41
|
}
|
|
48
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Interface representing stream track information.
|
|
45
|
+
*/
|
|
49
46
|
interface ITrack<T extends TrackType> {
|
|
47
|
+
/**
|
|
48
|
+
* Type of the track, e.g., "VIDEO", "AUDIO", "TEXT".
|
|
49
|
+
*/
|
|
50
50
|
trackType: T;
|
|
51
|
+
/**
|
|
52
|
+
* MIME type of the track, e.g., "video/mp4", "audio/mp3", "text/vtt".
|
|
53
|
+
*/
|
|
51
54
|
mimeType: string;
|
|
55
|
+
/**
|
|
56
|
+
* Unique identifier for the track group.
|
|
57
|
+
* This is used to group tracks of the same type (e.g., multiple audio tracks).
|
|
58
|
+
*/
|
|
52
59
|
groupId: string;
|
|
60
|
+
/**
|
|
61
|
+
* Unique identifier for the track.
|
|
62
|
+
*/
|
|
53
63
|
trackIndex: number;
|
|
64
|
+
/**
|
|
65
|
+
* If the track is selected for playback.
|
|
66
|
+
*/
|
|
54
67
|
selected: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Selected language of subtitles or captions.
|
|
70
|
+
*/
|
|
55
71
|
language: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* If the track is supported by the device.
|
|
74
|
+
*/
|
|
56
75
|
supported: boolean;
|
|
57
76
|
}
|
|
58
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Available track types for media streams.
|
|
80
|
+
*/
|
|
59
81
|
type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO';
|
|
60
82
|
|
|
61
83
|
interface ITrackAudioInfo extends ITrack<'AUDIO'> {
|
|
84
|
+
/**
|
|
85
|
+
* Number of audio channels.
|
|
86
|
+
*/
|
|
62
87
|
channelCount: number;
|
|
63
88
|
}
|
|
64
89
|
|
|
65
90
|
interface ITrackTextInfo extends ITrack<'TEXT'> {
|
|
91
|
+
/**
|
|
92
|
+
* Selected subtitles or captions.
|
|
93
|
+
*/
|
|
66
94
|
selection: string[];
|
|
67
95
|
}
|
|
68
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Video properties interface for defining the properties of a played video.
|
|
99
|
+
*/
|
|
100
|
+
interface IVideoProperties {
|
|
101
|
+
uri: string;
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
width: number;
|
|
105
|
+
height: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Params
|
|
111
|
+
|
|
112
|
+
| Name | Type | Description |
|
|
113
|
+
|-----------|--------------------|-------------------------------------------------------|
|
|
114
|
+
| `videoId` | `IVideoProperties` | The video properties of the stream to get tracks for. |
|
|
115
|
+
|
|
116
|
+
#### Return value
|
|
117
|
+
|
|
118
|
+
Returns array of object with information about subtitles, video, and audio tracks.
|
|
119
|
+
|
|
120
|
+
#### Example
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
// Example of getting tracks for a stream
|
|
124
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
125
|
+
const tracks = await sos.stream.getTracks(streamId);
|
|
126
|
+
console.log(tracks); // Outputs an array of track information
|
|
69
127
|
```
|
|
70
128
|
|
|
71
129
|
<Separator />
|
|
@@ -77,13 +135,31 @@ The `onConnected()` method sets up a listener, which is called whenever a stream
|
|
|
77
135
|
```ts expandable
|
|
78
136
|
onConnected(listener: (event: IStreamEvent<'connected'>) => void): void;
|
|
79
137
|
// show-more
|
|
138
|
+
/**
|
|
139
|
+
* Generic interface for stream events.
|
|
140
|
+
*/
|
|
80
141
|
interface IStreamEvent<T extends StreamEventType> {
|
|
142
|
+
/**
|
|
143
|
+
* Type of the event.
|
|
144
|
+
* @see {@link StreamEventType}
|
|
145
|
+
*/
|
|
81
146
|
type: T;
|
|
147
|
+
/**
|
|
148
|
+
* Additional stream properties that are relevant to the event.
|
|
149
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
150
|
+
*/
|
|
82
151
|
srcArguments: IStreamEventProperties;
|
|
83
152
|
}
|
|
84
153
|
|
|
154
|
+
/**
|
|
155
|
+
* List of all possible stream event types.
|
|
156
|
+
*/
|
|
85
157
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
86
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Returned properties of stream events that occur on stream events:
|
|
161
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
162
|
+
*/
|
|
87
163
|
interface IStreamEventProperties {
|
|
88
164
|
uri: string;
|
|
89
165
|
x: number;
|
|
@@ -92,25 +168,57 @@ interface IStreamEventProperties {
|
|
|
92
168
|
height: number;
|
|
93
169
|
protocol?: keyof typeof StreamProtocol | string;
|
|
94
170
|
/**
|
|
95
|
-
* @deprecated Events should not return options
|
|
171
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
96
172
|
*/
|
|
97
173
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
98
174
|
}
|
|
99
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Available options for stream function `play()`.
|
|
178
|
+
*/
|
|
100
179
|
interface IStreamOptions extends IOptions {
|
|
180
|
+
/**
|
|
181
|
+
* Protocol that the stream is using.
|
|
182
|
+
*
|
|
183
|
+
* Note: Not all protocols are supported by all devices.
|
|
184
|
+
*
|
|
185
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
186
|
+
*/
|
|
101
187
|
protocol?: keyof typeof StreamProtocol | string;
|
|
188
|
+
/**
|
|
189
|
+
* Automatically reconnect stream when it disconnects.
|
|
190
|
+
* @default false
|
|
191
|
+
*/
|
|
102
192
|
autoReconnect?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Interval in milliseconds between reconnect attempts.
|
|
195
|
+
* @default 30000
|
|
196
|
+
*/
|
|
103
197
|
autoReconnectInterval?: number;
|
|
104
198
|
}
|
|
105
199
|
|
|
106
200
|
interface IOptions {
|
|
107
201
|
/** @deprecated */
|
|
108
202
|
'4k'?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Prepare stream or video in background.
|
|
205
|
+
* @default false
|
|
206
|
+
*/
|
|
109
207
|
background?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Initial volume value of the stream.
|
|
210
|
+
* @default 100
|
|
211
|
+
*/
|
|
110
212
|
volume?: number;
|
|
111
213
|
}
|
|
112
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Available options for stream function `prepare()`.
|
|
217
|
+
*/
|
|
113
218
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
219
|
+
/**
|
|
220
|
+
* Track selection for subtitles, audio, and video.
|
|
221
|
+
*/
|
|
114
222
|
trackSelection?: {
|
|
115
223
|
/** Maximum number of audio channels to play */
|
|
116
224
|
maxAudioChannelCount?: number;
|
|
@@ -129,9 +237,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
129
237
|
/** Preferred text languages to play */
|
|
130
238
|
preferredTextLanguages?: string[];
|
|
131
239
|
};
|
|
240
|
+
/**
|
|
241
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
242
|
+
*/
|
|
132
243
|
drm?: {
|
|
133
244
|
scheme: DrmScheme;
|
|
245
|
+
/**
|
|
246
|
+
* URI to the license server.
|
|
247
|
+
*/
|
|
134
248
|
licenseUri: string;
|
|
249
|
+
/**
|
|
250
|
+
* Additional headers to include in the license request.
|
|
251
|
+
*/
|
|
135
252
|
licenseRequestHeaders: {
|
|
136
253
|
[key: string]: string;
|
|
137
254
|
};
|
|
@@ -144,22 +261,61 @@ type AnyString = string & {};
|
|
|
144
261
|
|
|
145
262
|
```
|
|
146
263
|
|
|
264
|
+
#### Params
|
|
265
|
+
|
|
266
|
+
| Name | Type | Description |
|
|
267
|
+
|------------|----------------------------------------------|-----------------------------------------------------------|
|
|
268
|
+
| `listener` | `(event: IStreamEvent<"connected">) => void` | The listener function to be called when the event occurs. |
|
|
269
|
+
|
|
270
|
+
#### Return value
|
|
271
|
+
|
|
272
|
+
Resolves when the listener is successfully set up.
|
|
273
|
+
|
|
274
|
+
#### Example
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
// Example of setting up a listener for the connected event
|
|
278
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
279
|
+
sos.stream.onConnected((event) => {
|
|
280
|
+
console.log('Stream connected:', event.srcArguments.uri);
|
|
281
|
+
});
|
|
282
|
+
```
|
|
283
|
+
|
|
147
284
|
<Separator />
|
|
148
285
|
|
|
149
286
|
### onDisconnected()
|
|
150
287
|
|
|
151
288
|
The `onDisconnected()` method sets up a listener, which is called whenever a stream gets disconnected.
|
|
289
|
+
Usually when source URI is not available anymore or when the stream is stopped.
|
|
152
290
|
|
|
153
291
|
```ts expandable
|
|
154
292
|
onDisconnected(listener: (event: IStreamEvent<'disconnected'>) => void): void;
|
|
155
293
|
// show-more
|
|
294
|
+
/**
|
|
295
|
+
* Generic interface for stream events.
|
|
296
|
+
*/
|
|
156
297
|
interface IStreamEvent<T extends StreamEventType> {
|
|
298
|
+
/**
|
|
299
|
+
* Type of the event.
|
|
300
|
+
* @see {@link StreamEventType}
|
|
301
|
+
*/
|
|
157
302
|
type: T;
|
|
303
|
+
/**
|
|
304
|
+
* Additional stream properties that are relevant to the event.
|
|
305
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
306
|
+
*/
|
|
158
307
|
srcArguments: IStreamEventProperties;
|
|
159
308
|
}
|
|
160
309
|
|
|
310
|
+
/**
|
|
311
|
+
* List of all possible stream event types.
|
|
312
|
+
*/
|
|
161
313
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
162
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Returned properties of stream events that occur on stream events:
|
|
317
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
318
|
+
*/
|
|
163
319
|
interface IStreamEventProperties {
|
|
164
320
|
uri: string;
|
|
165
321
|
x: number;
|
|
@@ -168,25 +324,57 @@ interface IStreamEventProperties {
|
|
|
168
324
|
height: number;
|
|
169
325
|
protocol?: keyof typeof StreamProtocol | string;
|
|
170
326
|
/**
|
|
171
|
-
* @deprecated Events should not return options
|
|
327
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
172
328
|
*/
|
|
173
329
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
174
330
|
}
|
|
175
331
|
|
|
332
|
+
/**
|
|
333
|
+
* Available options for stream function `play()`.
|
|
334
|
+
*/
|
|
176
335
|
interface IStreamOptions extends IOptions {
|
|
336
|
+
/**
|
|
337
|
+
* Protocol that the stream is using.
|
|
338
|
+
*
|
|
339
|
+
* Note: Not all protocols are supported by all devices.
|
|
340
|
+
*
|
|
341
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
342
|
+
*/
|
|
177
343
|
protocol?: keyof typeof StreamProtocol | string;
|
|
344
|
+
/**
|
|
345
|
+
* Automatically reconnect stream when it disconnects.
|
|
346
|
+
* @default false
|
|
347
|
+
*/
|
|
178
348
|
autoReconnect?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Interval in milliseconds between reconnect attempts.
|
|
351
|
+
* @default 30000
|
|
352
|
+
*/
|
|
179
353
|
autoReconnectInterval?: number;
|
|
180
354
|
}
|
|
181
355
|
|
|
182
356
|
interface IOptions {
|
|
183
357
|
/** @deprecated */
|
|
184
358
|
'4k'?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Prepare stream or video in background.
|
|
361
|
+
* @default false
|
|
362
|
+
*/
|
|
185
363
|
background?: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Initial volume value of the stream.
|
|
366
|
+
* @default 100
|
|
367
|
+
*/
|
|
186
368
|
volume?: number;
|
|
187
369
|
}
|
|
188
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Available options for stream function `prepare()`.
|
|
373
|
+
*/
|
|
189
374
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
375
|
+
/**
|
|
376
|
+
* Track selection for subtitles, audio, and video.
|
|
377
|
+
*/
|
|
190
378
|
trackSelection?: {
|
|
191
379
|
/** Maximum number of audio channels to play */
|
|
192
380
|
maxAudioChannelCount?: number;
|
|
@@ -205,9 +393,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
205
393
|
/** Preferred text languages to play */
|
|
206
394
|
preferredTextLanguages?: string[];
|
|
207
395
|
};
|
|
396
|
+
/**
|
|
397
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
398
|
+
*/
|
|
208
399
|
drm?: {
|
|
209
400
|
scheme: DrmScheme;
|
|
401
|
+
/**
|
|
402
|
+
* URI to the license server.
|
|
403
|
+
*/
|
|
210
404
|
licenseUri: string;
|
|
405
|
+
/**
|
|
406
|
+
* Additional headers to include in the license request.
|
|
407
|
+
*/
|
|
211
408
|
licenseRequestHeaders: {
|
|
212
409
|
[key: string]: string;
|
|
213
410
|
};
|
|
@@ -220,26 +417,70 @@ type AnyString = string & {};
|
|
|
220
417
|
|
|
221
418
|
```
|
|
222
419
|
|
|
420
|
+
#### Params
|
|
421
|
+
|
|
422
|
+
| Name | Type | Description |
|
|
423
|
+
|------------|-------------------------------------------------|-----------------------------------------------------------|
|
|
424
|
+
| `listener` | `(event: IStreamEvent<"disconnected">) => void` | The listener function to be called when the event occurs. |
|
|
425
|
+
|
|
426
|
+
#### Return value
|
|
427
|
+
|
|
428
|
+
Resolves when the listener is successfully set up.
|
|
429
|
+
|
|
430
|
+
#### Example
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
// Example of setting up a listener for the disconnected event
|
|
434
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
435
|
+
sos.stream.onDisconnected((event) => {
|
|
436
|
+
console.log('Stream disconnected:', event.srcArguments.uri);
|
|
437
|
+
});
|
|
438
|
+
```
|
|
439
|
+
|
|
223
440
|
<Separator />
|
|
224
441
|
|
|
225
442
|
### onError()
|
|
226
443
|
|
|
227
|
-
The `
|
|
444
|
+
The `onError()` method sets up a listener, which is called whenever an unexpected error occurs during a stream.
|
|
228
445
|
|
|
229
446
|
```ts expandable
|
|
230
447
|
onError(listener: (event: IStreamErrorEvent) => void): void;
|
|
231
448
|
// show-more
|
|
449
|
+
/**
|
|
450
|
+
* Stream Error Event, which is emitted when an error occurs during stream operations.
|
|
451
|
+
*/
|
|
232
452
|
interface IStreamErrorEvent extends IStreamEvent<'error'> {
|
|
453
|
+
/**
|
|
454
|
+
* Additional info about the error that occurred, if any info is available.
|
|
455
|
+
*/
|
|
233
456
|
errorMessage?: string | undefined;
|
|
234
457
|
}
|
|
235
458
|
|
|
459
|
+
/**
|
|
460
|
+
* Generic interface for stream events.
|
|
461
|
+
*/
|
|
236
462
|
interface IStreamEvent<T extends StreamEventType> {
|
|
463
|
+
/**
|
|
464
|
+
* Type of the event.
|
|
465
|
+
* @see {@link StreamEventType}
|
|
466
|
+
*/
|
|
237
467
|
type: T;
|
|
468
|
+
/**
|
|
469
|
+
* Additional stream properties that are relevant to the event.
|
|
470
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
471
|
+
*/
|
|
238
472
|
srcArguments: IStreamEventProperties;
|
|
239
473
|
}
|
|
240
474
|
|
|
475
|
+
/**
|
|
476
|
+
* List of all possible stream event types.
|
|
477
|
+
*/
|
|
241
478
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
242
479
|
|
|
480
|
+
/**
|
|
481
|
+
* Returned properties of stream events that occur on stream events:
|
|
482
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
483
|
+
*/
|
|
243
484
|
interface IStreamEventProperties {
|
|
244
485
|
uri: string;
|
|
245
486
|
x: number;
|
|
@@ -248,25 +489,57 @@ interface IStreamEventProperties {
|
|
|
248
489
|
height: number;
|
|
249
490
|
protocol?: keyof typeof StreamProtocol | string;
|
|
250
491
|
/**
|
|
251
|
-
* @deprecated Events should not return options
|
|
492
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
252
493
|
*/
|
|
253
494
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
254
495
|
}
|
|
255
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Available options for stream function `play()`.
|
|
499
|
+
*/
|
|
256
500
|
interface IStreamOptions extends IOptions {
|
|
501
|
+
/**
|
|
502
|
+
* Protocol that the stream is using.
|
|
503
|
+
*
|
|
504
|
+
* Note: Not all protocols are supported by all devices.
|
|
505
|
+
*
|
|
506
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
507
|
+
*/
|
|
257
508
|
protocol?: keyof typeof StreamProtocol | string;
|
|
509
|
+
/**
|
|
510
|
+
* Automatically reconnect stream when it disconnects.
|
|
511
|
+
* @default false
|
|
512
|
+
*/
|
|
258
513
|
autoReconnect?: boolean;
|
|
514
|
+
/**
|
|
515
|
+
* Interval in milliseconds between reconnect attempts.
|
|
516
|
+
* @default 30000
|
|
517
|
+
*/
|
|
259
518
|
autoReconnectInterval?: number;
|
|
260
519
|
}
|
|
261
520
|
|
|
262
521
|
interface IOptions {
|
|
263
522
|
/** @deprecated */
|
|
264
523
|
'4k'?: boolean;
|
|
524
|
+
/**
|
|
525
|
+
* Prepare stream or video in background.
|
|
526
|
+
* @default false
|
|
527
|
+
*/
|
|
265
528
|
background?: boolean;
|
|
529
|
+
/**
|
|
530
|
+
* Initial volume value of the stream.
|
|
531
|
+
* @default 100
|
|
532
|
+
*/
|
|
266
533
|
volume?: number;
|
|
267
534
|
}
|
|
268
535
|
|
|
536
|
+
/**
|
|
537
|
+
* Available options for stream function `prepare()`.
|
|
538
|
+
*/
|
|
269
539
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
540
|
+
/**
|
|
541
|
+
* Track selection for subtitles, audio, and video.
|
|
542
|
+
*/
|
|
270
543
|
trackSelection?: {
|
|
271
544
|
/** Maximum number of audio channels to play */
|
|
272
545
|
maxAudioChannelCount?: number;
|
|
@@ -285,9 +558,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
285
558
|
/** Preferred text languages to play */
|
|
286
559
|
preferredTextLanguages?: string[];
|
|
287
560
|
};
|
|
561
|
+
/**
|
|
562
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
563
|
+
*/
|
|
288
564
|
drm?: {
|
|
289
565
|
scheme: DrmScheme;
|
|
566
|
+
/**
|
|
567
|
+
* URI to the license server.
|
|
568
|
+
*/
|
|
290
569
|
licenseUri: string;
|
|
570
|
+
/**
|
|
571
|
+
* Additional headers to include in the license request.
|
|
572
|
+
*/
|
|
291
573
|
licenseRequestHeaders: {
|
|
292
574
|
[key: string]: string;
|
|
293
575
|
};
|
|
@@ -300,22 +582,60 @@ type AnyString = string & {};
|
|
|
300
582
|
|
|
301
583
|
```
|
|
302
584
|
|
|
585
|
+
#### Params
|
|
586
|
+
|
|
587
|
+
| Name | Type | Description |
|
|
588
|
+
|------------|--------------------------------------|-----------------------------------------------------------|
|
|
589
|
+
| `listener` | `(event: IStreamErrorEvent) => void` | The listener function to be called when the event occurs. |
|
|
590
|
+
|
|
591
|
+
#### Return value
|
|
592
|
+
|
|
593
|
+
Resolves when the listener is successfully set up.
|
|
594
|
+
|
|
595
|
+
#### Example
|
|
596
|
+
|
|
597
|
+
```ts
|
|
598
|
+
// Example of setting up a listener for the error event
|
|
599
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
600
|
+
sos.stream.onError((event) => {
|
|
601
|
+
console.error('Stream error:', event.errorMessage);
|
|
602
|
+
});
|
|
603
|
+
```
|
|
604
|
+
|
|
303
605
|
<Separator />
|
|
304
606
|
|
|
305
607
|
### onPause()
|
|
306
608
|
|
|
307
|
-
The `
|
|
609
|
+
The `onPause()` method sets up a listener, which is called whenever a stream is paused.
|
|
308
610
|
|
|
309
611
|
```ts expandable
|
|
310
612
|
onPause(listener: (event: IStreamEvent<'pause'>) => void): void;
|
|
311
613
|
// show-more
|
|
614
|
+
/**
|
|
615
|
+
* Generic interface for stream events.
|
|
616
|
+
*/
|
|
312
617
|
interface IStreamEvent<T extends StreamEventType> {
|
|
618
|
+
/**
|
|
619
|
+
* Type of the event.
|
|
620
|
+
* @see {@link StreamEventType}
|
|
621
|
+
*/
|
|
313
622
|
type: T;
|
|
623
|
+
/**
|
|
624
|
+
* Additional stream properties that are relevant to the event.
|
|
625
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
626
|
+
*/
|
|
314
627
|
srcArguments: IStreamEventProperties;
|
|
315
628
|
}
|
|
316
629
|
|
|
630
|
+
/**
|
|
631
|
+
* List of all possible stream event types.
|
|
632
|
+
*/
|
|
317
633
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
318
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Returned properties of stream events that occur on stream events:
|
|
637
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
638
|
+
*/
|
|
319
639
|
interface IStreamEventProperties {
|
|
320
640
|
uri: string;
|
|
321
641
|
x: number;
|
|
@@ -324,25 +644,57 @@ interface IStreamEventProperties {
|
|
|
324
644
|
height: number;
|
|
325
645
|
protocol?: keyof typeof StreamProtocol | string;
|
|
326
646
|
/**
|
|
327
|
-
* @deprecated Events should not return options
|
|
647
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
328
648
|
*/
|
|
329
649
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
330
650
|
}
|
|
331
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Available options for stream function `play()`.
|
|
654
|
+
*/
|
|
332
655
|
interface IStreamOptions extends IOptions {
|
|
656
|
+
/**
|
|
657
|
+
* Protocol that the stream is using.
|
|
658
|
+
*
|
|
659
|
+
* Note: Not all protocols are supported by all devices.
|
|
660
|
+
*
|
|
661
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
662
|
+
*/
|
|
333
663
|
protocol?: keyof typeof StreamProtocol | string;
|
|
664
|
+
/**
|
|
665
|
+
* Automatically reconnect stream when it disconnects.
|
|
666
|
+
* @default false
|
|
667
|
+
*/
|
|
334
668
|
autoReconnect?: boolean;
|
|
669
|
+
/**
|
|
670
|
+
* Interval in milliseconds between reconnect attempts.
|
|
671
|
+
* @default 30000
|
|
672
|
+
*/
|
|
335
673
|
autoReconnectInterval?: number;
|
|
336
674
|
}
|
|
337
675
|
|
|
338
676
|
interface IOptions {
|
|
339
677
|
/** @deprecated */
|
|
340
678
|
'4k'?: boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Prepare stream or video in background.
|
|
681
|
+
* @default false
|
|
682
|
+
*/
|
|
341
683
|
background?: boolean;
|
|
684
|
+
/**
|
|
685
|
+
* Initial volume value of the stream.
|
|
686
|
+
* @default 100
|
|
687
|
+
*/
|
|
342
688
|
volume?: number;
|
|
343
689
|
}
|
|
344
690
|
|
|
691
|
+
/**
|
|
692
|
+
* Available options for stream function `prepare()`.
|
|
693
|
+
*/
|
|
345
694
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
695
|
+
/**
|
|
696
|
+
* Track selection for subtitles, audio, and video.
|
|
697
|
+
*/
|
|
346
698
|
trackSelection?: {
|
|
347
699
|
/** Maximum number of audio channels to play */
|
|
348
700
|
maxAudioChannelCount?: number;
|
|
@@ -361,9 +713,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
361
713
|
/** Preferred text languages to play */
|
|
362
714
|
preferredTextLanguages?: string[];
|
|
363
715
|
};
|
|
716
|
+
/**
|
|
717
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
718
|
+
*/
|
|
364
719
|
drm?: {
|
|
365
720
|
scheme: DrmScheme;
|
|
721
|
+
/**
|
|
722
|
+
* URI to the license server.
|
|
723
|
+
*/
|
|
366
724
|
licenseUri: string;
|
|
725
|
+
/**
|
|
726
|
+
* Additional headers to include in the license request.
|
|
727
|
+
*/
|
|
367
728
|
licenseRequestHeaders: {
|
|
368
729
|
[key: string]: string;
|
|
369
730
|
};
|
|
@@ -376,6 +737,26 @@ type AnyString = string & {};
|
|
|
376
737
|
|
|
377
738
|
```
|
|
378
739
|
|
|
740
|
+
#### Params
|
|
741
|
+
|
|
742
|
+
| Name | Type | Description |
|
|
743
|
+
|------------|------------------------------------------|-----------------------------------------------------------|
|
|
744
|
+
| `listener` | `(event: IStreamEvent<"pause">) => void` | The listener function to be called when the event occurs. |
|
|
745
|
+
|
|
746
|
+
#### Return value
|
|
747
|
+
|
|
748
|
+
Resolves when the listener is successfully set up.
|
|
749
|
+
|
|
750
|
+
#### Example
|
|
751
|
+
|
|
752
|
+
```ts
|
|
753
|
+
// Example of setting up a listener for the pause event
|
|
754
|
+
await sos.stream.pause('http://example.com/stream', 0, 0, 1920, 1080);
|
|
755
|
+
sos.stream.onPause((event) => {
|
|
756
|
+
console.log('Stream paused:', event.srcArguments.uri);
|
|
757
|
+
});
|
|
758
|
+
```
|
|
759
|
+
|
|
379
760
|
<Separator />
|
|
380
761
|
|
|
381
762
|
### onPlay()
|
|
@@ -385,13 +766,31 @@ The `onPlay()` method sets up a listener, which is called whenever a stream star
|
|
|
385
766
|
```ts expandable
|
|
386
767
|
onPlay(listener: (event: IStreamEvent<'play'>) => void): void;
|
|
387
768
|
// show-more
|
|
769
|
+
/**
|
|
770
|
+
* Generic interface for stream events.
|
|
771
|
+
*/
|
|
388
772
|
interface IStreamEvent<T extends StreamEventType> {
|
|
773
|
+
/**
|
|
774
|
+
* Type of the event.
|
|
775
|
+
* @see {@link StreamEventType}
|
|
776
|
+
*/
|
|
389
777
|
type: T;
|
|
778
|
+
/**
|
|
779
|
+
* Additional stream properties that are relevant to the event.
|
|
780
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
781
|
+
*/
|
|
390
782
|
srcArguments: IStreamEventProperties;
|
|
391
783
|
}
|
|
392
784
|
|
|
785
|
+
/**
|
|
786
|
+
* List of all possible stream event types.
|
|
787
|
+
*/
|
|
393
788
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
394
789
|
|
|
790
|
+
/**
|
|
791
|
+
* Returned properties of stream events that occur on stream events:
|
|
792
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
793
|
+
*/
|
|
395
794
|
interface IStreamEventProperties {
|
|
396
795
|
uri: string;
|
|
397
796
|
x: number;
|
|
@@ -400,25 +799,57 @@ interface IStreamEventProperties {
|
|
|
400
799
|
height: number;
|
|
401
800
|
protocol?: keyof typeof StreamProtocol | string;
|
|
402
801
|
/**
|
|
403
|
-
* @deprecated Events should not return options
|
|
802
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
404
803
|
*/
|
|
405
804
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
406
805
|
}
|
|
407
806
|
|
|
807
|
+
/**
|
|
808
|
+
* Available options for stream function `play()`.
|
|
809
|
+
*/
|
|
408
810
|
interface IStreamOptions extends IOptions {
|
|
811
|
+
/**
|
|
812
|
+
* Protocol that the stream is using.
|
|
813
|
+
*
|
|
814
|
+
* Note: Not all protocols are supported by all devices.
|
|
815
|
+
*
|
|
816
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
817
|
+
*/
|
|
409
818
|
protocol?: keyof typeof StreamProtocol | string;
|
|
819
|
+
/**
|
|
820
|
+
* Automatically reconnect stream when it disconnects.
|
|
821
|
+
* @default false
|
|
822
|
+
*/
|
|
410
823
|
autoReconnect?: boolean;
|
|
824
|
+
/**
|
|
825
|
+
* Interval in milliseconds between reconnect attempts.
|
|
826
|
+
* @default 30000
|
|
827
|
+
*/
|
|
411
828
|
autoReconnectInterval?: number;
|
|
412
829
|
}
|
|
413
830
|
|
|
414
831
|
interface IOptions {
|
|
415
832
|
/** @deprecated */
|
|
416
833
|
'4k'?: boolean;
|
|
834
|
+
/**
|
|
835
|
+
* Prepare stream or video in background.
|
|
836
|
+
* @default false
|
|
837
|
+
*/
|
|
417
838
|
background?: boolean;
|
|
839
|
+
/**
|
|
840
|
+
* Initial volume value of the stream.
|
|
841
|
+
* @default 100
|
|
842
|
+
*/
|
|
418
843
|
volume?: number;
|
|
419
844
|
}
|
|
420
845
|
|
|
846
|
+
/**
|
|
847
|
+
* Available options for stream function `prepare()`.
|
|
848
|
+
*/
|
|
421
849
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
850
|
+
/**
|
|
851
|
+
* Track selection for subtitles, audio, and video.
|
|
852
|
+
*/
|
|
422
853
|
trackSelection?: {
|
|
423
854
|
/** Maximum number of audio channels to play */
|
|
424
855
|
maxAudioChannelCount?: number;
|
|
@@ -437,9 +868,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
437
868
|
/** Preferred text languages to play */
|
|
438
869
|
preferredTextLanguages?: string[];
|
|
439
870
|
};
|
|
871
|
+
/**
|
|
872
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
873
|
+
*/
|
|
440
874
|
drm?: {
|
|
441
875
|
scheme: DrmScheme;
|
|
876
|
+
/**
|
|
877
|
+
* URI to the license server.
|
|
878
|
+
*/
|
|
442
879
|
licenseUri: string;
|
|
880
|
+
/**
|
|
881
|
+
* Additional headers to include in the license request.
|
|
882
|
+
*/
|
|
443
883
|
licenseRequestHeaders: {
|
|
444
884
|
[key: string]: string;
|
|
445
885
|
};
|
|
@@ -452,6 +892,26 @@ type AnyString = string & {};
|
|
|
452
892
|
|
|
453
893
|
```
|
|
454
894
|
|
|
895
|
+
#### Params
|
|
896
|
+
|
|
897
|
+
| Name | Type | Description |
|
|
898
|
+
|------------|-----------------------------------------|-----------------------------------------------------------|
|
|
899
|
+
| `listener` | `(event: IStreamEvent<"play">) => void` | The listener function to be called when the event occurs. |
|
|
900
|
+
|
|
901
|
+
#### Return value
|
|
902
|
+
|
|
903
|
+
Resolves when the listener is successfully set up.
|
|
904
|
+
|
|
905
|
+
#### Example
|
|
906
|
+
|
|
907
|
+
```ts
|
|
908
|
+
// Example of setting up a listener for the play event
|
|
909
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
910
|
+
sos.stream.onPlay((event) => {
|
|
911
|
+
console.log('Stream started playing:', event.srcArguments.uri);
|
|
912
|
+
});
|
|
913
|
+
```
|
|
914
|
+
|
|
455
915
|
<Separator />
|
|
456
916
|
|
|
457
917
|
### onPrepare()
|
|
@@ -461,13 +921,31 @@ The `onPrepare()` method sets up a listener, which is called whenever a stream g
|
|
|
461
921
|
```ts expandable
|
|
462
922
|
onPrepare(listener: (event: IStreamEvent<'prepare'>) => void): void;
|
|
463
923
|
// show-more
|
|
924
|
+
/**
|
|
925
|
+
* Generic interface for stream events.
|
|
926
|
+
*/
|
|
464
927
|
interface IStreamEvent<T extends StreamEventType> {
|
|
928
|
+
/**
|
|
929
|
+
* Type of the event.
|
|
930
|
+
* @see {@link StreamEventType}
|
|
931
|
+
*/
|
|
465
932
|
type: T;
|
|
933
|
+
/**
|
|
934
|
+
* Additional stream properties that are relevant to the event.
|
|
935
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
936
|
+
*/
|
|
466
937
|
srcArguments: IStreamEventProperties;
|
|
467
938
|
}
|
|
468
939
|
|
|
940
|
+
/**
|
|
941
|
+
* List of all possible stream event types.
|
|
942
|
+
*/
|
|
469
943
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
470
944
|
|
|
945
|
+
/**
|
|
946
|
+
* Returned properties of stream events that occur on stream events:
|
|
947
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
948
|
+
*/
|
|
471
949
|
interface IStreamEventProperties {
|
|
472
950
|
uri: string;
|
|
473
951
|
x: number;
|
|
@@ -476,25 +954,57 @@ interface IStreamEventProperties {
|
|
|
476
954
|
height: number;
|
|
477
955
|
protocol?: keyof typeof StreamProtocol | string;
|
|
478
956
|
/**
|
|
479
|
-
* @deprecated Events should not return options
|
|
957
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
480
958
|
*/
|
|
481
959
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
482
960
|
}
|
|
483
961
|
|
|
962
|
+
/**
|
|
963
|
+
* Available options for stream function `play()`.
|
|
964
|
+
*/
|
|
484
965
|
interface IStreamOptions extends IOptions {
|
|
966
|
+
/**
|
|
967
|
+
* Protocol that the stream is using.
|
|
968
|
+
*
|
|
969
|
+
* Note: Not all protocols are supported by all devices.
|
|
970
|
+
*
|
|
971
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
972
|
+
*/
|
|
485
973
|
protocol?: keyof typeof StreamProtocol | string;
|
|
974
|
+
/**
|
|
975
|
+
* Automatically reconnect stream when it disconnects.
|
|
976
|
+
* @default false
|
|
977
|
+
*/
|
|
486
978
|
autoReconnect?: boolean;
|
|
979
|
+
/**
|
|
980
|
+
* Interval in milliseconds between reconnect attempts.
|
|
981
|
+
* @default 30000
|
|
982
|
+
*/
|
|
487
983
|
autoReconnectInterval?: number;
|
|
488
984
|
}
|
|
489
985
|
|
|
490
986
|
interface IOptions {
|
|
491
987
|
/** @deprecated */
|
|
492
988
|
'4k'?: boolean;
|
|
989
|
+
/**
|
|
990
|
+
* Prepare stream or video in background.
|
|
991
|
+
* @default false
|
|
992
|
+
*/
|
|
493
993
|
background?: boolean;
|
|
994
|
+
/**
|
|
995
|
+
* Initial volume value of the stream.
|
|
996
|
+
* @default 100
|
|
997
|
+
*/
|
|
494
998
|
volume?: number;
|
|
495
999
|
}
|
|
496
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* Available options for stream function `prepare()`.
|
|
1003
|
+
*/
|
|
497
1004
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
1005
|
+
/**
|
|
1006
|
+
* Track selection for subtitles, audio, and video.
|
|
1007
|
+
*/
|
|
498
1008
|
trackSelection?: {
|
|
499
1009
|
/** Maximum number of audio channels to play */
|
|
500
1010
|
maxAudioChannelCount?: number;
|
|
@@ -513,9 +1023,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
513
1023
|
/** Preferred text languages to play */
|
|
514
1024
|
preferredTextLanguages?: string[];
|
|
515
1025
|
};
|
|
1026
|
+
/**
|
|
1027
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
1028
|
+
*/
|
|
516
1029
|
drm?: {
|
|
517
1030
|
scheme: DrmScheme;
|
|
1031
|
+
/**
|
|
1032
|
+
* URI to the license server.
|
|
1033
|
+
*/
|
|
518
1034
|
licenseUri: string;
|
|
1035
|
+
/**
|
|
1036
|
+
* Additional headers to include in the license request.
|
|
1037
|
+
*/
|
|
519
1038
|
licenseRequestHeaders: {
|
|
520
1039
|
[key: string]: string;
|
|
521
1040
|
};
|
|
@@ -528,22 +1047,60 @@ type AnyString = string & {};
|
|
|
528
1047
|
|
|
529
1048
|
```
|
|
530
1049
|
|
|
1050
|
+
#### Params
|
|
1051
|
+
|
|
1052
|
+
| Name | Type | Description |
|
|
1053
|
+
|------------|--------------------------------------------|-----------------------------------------------------------|
|
|
1054
|
+
| `listener` | `(event: IStreamEvent<"prepare">) => void` | The listener function to be called when the event occurs. |
|
|
1055
|
+
|
|
1056
|
+
#### Return value
|
|
1057
|
+
|
|
1058
|
+
Resolves when the listener is successfully set up.
|
|
1059
|
+
|
|
1060
|
+
#### Example
|
|
1061
|
+
|
|
1062
|
+
```ts
|
|
1063
|
+
// Example of setting up a listener for the prepare event
|
|
1064
|
+
await sos.stream.prepare('http://example.com/stream', 0, 0, 1920, 1080);
|
|
1065
|
+
sos.stream.onPrepare((event) => {
|
|
1066
|
+
console.log('Stream prepared:', event.srcArguments.uri);
|
|
1067
|
+
});
|
|
1068
|
+
```
|
|
1069
|
+
|
|
531
1070
|
<Separator />
|
|
532
1071
|
|
|
533
1072
|
### onResume()
|
|
534
1073
|
|
|
535
|
-
The `
|
|
1074
|
+
The `onResume()` method sets up a listener, which is called whenever a stream is resumed.
|
|
536
1075
|
|
|
537
1076
|
```ts expandable
|
|
538
1077
|
onResume(listener: (event: IStreamEvent<'resume'>) => void): void;
|
|
539
1078
|
// show-more
|
|
1079
|
+
/**
|
|
1080
|
+
* Generic interface for stream events.
|
|
1081
|
+
*/
|
|
540
1082
|
interface IStreamEvent<T extends StreamEventType> {
|
|
1083
|
+
/**
|
|
1084
|
+
* Type of the event.
|
|
1085
|
+
* @see {@link StreamEventType}
|
|
1086
|
+
*/
|
|
541
1087
|
type: T;
|
|
1088
|
+
/**
|
|
1089
|
+
* Additional stream properties that are relevant to the event.
|
|
1090
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
1091
|
+
*/
|
|
542
1092
|
srcArguments: IStreamEventProperties;
|
|
543
1093
|
}
|
|
544
1094
|
|
|
1095
|
+
/**
|
|
1096
|
+
* List of all possible stream event types.
|
|
1097
|
+
*/
|
|
545
1098
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
546
1099
|
|
|
1100
|
+
/**
|
|
1101
|
+
* Returned properties of stream events that occur on stream events:
|
|
1102
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
1103
|
+
*/
|
|
547
1104
|
interface IStreamEventProperties {
|
|
548
1105
|
uri: string;
|
|
549
1106
|
x: number;
|
|
@@ -552,25 +1109,57 @@ interface IStreamEventProperties {
|
|
|
552
1109
|
height: number;
|
|
553
1110
|
protocol?: keyof typeof StreamProtocol | string;
|
|
554
1111
|
/**
|
|
555
|
-
* @deprecated Events should not return options
|
|
1112
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
556
1113
|
*/
|
|
557
1114
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
558
1115
|
}
|
|
559
1116
|
|
|
1117
|
+
/**
|
|
1118
|
+
* Available options for stream function `play()`.
|
|
1119
|
+
*/
|
|
560
1120
|
interface IStreamOptions extends IOptions {
|
|
1121
|
+
/**
|
|
1122
|
+
* Protocol that the stream is using.
|
|
1123
|
+
*
|
|
1124
|
+
* Note: Not all protocols are supported by all devices.
|
|
1125
|
+
*
|
|
1126
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
1127
|
+
*/
|
|
561
1128
|
protocol?: keyof typeof StreamProtocol | string;
|
|
1129
|
+
/**
|
|
1130
|
+
* Automatically reconnect stream when it disconnects.
|
|
1131
|
+
* @default false
|
|
1132
|
+
*/
|
|
562
1133
|
autoReconnect?: boolean;
|
|
1134
|
+
/**
|
|
1135
|
+
* Interval in milliseconds between reconnect attempts.
|
|
1136
|
+
* @default 30000
|
|
1137
|
+
*/
|
|
563
1138
|
autoReconnectInterval?: number;
|
|
564
1139
|
}
|
|
565
1140
|
|
|
566
1141
|
interface IOptions {
|
|
567
1142
|
/** @deprecated */
|
|
568
1143
|
'4k'?: boolean;
|
|
1144
|
+
/**
|
|
1145
|
+
* Prepare stream or video in background.
|
|
1146
|
+
* @default false
|
|
1147
|
+
*/
|
|
569
1148
|
background?: boolean;
|
|
1149
|
+
/**
|
|
1150
|
+
* Initial volume value of the stream.
|
|
1151
|
+
* @default 100
|
|
1152
|
+
*/
|
|
570
1153
|
volume?: number;
|
|
571
1154
|
}
|
|
572
1155
|
|
|
1156
|
+
/**
|
|
1157
|
+
* Available options for stream function `prepare()`.
|
|
1158
|
+
*/
|
|
573
1159
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
1160
|
+
/**
|
|
1161
|
+
* Track selection for subtitles, audio, and video.
|
|
1162
|
+
*/
|
|
574
1163
|
trackSelection?: {
|
|
575
1164
|
/** Maximum number of audio channels to play */
|
|
576
1165
|
maxAudioChannelCount?: number;
|
|
@@ -589,9 +1178,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
589
1178
|
/** Preferred text languages to play */
|
|
590
1179
|
preferredTextLanguages?: string[];
|
|
591
1180
|
};
|
|
1181
|
+
/**
|
|
1182
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
1183
|
+
*/
|
|
592
1184
|
drm?: {
|
|
593
1185
|
scheme: DrmScheme;
|
|
1186
|
+
/**
|
|
1187
|
+
* URI to the license server.
|
|
1188
|
+
*/
|
|
594
1189
|
licenseUri: string;
|
|
1190
|
+
/**
|
|
1191
|
+
* Additional headers to include in the license request.
|
|
1192
|
+
*/
|
|
595
1193
|
licenseRequestHeaders: {
|
|
596
1194
|
[key: string]: string;
|
|
597
1195
|
};
|
|
@@ -604,6 +1202,28 @@ type AnyString = string & {};
|
|
|
604
1202
|
|
|
605
1203
|
```
|
|
606
1204
|
|
|
1205
|
+
#### Params
|
|
1206
|
+
|
|
1207
|
+
| Name | Type | Description |
|
|
1208
|
+
|------------|-------------------------------------------|-----------------------------------------------------------|
|
|
1209
|
+
| `listener` | `(event: IStreamEvent<"resume">) => void` | The listener function to be called when the event occurs. |
|
|
1210
|
+
|
|
1211
|
+
#### Return value
|
|
1212
|
+
|
|
1213
|
+
Resolves when the listener is successfully set up.
|
|
1214
|
+
|
|
1215
|
+
#### Example
|
|
1216
|
+
|
|
1217
|
+
```ts
|
|
1218
|
+
// Example of setting up a listener for the resume event
|
|
1219
|
+
await sos.stream.pause('http://example.com/stream', 0, 0, 1920, 1080); // Pause the stream
|
|
1220
|
+
// ... after some time
|
|
1221
|
+
await sos.stream.resume('http://example.com/stream', 0, 0, 1920, 1080);
|
|
1222
|
+
sos.stream.onResume((event) => {
|
|
1223
|
+
console.log('Stream resumed:', event.srcArguments.uri);
|
|
1224
|
+
});
|
|
1225
|
+
```
|
|
1226
|
+
|
|
607
1227
|
<Separator />
|
|
608
1228
|
|
|
609
1229
|
### onStop()
|
|
@@ -613,13 +1233,31 @@ The `onStop()` method sets up a listener, which is called whenever a stream stop
|
|
|
613
1233
|
```ts expandable
|
|
614
1234
|
onStop(listener: (event: IStreamEvent<'stop'>) => void): void;
|
|
615
1235
|
// show-more
|
|
1236
|
+
/**
|
|
1237
|
+
* Generic interface for stream events.
|
|
1238
|
+
*/
|
|
616
1239
|
interface IStreamEvent<T extends StreamEventType> {
|
|
1240
|
+
/**
|
|
1241
|
+
* Type of the event.
|
|
1242
|
+
* @see {@link StreamEventType}
|
|
1243
|
+
*/
|
|
617
1244
|
type: T;
|
|
1245
|
+
/**
|
|
1246
|
+
* Additional stream properties that are relevant to the event.
|
|
1247
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
1248
|
+
*/
|
|
618
1249
|
srcArguments: IStreamEventProperties;
|
|
619
1250
|
}
|
|
620
1251
|
|
|
1252
|
+
/**
|
|
1253
|
+
* List of all possible stream event types.
|
|
1254
|
+
*/
|
|
621
1255
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
622
1256
|
|
|
1257
|
+
/**
|
|
1258
|
+
* Returned properties of stream events that occur on stream events:
|
|
1259
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
1260
|
+
*/
|
|
623
1261
|
interface IStreamEventProperties {
|
|
624
1262
|
uri: string;
|
|
625
1263
|
x: number;
|
|
@@ -628,25 +1266,57 @@ interface IStreamEventProperties {
|
|
|
628
1266
|
height: number;
|
|
629
1267
|
protocol?: keyof typeof StreamProtocol | string;
|
|
630
1268
|
/**
|
|
631
|
-
* @deprecated Events should not return options
|
|
1269
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
632
1270
|
*/
|
|
633
1271
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
634
1272
|
}
|
|
635
1273
|
|
|
1274
|
+
/**
|
|
1275
|
+
* Available options for stream function `play()`.
|
|
1276
|
+
*/
|
|
636
1277
|
interface IStreamOptions extends IOptions {
|
|
1278
|
+
/**
|
|
1279
|
+
* Protocol that the stream is using.
|
|
1280
|
+
*
|
|
1281
|
+
* Note: Not all protocols are supported by all devices.
|
|
1282
|
+
*
|
|
1283
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
1284
|
+
*/
|
|
637
1285
|
protocol?: keyof typeof StreamProtocol | string;
|
|
1286
|
+
/**
|
|
1287
|
+
* Automatically reconnect stream when it disconnects.
|
|
1288
|
+
* @default false
|
|
1289
|
+
*/
|
|
638
1290
|
autoReconnect?: boolean;
|
|
1291
|
+
/**
|
|
1292
|
+
* Interval in milliseconds between reconnect attempts.
|
|
1293
|
+
* @default 30000
|
|
1294
|
+
*/
|
|
639
1295
|
autoReconnectInterval?: number;
|
|
640
1296
|
}
|
|
641
1297
|
|
|
642
1298
|
interface IOptions {
|
|
643
1299
|
/** @deprecated */
|
|
644
1300
|
'4k'?: boolean;
|
|
1301
|
+
/**
|
|
1302
|
+
* Prepare stream or video in background.
|
|
1303
|
+
* @default false
|
|
1304
|
+
*/
|
|
645
1305
|
background?: boolean;
|
|
1306
|
+
/**
|
|
1307
|
+
* Initial volume value of the stream.
|
|
1308
|
+
* @default 100
|
|
1309
|
+
*/
|
|
646
1310
|
volume?: number;
|
|
647
1311
|
}
|
|
648
1312
|
|
|
1313
|
+
/**
|
|
1314
|
+
* Available options for stream function `prepare()`.
|
|
1315
|
+
*/
|
|
649
1316
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
1317
|
+
/**
|
|
1318
|
+
* Track selection for subtitles, audio, and video.
|
|
1319
|
+
*/
|
|
650
1320
|
trackSelection?: {
|
|
651
1321
|
/** Maximum number of audio channels to play */
|
|
652
1322
|
maxAudioChannelCount?: number;
|
|
@@ -665,9 +1335,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
665
1335
|
/** Preferred text languages to play */
|
|
666
1336
|
preferredTextLanguages?: string[];
|
|
667
1337
|
};
|
|
1338
|
+
/**
|
|
1339
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
1340
|
+
*/
|
|
668
1341
|
drm?: {
|
|
669
1342
|
scheme: DrmScheme;
|
|
1343
|
+
/**
|
|
1344
|
+
* URI to the license server.
|
|
1345
|
+
*/
|
|
670
1346
|
licenseUri: string;
|
|
1347
|
+
/**
|
|
1348
|
+
* Additional headers to include in the license request.
|
|
1349
|
+
*/
|
|
671
1350
|
licenseRequestHeaders: {
|
|
672
1351
|
[key: string]: string;
|
|
673
1352
|
};
|
|
@@ -680,16 +1359,43 @@ type AnyString = string & {};
|
|
|
680
1359
|
|
|
681
1360
|
```
|
|
682
1361
|
|
|
1362
|
+
#### Params
|
|
1363
|
+
|
|
1364
|
+
| Name | Type | Description |
|
|
1365
|
+
|------------|-----------------------------------------|-----------------------------------------------------------|
|
|
1366
|
+
| `listener` | `(event: IStreamEvent<"stop">) => void` | The listener function to be called when the event occurs. |
|
|
1367
|
+
|
|
1368
|
+
#### Return value
|
|
1369
|
+
|
|
1370
|
+
Resolves when the listener is successfully set up.
|
|
1371
|
+
|
|
1372
|
+
#### Example
|
|
1373
|
+
|
|
1374
|
+
```ts
|
|
1375
|
+
// Example of setting up a listener for the stop event
|
|
1376
|
+
await sos.stream.stop('http://example.com/stream', 0, 0, 1920, 1080);
|
|
1377
|
+
sos.stream.onStop((event) => {
|
|
1378
|
+
console.log('Stream stopped:', event.srcArguments.uri);
|
|
1379
|
+
});
|
|
1380
|
+
```
|
|
1381
|
+
|
|
683
1382
|
<Separator />
|
|
684
1383
|
|
|
685
1384
|
### onTracksChanged()
|
|
686
1385
|
|
|
687
|
-
The `onTracksChanged()` method sets up a listener, which is called whenever a track is changed
|
|
1386
|
+
The `onTracksChanged()` method sets up a listener, which is called whenever a track is changed
|
|
1387
|
+
from functions `selectTrack()` or `resetTrack()`.
|
|
688
1388
|
|
|
689
1389
|
```ts expandable
|
|
690
1390
|
onTracksChanged(listener: (event: IStreamTracksChangedEvent) => void): void;
|
|
691
1391
|
// show-more
|
|
1392
|
+
/**
|
|
1393
|
+
* Stream Tracks Changed Event which is emitted when new track is selected or active track resets.
|
|
1394
|
+
*/
|
|
692
1395
|
interface IStreamTracksChangedEvent extends IStreamEvent<'tracks_changed'> {
|
|
1396
|
+
/**
|
|
1397
|
+
* Additional info about the track which has occurred the event.
|
|
1398
|
+
*/
|
|
693
1399
|
tracks: ITrackInfo[] | undefined;
|
|
694
1400
|
}
|
|
695
1401
|
|
|
@@ -702,33 +1408,85 @@ interface ITrackVideoInfo extends ITrack<'VIDEO'> {
|
|
|
702
1408
|
};
|
|
703
1409
|
}
|
|
704
1410
|
|
|
1411
|
+
/**
|
|
1412
|
+
* Interface representing stream track information.
|
|
1413
|
+
*/
|
|
705
1414
|
interface ITrack<T extends TrackType> {
|
|
1415
|
+
/**
|
|
1416
|
+
* Type of the track, e.g., "VIDEO", "AUDIO", "TEXT".
|
|
1417
|
+
*/
|
|
706
1418
|
trackType: T;
|
|
1419
|
+
/**
|
|
1420
|
+
* MIME type of the track, e.g., "video/mp4", "audio/mp3", "text/vtt".
|
|
1421
|
+
*/
|
|
707
1422
|
mimeType: string;
|
|
1423
|
+
/**
|
|
1424
|
+
* Unique identifier for the track group.
|
|
1425
|
+
* This is used to group tracks of the same type (e.g., multiple audio tracks).
|
|
1426
|
+
*/
|
|
708
1427
|
groupId: string;
|
|
1428
|
+
/**
|
|
1429
|
+
* Unique identifier for the track.
|
|
1430
|
+
*/
|
|
709
1431
|
trackIndex: number;
|
|
1432
|
+
/**
|
|
1433
|
+
* If the track is selected for playback.
|
|
1434
|
+
*/
|
|
710
1435
|
selected: boolean;
|
|
1436
|
+
/**
|
|
1437
|
+
* Selected language of subtitles or captions.
|
|
1438
|
+
*/
|
|
711
1439
|
language: string | null;
|
|
1440
|
+
/**
|
|
1441
|
+
* If the track is supported by the device.
|
|
1442
|
+
*/
|
|
712
1443
|
supported: boolean;
|
|
713
1444
|
}
|
|
714
1445
|
|
|
1446
|
+
/**
|
|
1447
|
+
* Available track types for media streams.
|
|
1448
|
+
*/
|
|
715
1449
|
type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO';
|
|
716
1450
|
|
|
717
1451
|
interface ITrackAudioInfo extends ITrack<'AUDIO'> {
|
|
1452
|
+
/**
|
|
1453
|
+
* Number of audio channels.
|
|
1454
|
+
*/
|
|
718
1455
|
channelCount: number;
|
|
719
1456
|
}
|
|
720
1457
|
|
|
721
1458
|
interface ITrackTextInfo extends ITrack<'TEXT'> {
|
|
1459
|
+
/**
|
|
1460
|
+
* Selected subtitles or captions.
|
|
1461
|
+
*/
|
|
722
1462
|
selection: string[];
|
|
723
1463
|
}
|
|
724
1464
|
|
|
1465
|
+
/**
|
|
1466
|
+
* Generic interface for stream events.
|
|
1467
|
+
*/
|
|
725
1468
|
interface IStreamEvent<T extends StreamEventType> {
|
|
1469
|
+
/**
|
|
1470
|
+
* Type of the event.
|
|
1471
|
+
* @see {@link StreamEventType}
|
|
1472
|
+
*/
|
|
726
1473
|
type: T;
|
|
1474
|
+
/**
|
|
1475
|
+
* Additional stream properties that are relevant to the event.
|
|
1476
|
+
* If there is more than one stream active, this will contain the properties of the stream that emitted the event.
|
|
1477
|
+
*/
|
|
727
1478
|
srcArguments: IStreamEventProperties;
|
|
728
1479
|
}
|
|
729
1480
|
|
|
1481
|
+
/**
|
|
1482
|
+
* List of all possible stream event types.
|
|
1483
|
+
*/
|
|
730
1484
|
type StreamEventType = 'connected' | 'disconnected' | 'error' | 'stop' | 'play' | 'prepare' | 'pause' | 'resume' | 'tracks_changed';
|
|
731
1485
|
|
|
1486
|
+
/**
|
|
1487
|
+
* Returned properties of stream events that occur on stream events:
|
|
1488
|
+
* connected, disconnected, error, stop, tracks_changed
|
|
1489
|
+
*/
|
|
732
1490
|
interface IStreamEventProperties {
|
|
733
1491
|
uri: string;
|
|
734
1492
|
x: number;
|
|
@@ -737,25 +1495,57 @@ interface IStreamEventProperties {
|
|
|
737
1495
|
height: number;
|
|
738
1496
|
protocol?: keyof typeof StreamProtocol | string;
|
|
739
1497
|
/**
|
|
740
|
-
* @deprecated Events should not return options
|
|
1498
|
+
* @deprecated Events should not return options objects. Instead, they should return protocol {@link protocol}
|
|
741
1499
|
*/
|
|
742
1500
|
options?: IStreamOptions | IStreamPrepareOptions;
|
|
743
1501
|
}
|
|
744
1502
|
|
|
1503
|
+
/**
|
|
1504
|
+
* Available options for stream function `play()`.
|
|
1505
|
+
*/
|
|
745
1506
|
interface IStreamOptions extends IOptions {
|
|
1507
|
+
/**
|
|
1508
|
+
* Protocol that the stream is using.
|
|
1509
|
+
*
|
|
1510
|
+
* Note: Not all protocols are supported by all devices.
|
|
1511
|
+
*
|
|
1512
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
1513
|
+
*/
|
|
746
1514
|
protocol?: keyof typeof StreamProtocol | string;
|
|
1515
|
+
/**
|
|
1516
|
+
* Automatically reconnect stream when it disconnects.
|
|
1517
|
+
* @default false
|
|
1518
|
+
*/
|
|
747
1519
|
autoReconnect?: boolean;
|
|
1520
|
+
/**
|
|
1521
|
+
* Interval in milliseconds between reconnect attempts.
|
|
1522
|
+
* @default 30000
|
|
1523
|
+
*/
|
|
748
1524
|
autoReconnectInterval?: number;
|
|
749
1525
|
}
|
|
750
1526
|
|
|
751
1527
|
interface IOptions {
|
|
752
1528
|
/** @deprecated */
|
|
753
1529
|
'4k'?: boolean;
|
|
1530
|
+
/**
|
|
1531
|
+
* Prepare stream or video in background.
|
|
1532
|
+
* @default false
|
|
1533
|
+
*/
|
|
754
1534
|
background?: boolean;
|
|
1535
|
+
/**
|
|
1536
|
+
* Initial volume value of the stream.
|
|
1537
|
+
* @default 100
|
|
1538
|
+
*/
|
|
755
1539
|
volume?: number;
|
|
756
1540
|
}
|
|
757
1541
|
|
|
1542
|
+
/**
|
|
1543
|
+
* Available options for stream function `prepare()`.
|
|
1544
|
+
*/
|
|
758
1545
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
1546
|
+
/**
|
|
1547
|
+
* Track selection for subtitles, audio, and video.
|
|
1548
|
+
*/
|
|
759
1549
|
trackSelection?: {
|
|
760
1550
|
/** Maximum number of audio channels to play */
|
|
761
1551
|
maxAudioChannelCount?: number;
|
|
@@ -774,9 +1564,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
774
1564
|
/** Preferred text languages to play */
|
|
775
1565
|
preferredTextLanguages?: string[];
|
|
776
1566
|
};
|
|
1567
|
+
/**
|
|
1568
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
1569
|
+
*/
|
|
777
1570
|
drm?: {
|
|
778
1571
|
scheme: DrmScheme;
|
|
1572
|
+
/**
|
|
1573
|
+
* URI to the license server.
|
|
1574
|
+
*/
|
|
779
1575
|
licenseUri: string;
|
|
1576
|
+
/**
|
|
1577
|
+
* Additional headers to include in the license request.
|
|
1578
|
+
*/
|
|
780
1579
|
licenseRequestHeaders: {
|
|
781
1580
|
[key: string]: string;
|
|
782
1581
|
};
|
|
@@ -789,56 +1588,193 @@ type AnyString = string & {};
|
|
|
789
1588
|
|
|
790
1589
|
```
|
|
791
1590
|
|
|
1591
|
+
#### Params
|
|
1592
|
+
|
|
1593
|
+
| Name | Type | Description |
|
|
1594
|
+
|------------|----------------------------------------------|-----------------------------------------------------------|
|
|
1595
|
+
| `listener` | `(event: IStreamTracksChangedEvent) => void` | The listener function to be called when the event occurs. |
|
|
1596
|
+
|
|
1597
|
+
#### Return value
|
|
1598
|
+
|
|
1599
|
+
Resolves when the listener is successfully set up.
|
|
1600
|
+
|
|
1601
|
+
#### Example
|
|
1602
|
+
|
|
1603
|
+
```ts
|
|
1604
|
+
// Example of setting up a listener with starting a stream and selecting a track
|
|
1605
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
1606
|
+
await sos.stream.selectTrack(videoId, 'AUDIO', 'audioGroup1', 0);
|
|
1607
|
+
|
|
1608
|
+
// Create the listener for tracks changed event
|
|
1609
|
+
sos.stream.onTracksChanged((event) => {
|
|
1610
|
+
console.log('Track type:', event.tracks[0].trackType); // AUDIO
|
|
1611
|
+
console.log('Track group ID:', event.tracks[0].groupId); // audioGroup1
|
|
1612
|
+
console.log('Track index:', event.tracks[0].trackIndex); // 0
|
|
1613
|
+
});
|
|
1614
|
+
```
|
|
1615
|
+
|
|
792
1616
|
<Separator />
|
|
793
1617
|
|
|
794
1618
|
### pause()
|
|
795
1619
|
|
|
796
|
-
The `pause()` method pauses the stream, it can be resumed with `resume()`.
|
|
1620
|
+
The `pause()` method pauses the active stream, it can be resumed with `resume()`.
|
|
797
1621
|
|
|
798
1622
|
```ts expandable
|
|
799
1623
|
pause(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
800
1624
|
```
|
|
801
1625
|
|
|
1626
|
+
#### Params
|
|
1627
|
+
|
|
1628
|
+
| Name | Type | Description |
|
|
1629
|
+
|----------|----------|------------------------------------------------|
|
|
1630
|
+
| `uri` | `string` | Network address where the stream is available. |
|
|
1631
|
+
| `x` | `number` | Stream x-position on the screen |
|
|
1632
|
+
| `y` | `number` | Stream y-position on the screen |
|
|
1633
|
+
| `width` | `number` | Stream width on the screen |
|
|
1634
|
+
| `height` | `number` | Stream height on the screen |
|
|
1635
|
+
|
|
1636
|
+
#### Return value
|
|
1637
|
+
|
|
1638
|
+
Returns a promise that resolves when the stream is paused.
|
|
1639
|
+
|
|
1640
|
+
#### Possible errors
|
|
1641
|
+
|
|
1642
|
+
Error If parameters are invalid.
|
|
1643
|
+
|
|
1644
|
+
#### Example
|
|
1645
|
+
|
|
1646
|
+
```ts
|
|
1647
|
+
// Example of pausing an active stream
|
|
1648
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080); // Start
|
|
1649
|
+
// ... after some time
|
|
1650
|
+
await sos.stream.pause('http://example.com/stream', 0, 0, 1920, 1080); // Pause
|
|
1651
|
+
```
|
|
1652
|
+
|
|
802
1653
|
<Separator />
|
|
803
1654
|
|
|
804
1655
|
### play()
|
|
805
1656
|
|
|
806
|
-
The `play()` method starts the
|
|
1657
|
+
The `play()` method starts the video stream based by uri or stream which was prepared by `prepare()` method.
|
|
1658
|
+
|
|
1659
|
+
:::note Internal ports
|
|
1660
|
+
This method use same functionality, instead of URL (for stream), specify a URI of the port to display.
|
|
1661
|
+
|
|
1662
|
+
| Port URI value | Description |
|
|
1663
|
+
|-----------------|-------------|
|
|
1664
|
+
| `internal://hdmi<number>` | HDMI |
|
|
1665
|
+
| `internal://dp` | DisplayPort |
|
|
1666
|
+
| `internal://dvi` | DVI |
|
|
1667
|
+
| `internal://pc` | PC or VGA |
|
|
1668
|
+
|
|
1669
|
+
`<number>` has to be a value between 1 - 4, depending on which of the available HDMI ports you want to use.
|
|
1670
|
+
:::
|
|
807
1671
|
|
|
808
1672
|
```ts expandable
|
|
809
1673
|
play(uri: string, x: number, y: number, width: number, height: number, options?: IStreamOptions | keyof typeof StreamProtocol): Promise<void>;
|
|
810
1674
|
// show-more
|
|
1675
|
+
/**
|
|
1676
|
+
* Available options for stream function `play()`.
|
|
1677
|
+
*/
|
|
811
1678
|
interface IStreamOptions extends IOptions {
|
|
1679
|
+
/**
|
|
1680
|
+
* Protocol that the stream is using.
|
|
1681
|
+
*
|
|
1682
|
+
* Note: Not all protocols are supported by all devices.
|
|
1683
|
+
*
|
|
1684
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
1685
|
+
*/
|
|
812
1686
|
protocol?: keyof typeof StreamProtocol | string;
|
|
1687
|
+
/**
|
|
1688
|
+
* Automatically reconnect stream when it disconnects.
|
|
1689
|
+
* @default false
|
|
1690
|
+
*/
|
|
813
1691
|
autoReconnect?: boolean;
|
|
1692
|
+
/**
|
|
1693
|
+
* Interval in milliseconds between reconnect attempts.
|
|
1694
|
+
* @default 30000
|
|
1695
|
+
*/
|
|
814
1696
|
autoReconnectInterval?: number;
|
|
815
1697
|
}
|
|
816
1698
|
|
|
817
1699
|
interface IOptions {
|
|
818
1700
|
/** @deprecated */
|
|
819
1701
|
'4k'?: boolean;
|
|
1702
|
+
/**
|
|
1703
|
+
* Prepare stream or video in background.
|
|
1704
|
+
* @default false
|
|
1705
|
+
*/
|
|
820
1706
|
background?: boolean;
|
|
1707
|
+
/**
|
|
1708
|
+
* Initial volume value of the stream.
|
|
1709
|
+
* @default 100
|
|
1710
|
+
*/
|
|
821
1711
|
volume?: number;
|
|
822
1712
|
}
|
|
823
1713
|
|
|
824
1714
|
```
|
|
825
1715
|
|
|
1716
|
+
#### Params
|
|
1717
|
+
|
|
1718
|
+
| Name | Type | Description |
|
|
1719
|
+
|------------------------|---------------------------------------------------------------------------|------------------------------------------------|
|
|
1720
|
+
| `uri` | `string` | Network address where the stream is available. |
|
|
1721
|
+
| `x` | `number` | Stream x-position on the screen |
|
|
1722
|
+
| `y` | `number` | Stream y-position on the screen |
|
|
1723
|
+
| `width` | `number` | Stream width on the screen |
|
|
1724
|
+
| `height` | `number` | Stream height on the screen |
|
|
1725
|
+
| `options` *(optional)* | `IStreamOptions \| "HLS" \| "RTP" \| "HTTP" \| "UDP" \| "RTMP" \| "RTSP"` | Additional options for the stream |
|
|
1726
|
+
|
|
1727
|
+
#### Return value
|
|
1728
|
+
|
|
1729
|
+
Returns a promise that resolves when the stream is successfully started.
|
|
1730
|
+
|
|
1731
|
+
#### Possible errors
|
|
1732
|
+
|
|
1733
|
+
|
|
1734
|
+
- AppletStreamError If the protocol is not a string or if the parameters are invalid.
|
|
1735
|
+
- Error If parameters are invalid.
|
|
1736
|
+
- Error If the device fails to prepare the stream.
|
|
1737
|
+
|
|
1738
|
+
#### Example
|
|
1739
|
+
|
|
1740
|
+
```ts
|
|
1741
|
+
// Example with specific protocol type
|
|
1742
|
+
await sos.stream.play(uri, x, y, width, height, { protocol: 'HTTP' });
|
|
1743
|
+
|
|
1744
|
+
// Example with options - reconnect stream when it disconnects after 60 seconds
|
|
1745
|
+
await sos.stream.play(uri, x, y, width, height, { protocol: 'HTTP', autoReconnect: true, autoReconnectInterval: 60000 });
|
|
1746
|
+
|
|
1747
|
+
// Example for playing HDMI port
|
|
1748
|
+
await sos.stream.play('internal://hdmi1', 0, 0, 1920, 1080, { protocol: 'RTP' });
|
|
1749
|
+
```
|
|
1750
|
+
|
|
1751
|
+
:::note[GitHub Example]
|
|
1752
|
+
|
|
1753
|
+
- [ How to create video Applet with for URL streams](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/stream)
|
|
1754
|
+
- [ How to create video Applet with HDMI port](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/stream-hdmi-port)
|
|
1755
|
+
|
|
1756
|
+
:::
|
|
1757
|
+
|
|
826
1758
|
<Separator />
|
|
827
1759
|
|
|
828
1760
|
### prepare()
|
|
829
1761
|
|
|
830
|
-
|
|
1762
|
+
Calls the internal player and prepares a video stream in memory, so it can later start playing instantaneously.
|
|
831
1763
|
|
|
832
1764
|
:::info
|
|
833
|
-
|
|
834
1765
|
If you want to play a video stream in full screen mode, use x = y = 0 and width = document.documentElement.clientWidth and height = document.documentElement.clientHeight as setup parameters.
|
|
835
|
-
|
|
836
1766
|
:::
|
|
837
1767
|
|
|
838
1768
|
```ts expandable
|
|
839
1769
|
prepare(uri: string, x: number, y: number, width: number, height: number, options?: IStreamPrepareOptions | keyof typeof StreamProtocol): Promise<void>;
|
|
840
1770
|
// show-more
|
|
1771
|
+
/**
|
|
1772
|
+
* Available options for stream function `prepare()`.
|
|
1773
|
+
*/
|
|
841
1774
|
interface IStreamPrepareOptions extends IStreamOptions {
|
|
1775
|
+
/**
|
|
1776
|
+
* Track selection for subtitles, audio, and video.
|
|
1777
|
+
*/
|
|
842
1778
|
trackSelection?: {
|
|
843
1779
|
/** Maximum number of audio channels to play */
|
|
844
1780
|
maxAudioChannelCount?: number;
|
|
@@ -857,9 +1793,18 @@ interface IStreamPrepareOptions extends IStreamOptions {
|
|
|
857
1793
|
/** Preferred text languages to play */
|
|
858
1794
|
preferredTextLanguages?: string[];
|
|
859
1795
|
};
|
|
1796
|
+
/**
|
|
1797
|
+
* DRM (Digital Rights Management) options for the stream.
|
|
1798
|
+
*/
|
|
860
1799
|
drm?: {
|
|
861
1800
|
scheme: DrmScheme;
|
|
1801
|
+
/**
|
|
1802
|
+
* URI to the license server.
|
|
1803
|
+
*/
|
|
862
1804
|
licenseUri: string;
|
|
1805
|
+
/**
|
|
1806
|
+
* Additional headers to include in the license request.
|
|
1807
|
+
*/
|
|
863
1808
|
licenseRequestHeaders: {
|
|
864
1809
|
[key: string]: string;
|
|
865
1810
|
};
|
|
@@ -870,24 +1815,85 @@ type DrmScheme = 'CommonPSSH' | 'ClearKey' | 'Widevine' | 'PlayReady' | AnyStrin
|
|
|
870
1815
|
|
|
871
1816
|
type AnyString = string & {};
|
|
872
1817
|
|
|
1818
|
+
/**
|
|
1819
|
+
* Available options for stream function `play()`.
|
|
1820
|
+
*/
|
|
873
1821
|
interface IStreamOptions extends IOptions {
|
|
1822
|
+
/**
|
|
1823
|
+
* Protocol that the stream is using.
|
|
1824
|
+
*
|
|
1825
|
+
* Note: Not all protocols are supported by all devices.
|
|
1826
|
+
*
|
|
1827
|
+
* Allowed values are: HLS, RTP, HTTP, UDP, RTMP, RTSP
|
|
1828
|
+
*/
|
|
874
1829
|
protocol?: keyof typeof StreamProtocol | string;
|
|
1830
|
+
/**
|
|
1831
|
+
* Automatically reconnect stream when it disconnects.
|
|
1832
|
+
* @default false
|
|
1833
|
+
*/
|
|
875
1834
|
autoReconnect?: boolean;
|
|
1835
|
+
/**
|
|
1836
|
+
* Interval in milliseconds between reconnect attempts.
|
|
1837
|
+
* @default 30000
|
|
1838
|
+
*/
|
|
876
1839
|
autoReconnectInterval?: number;
|
|
877
1840
|
}
|
|
878
1841
|
|
|
879
1842
|
interface IOptions {
|
|
880
1843
|
/** @deprecated */
|
|
881
1844
|
'4k'?: boolean;
|
|
1845
|
+
/**
|
|
1846
|
+
* Prepare stream or video in background.
|
|
1847
|
+
* @default false
|
|
1848
|
+
*/
|
|
882
1849
|
background?: boolean;
|
|
1850
|
+
/**
|
|
1851
|
+
* Initial volume value of the stream.
|
|
1852
|
+
* @default 100
|
|
1853
|
+
*/
|
|
883
1854
|
volume?: number;
|
|
884
1855
|
}
|
|
885
1856
|
|
|
886
1857
|
```
|
|
887
1858
|
|
|
1859
|
+
#### Params
|
|
1860
|
+
|
|
1861
|
+
| Name | Type | Description |
|
|
1862
|
+
|------------------------|----------------------------------------------------------------------------------|------------------------------------------------|
|
|
1863
|
+
| `uri` | `string` | Network address where the stream is available. |
|
|
1864
|
+
| `x` | `number` | Stream x-position on the screen |
|
|
1865
|
+
| `y` | `number` | Stream y-position on the screen |
|
|
1866
|
+
| `width` | `number` | Stream width on the screen |
|
|
1867
|
+
| `height` | `number` | Stream height on the screen |
|
|
1868
|
+
| `options` *(optional)* | `IStreamPrepareOptions \| "HLS" \| "RTP" \| "HTTP" \| "UDP" \| "RTMP" \| "RTSP"` | Additional options for the stream |
|
|
1869
|
+
|
|
1870
|
+
#### Return value
|
|
1871
|
+
|
|
1872
|
+
Returns a promise that resolves when the stream is prepared.
|
|
1873
|
+
|
|
1874
|
+
#### Possible errors
|
|
1875
|
+
|
|
1876
|
+
|
|
1877
|
+
- AppletStreamError If the protocol is not a string or if the parameters are invalid.
|
|
1878
|
+
- Error If parameters are invalid.
|
|
1879
|
+
- Error If device fail to prepare the stream.
|
|
1880
|
+
|
|
1881
|
+
#### Example
|
|
1882
|
+
|
|
1883
|
+
```ts
|
|
1884
|
+
// Example with specific protocol type
|
|
1885
|
+
await sos.stream.prepare(uri, x, y, width, height, { protocol: 'HTTP' });
|
|
1886
|
+
|
|
1887
|
+
// Example with options - prepare stream in the background
|
|
1888
|
+
await sos.stream.prepare(uri, x, y, width, height, { protocol: 'HTTP', background: true });
|
|
1889
|
+
|
|
1890
|
+
// Deprecated format
|
|
1891
|
+
await sos.stream.prepare(uri, x, y, width, height, 'HTTP');
|
|
1892
|
+
```
|
|
1893
|
+
|
|
888
1894
|
:::note[GitHub Example]
|
|
889
1895
|
|
|
890
|
-
- [
|
|
1896
|
+
- [ How to create video Applet with for streams](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/stream)
|
|
891
1897
|
|
|
892
1898
|
:::
|
|
893
1899
|
|
|
@@ -905,11 +1911,14 @@ removeEventListeners(): void;
|
|
|
905
1911
|
|
|
906
1912
|
### resetTrack()
|
|
907
1913
|
|
|
908
|
-
The `resetTrack()` method resets a track of a stream.
|
|
1914
|
+
The `resetTrack()` method resets a selected track of a stream.
|
|
909
1915
|
|
|
910
1916
|
```ts expandable
|
|
911
1917
|
resetTrack(videoId: IVideoProperties, trackType: TrackType, groupId?: string): Promise<void>;
|
|
912
1918
|
// show-more
|
|
1919
|
+
/**
|
|
1920
|
+
* Video properties interface for defining the properties of a played video.
|
|
1921
|
+
*/
|
|
913
1922
|
interface IVideoProperties {
|
|
914
1923
|
uri: string;
|
|
915
1924
|
x: number;
|
|
@@ -918,29 +1927,88 @@ interface IVideoProperties {
|
|
|
918
1927
|
height: number;
|
|
919
1928
|
}
|
|
920
1929
|
|
|
1930
|
+
/**
|
|
1931
|
+
* Available track types for media streams.
|
|
1932
|
+
*/
|
|
921
1933
|
type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO';
|
|
922
1934
|
|
|
923
1935
|
```
|
|
924
1936
|
|
|
1937
|
+
#### Params
|
|
1938
|
+
|
|
1939
|
+
| Name | Type | Description |
|
|
1940
|
+
|------------------------|--------------------|--------------------------------------------------------------------------------------------------|
|
|
1941
|
+
| `videoId` | `IVideoProperties` | The video properties of the stream to reset track for. |
|
|
1942
|
+
| `trackType` | `TrackType` | The type of the track to reset (e.g., 'TEXT', 'AUDIO', 'VIDEO'). |
|
|
1943
|
+
| `groupId` *(optional)* | `string` | The group ID of the track to reset. If not provided, the first track in the group will be reset. |
|
|
1944
|
+
|
|
1945
|
+
#### Return value
|
|
1946
|
+
|
|
1947
|
+
Resolves when the track is successfully reset.
|
|
1948
|
+
|
|
1949
|
+
#### Possible errors
|
|
1950
|
+
|
|
1951
|
+
Error If parameters are invalid or if the track type is not supported.
|
|
1952
|
+
|
|
1953
|
+
#### Example
|
|
1954
|
+
|
|
1955
|
+
```ts
|
|
1956
|
+
// Example of resetting a track for a stream
|
|
1957
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
1958
|
+
// Reset the audio track in the group with ID 'audioGroup1'
|
|
1959
|
+
await sos.stream.resetTrack(videoId, 'AUDIO', 'audioGroup1');
|
|
1960
|
+
```
|
|
1961
|
+
|
|
925
1962
|
<Separator />
|
|
926
1963
|
|
|
927
1964
|
### resume()
|
|
928
1965
|
|
|
929
|
-
The `resume()` method resumes the stream
|
|
1966
|
+
The `resume()` method resumes the paused stream by `pause()` function.
|
|
930
1967
|
|
|
931
1968
|
```ts expandable
|
|
932
1969
|
resume(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
933
1970
|
```
|
|
934
1971
|
|
|
1972
|
+
#### Params
|
|
1973
|
+
|
|
1974
|
+
| Name | Type | Description |
|
|
1975
|
+
|----------|----------|------------------------------------------------|
|
|
1976
|
+
| `uri` | `string` | Network address where the stream is available. |
|
|
1977
|
+
| `x` | `number` | Stream x-position on the screen |
|
|
1978
|
+
| `y` | `number` | Stream y-position on the screen |
|
|
1979
|
+
| `width` | `number` | Stream width on the screen |
|
|
1980
|
+
| `height` | `number` | Stream height on the screen |
|
|
1981
|
+
|
|
1982
|
+
#### Return value
|
|
1983
|
+
|
|
1984
|
+
Returns a promise that resolves when the stream is successfully resumed.
|
|
1985
|
+
|
|
1986
|
+
#### Possible errors
|
|
1987
|
+
|
|
1988
|
+
Error If parameters are invalid.
|
|
1989
|
+
|
|
1990
|
+
#### Example
|
|
1991
|
+
|
|
1992
|
+
```ts
|
|
1993
|
+
// Example of resuming a paused stream
|
|
1994
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080); // Start
|
|
1995
|
+
await sos.stream.pause('http://example.com/stream', 0, 0, 1920, 1080); // Pause
|
|
1996
|
+
// ... after some time
|
|
1997
|
+
await sos.stream.resume('http://example.com/stream', 0, 0, 1920, 1080); // Resume
|
|
1998
|
+
```
|
|
1999
|
+
|
|
935
2000
|
<Separator />
|
|
936
2001
|
|
|
937
2002
|
### selectTrack()
|
|
938
2003
|
|
|
939
|
-
The `selectTrack()` method selects a track of a stream.
|
|
2004
|
+
The `selectTrack()` method selects a text (subtitles), video or audio track of a stream.
|
|
940
2005
|
|
|
941
2006
|
```ts expandable
|
|
942
2007
|
selectTrack(videoId: IVideoProperties, trackType: TrackType, groupId: string, trackIndex: number): Promise<void>;
|
|
943
2008
|
// show-more
|
|
2009
|
+
/**
|
|
2010
|
+
* Video properties interface for defining the properties of a played video.
|
|
2011
|
+
*/
|
|
944
2012
|
interface IVideoProperties {
|
|
945
2013
|
uri: string;
|
|
946
2014
|
x: number;
|
|
@@ -949,16 +2017,83 @@ interface IVideoProperties {
|
|
|
949
2017
|
height: number;
|
|
950
2018
|
}
|
|
951
2019
|
|
|
2020
|
+
/**
|
|
2021
|
+
* Available track types for media streams.
|
|
2022
|
+
*/
|
|
952
2023
|
type TrackType = 'TEXT' | 'AUDIO' | 'VIDEO';
|
|
953
2024
|
|
|
954
2025
|
```
|
|
955
2026
|
|
|
2027
|
+
#### Params
|
|
2028
|
+
|
|
2029
|
+
| Name | Type | Description |
|
|
2030
|
+
|--------------|--------------------|-------------------------------------------------------------------|
|
|
2031
|
+
| `videoId` | `IVideoProperties` | The video properties of the stream to select track for. |
|
|
2032
|
+
| `trackType` | `TrackType` | The type of the track to select (e.g., 'TEXT', 'AUDIO', 'VIDEO'). |
|
|
2033
|
+
| `groupId` | `string` | The group ID of the track to select. |
|
|
2034
|
+
| `trackIndex` | `number` | The index of the track to select within the group. |
|
|
2035
|
+
|
|
2036
|
+
#### Return value
|
|
2037
|
+
|
|
2038
|
+
Resolves when the track is successfully selected.
|
|
2039
|
+
|
|
2040
|
+
#### Possible errors
|
|
2041
|
+
|
|
2042
|
+
Error If parameters are invalid or if the track type is not supported.
|
|
2043
|
+
|
|
2044
|
+
#### Example
|
|
2045
|
+
|
|
2046
|
+
```ts
|
|
2047
|
+
// Example of selecting a track for a stream
|
|
2048
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080);
|
|
2049
|
+
|
|
2050
|
+
// Select the first audio track in the group with ID 'audioGroup1'
|
|
2051
|
+
await sos.stream.selectTrack(videoId, 'AUDIO', 'audioGroup1', 0);
|
|
2052
|
+
// Select the first text track in the group with ID 'subtitlesGroup1'
|
|
2053
|
+
await sos.stream.selectTrack(videoId, 'TEXT', 'subtitlesGroup1', 0);
|
|
2054
|
+
// Select the first video track in the group with ID 'videoGroup1'
|
|
2055
|
+
await sos.stream.selectTrack(videoId, 'VIDEO', 'videoGroup1', 0);
|
|
2056
|
+
```
|
|
2057
|
+
|
|
2058
|
+
:::note[GitHub Example]
|
|
2059
|
+
|
|
2060
|
+
- [ How to set subtitles for a stream](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/stream-subtitles)
|
|
2061
|
+
|
|
2062
|
+
:::
|
|
2063
|
+
|
|
956
2064
|
<Separator />
|
|
957
2065
|
|
|
958
2066
|
### stop()
|
|
959
2067
|
|
|
960
|
-
The `stop()` method stops the stream, it can't be resumed with `resume()`.
|
|
2068
|
+
The `stop()` method stops the active stream, it can't be later resumed with `resume()`.
|
|
961
2069
|
|
|
962
2070
|
```ts expandable
|
|
963
2071
|
stop(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
2072
|
+
```
|
|
2073
|
+
|
|
2074
|
+
#### Params
|
|
2075
|
+
|
|
2076
|
+
| Name | Type | Description |
|
|
2077
|
+
|----------|----------|------------------------------------------------|
|
|
2078
|
+
| `uri` | `string` | Network address where the stream is available. |
|
|
2079
|
+
| `x` | `number` | Stream x-position on the screen |
|
|
2080
|
+
| `y` | `number` | Stream y-position on the screen |
|
|
2081
|
+
| `width` | `number` | Stream width on the screen |
|
|
2082
|
+
| `height` | `number` | Stream height on the screen |
|
|
2083
|
+
|
|
2084
|
+
#### Return value
|
|
2085
|
+
|
|
2086
|
+
Returns a promise that resolves when the stream is stopped.
|
|
2087
|
+
|
|
2088
|
+
#### Possible errors
|
|
2089
|
+
|
|
2090
|
+
Error If parameters are invalid.
|
|
2091
|
+
|
|
2092
|
+
#### Example
|
|
2093
|
+
|
|
2094
|
+
```ts
|
|
2095
|
+
// Example of stopping an active stream
|
|
2096
|
+
await sos.stream.play('http://example.com/stream', 0, 0, 1920, 1080); // Start
|
|
2097
|
+
// ... after some time
|
|
2098
|
+
await sos.stream.stop('http://example.com/stream', 0, 0, 1920, 1080); // Stop
|
|
964
2099
|
```
|