@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/video.md
CHANGED
|
@@ -4,36 +4,132 @@ sidebar_position: 0
|
|
|
4
4
|
|
|
5
5
|
# video
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Learn more about using this API [here](https://developers.signageos.io/docs/applets/api-guides/video)
|
|
9
|
-
</Admonition>
|
|
7
|
+
We know how crucial video is for digital signage. So we made it easy. This guide will walk you through playing video using the sos.video API. This allows you to play video natively on any platform.
|
|
10
8
|
|
|
11
|
-
The `sos.video`
|
|
9
|
+
The `sos.video` provides you 4 methods to handle the playback:
|
|
10
|
+
- `prepare()` - Prepare will load the video into memory and prepare it for immediate playback.
|
|
11
|
+
- `play()` - This method loads the video into memory (if it hasn't been loaded previously) and starts the video playback.
|
|
12
|
+
- `pause()` / `resume()` - This method pauses the video that was previously started to play, it is possible to resume the playback with `resume()`.
|
|
13
|
+
- `stop()` - This method stops the playback and unloads the video from memory.
|
|
12
14
|
|
|
13
|
-
:::warning
|
|
14
|
-
First 5 parameters (uri, x, y, width, height) are unique identifiers for playing the video using play, stop, resume and pause methods.
|
|
15
|
+
:::warning Video identification
|
|
16
|
+
First 5 parameters (uri, x, y, width, and height) are unique identifiers for playing the video using play, stop, resume, and pause methods.
|
|
15
17
|
:::
|
|
16
18
|
|
|
19
|
+
## Gapless video playback
|
|
20
|
+
It is often desirable to be able to play different videos consecutively without "black" frames. To achieve this next video in the queue needs to be loaded before the current video ends. How to achieve this may differ from platform to platform. Applet JS SDK handles this under the hood and provides you with `prepare()`, `play()` and `stop()` methods.
|
|
21
|
+
Each video has to be pre-loaded with `prepare()` while the previous video is still playing, and after the video ends it should be unloaded immediately with `stop()`. This is because some (especially older ones) platforms support that only 2 videos are loaded into memory at any time (one playing and one ready to play).
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const { filePath } = await sos.offline.cache.loadOrSaveFile(
|
|
27
|
+
'video-1.mp4',
|
|
28
|
+
'https://static.signageos.io/assets/video-test-1_e07fc21a7a72e3d33478243bd75d7743.mp4',
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const video = [filePath, 0, 0, 1280, 720];
|
|
32
|
+
|
|
33
|
+
await sos.video.play(...video);
|
|
34
|
+
|
|
35
|
+
// pause the video after 2s
|
|
36
|
+
setTimeout(() => sos.video.pause(...video), 2000);
|
|
37
|
+
|
|
38
|
+
// resume the paused video
|
|
39
|
+
setTimeout(() => sos.video.resume(...video), 2500);
|
|
40
|
+
|
|
41
|
+
// stop and unload the video
|
|
42
|
+
setTimeout(() => sos.video.stop(...video), 4000);
|
|
43
|
+
```
|
|
44
|
+
|
|
17
45
|
## Methods
|
|
18
46
|
|
|
19
47
|
### onceEnded()
|
|
20
48
|
|
|
21
|
-
The `onceEnded()` method returns a promise
|
|
49
|
+
The `onceEnded()` method returns a promise that is resolved after the specified video ends.
|
|
22
50
|
|
|
23
51
|
```ts expandable
|
|
24
52
|
onceEnded(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
25
53
|
```
|
|
26
54
|
|
|
55
|
+
#### Params
|
|
56
|
+
|
|
57
|
+
| Name | Type | Description |
|
|
58
|
+
|----------|----------|------------------------------------------------|
|
|
59
|
+
| `uri` | `string` | Address to remote (online) or local video file |
|
|
60
|
+
| `x` | `number` | x-position for video on screen |
|
|
61
|
+
| `y` | `number` | y-position for video on screen |
|
|
62
|
+
| `width` | `number` | Video width on screen |
|
|
63
|
+
| `height` | `number` | Video height on screen |
|
|
64
|
+
|
|
65
|
+
#### Return value
|
|
66
|
+
|
|
67
|
+
Returns a promise that resolves when the video ends.
|
|
68
|
+
|
|
69
|
+
#### Possible errors
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
- Error If the parameters are not valid.
|
|
73
|
+
- Error If the video was not played yet.
|
|
74
|
+
|
|
75
|
+
#### Example
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
// Example of using onceEnded to wait for a video to end
|
|
79
|
+
await sos.video.prepare('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
80
|
+
while (true) {
|
|
81
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
82
|
+
// Wait for the video to stop to start playing it again
|
|
83
|
+
await sos.video.onceEnded('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
27
87
|
<Separator />
|
|
28
88
|
|
|
29
89
|
### onceStop()
|
|
30
90
|
|
|
31
|
-
The `
|
|
91
|
+
The `onceStop()` method returns a promise that is resolved after the specified video has been stopped.
|
|
32
92
|
|
|
33
93
|
```ts expandable
|
|
34
94
|
onceStop(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
35
95
|
```
|
|
36
96
|
|
|
97
|
+
#### Params
|
|
98
|
+
|
|
99
|
+
| Name | Type | Description |
|
|
100
|
+
|----------|----------|------------------------------------------------|
|
|
101
|
+
| `uri` | `string` | Address to remote (online) or local video file |
|
|
102
|
+
| `x` | `number` | x-position for video on screen |
|
|
103
|
+
| `y` | `number` | y-position for video on screen |
|
|
104
|
+
| `width` | `number` | Video width on screen |
|
|
105
|
+
| `height` | `number` | Video height on screen |
|
|
106
|
+
|
|
107
|
+
#### Return value
|
|
108
|
+
|
|
109
|
+
Returns a promise that resolves when the video is stopped.
|
|
110
|
+
|
|
111
|
+
#### Possible errors
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
- Error If the parameters are not valid.
|
|
115
|
+
- Error If the video was not played yet.
|
|
116
|
+
|
|
117
|
+
#### Example
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
// Example of using onceStop to wait for a video to stop
|
|
121
|
+
await sos.video.prepare('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
122
|
+
while (true) {
|
|
123
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
124
|
+
// Wait few seconds for the video to play
|
|
125
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
126
|
+
// Stop the video and wait for it to stop
|
|
127
|
+
await sos.video.stop('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
128
|
+
await sos.video.onceStop('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
129
|
+
// Now the video is stopped, and we can play it again
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
37
133
|
<Separator />
|
|
38
134
|
|
|
39
135
|
### onEnded()
|
|
@@ -43,13 +139,24 @@ The `onEnded()` method sets up a listener, which is called whenever a video fini
|
|
|
43
139
|
```ts expandable
|
|
44
140
|
onEnded(listener: (event: IVideoEvent) => void): void;
|
|
45
141
|
// show-more
|
|
142
|
+
/**
|
|
143
|
+
* Represents an event related to video playback.
|
|
144
|
+
*/
|
|
46
145
|
interface IVideoEvent {
|
|
146
|
+
/** The type of the video event. */
|
|
47
147
|
type: VideoEventType;
|
|
148
|
+
/** Properties of video that created the event */
|
|
48
149
|
srcArguments: IVideoProperties;
|
|
49
150
|
}
|
|
50
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Represents the types of video events that can occur.
|
|
154
|
+
*/
|
|
51
155
|
type VideoEventType = 'prepare' | 'play' | 'stop' | 'pause' | 'resume' | 'ended' | 'error';
|
|
52
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Video properties interface for defining the properties of a played video.
|
|
159
|
+
*/
|
|
53
160
|
interface IVideoProperties {
|
|
54
161
|
uri: string;
|
|
55
162
|
x: number;
|
|
@@ -60,6 +167,26 @@ interface IVideoProperties {
|
|
|
60
167
|
|
|
61
168
|
```
|
|
62
169
|
|
|
170
|
+
#### Params
|
|
171
|
+
|
|
172
|
+
| Name | Type | Description |
|
|
173
|
+
|------------|--------------------------------|----------------------------------------------------------------|
|
|
174
|
+
| `listener` | `(event: IVideoEvent) => void` | The listener function to be called when an ended event occurs. |
|
|
175
|
+
|
|
176
|
+
#### Return value
|
|
177
|
+
|
|
178
|
+
Resolves when the listener is successfully set up.
|
|
179
|
+
|
|
180
|
+
#### Example
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
// Play a video and handle the end of playback
|
|
184
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
185
|
+
sos.video.onEnded((event) => {
|
|
186
|
+
console.log('Video ended:', event);
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
63
190
|
<Separator />
|
|
64
191
|
|
|
65
192
|
### onError()
|
|
@@ -69,13 +196,24 @@ The `onError()` method sets up a listener, which is called whenever a video fail
|
|
|
69
196
|
```ts expandable
|
|
70
197
|
onError(listener: (event: IVideoEvent) => void): void;
|
|
71
198
|
// show-more
|
|
199
|
+
/**
|
|
200
|
+
* Represents an event related to video playback.
|
|
201
|
+
*/
|
|
72
202
|
interface IVideoEvent {
|
|
203
|
+
/** The type of the video event. */
|
|
73
204
|
type: VideoEventType;
|
|
205
|
+
/** Properties of video that created the event */
|
|
74
206
|
srcArguments: IVideoProperties;
|
|
75
207
|
}
|
|
76
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Represents the types of video events that can occur.
|
|
211
|
+
*/
|
|
77
212
|
type VideoEventType = 'prepare' | 'play' | 'stop' | 'pause' | 'resume' | 'ended' | 'error';
|
|
78
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Video properties interface for defining the properties of a played video.
|
|
216
|
+
*/
|
|
79
217
|
interface IVideoProperties {
|
|
80
218
|
uri: string;
|
|
81
219
|
x: number;
|
|
@@ -86,22 +224,53 @@ interface IVideoProperties {
|
|
|
86
224
|
|
|
87
225
|
```
|
|
88
226
|
|
|
227
|
+
#### Params
|
|
228
|
+
|
|
229
|
+
| Name | Type | Description |
|
|
230
|
+
|------------|--------------------------------|----------------------------------------------------------|
|
|
231
|
+
| `listener` | `(event: IVideoEvent) => void` | The listener function to be called when an error occurs. |
|
|
232
|
+
|
|
233
|
+
#### Return value
|
|
234
|
+
|
|
235
|
+
Resolves when the listener is successfully set up.
|
|
236
|
+
|
|
237
|
+
#### Example
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
// Play a video and handle errors
|
|
241
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
242
|
+
sos.video.onError((event) => {
|
|
243
|
+
console.error('Video error:', event);
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
89
247
|
<Separator />
|
|
90
248
|
|
|
91
249
|
### onPause()
|
|
92
250
|
|
|
93
|
-
The `onPause()` method sets up a listener, which is called whenever a video is paused
|
|
251
|
+
The `onPause()` method sets up a listener, which is called whenever a video is paused with `pause()` method.
|
|
94
252
|
|
|
95
253
|
```ts expandable
|
|
96
254
|
onPause(listener: (event: IVideoEvent) => void): void;
|
|
97
255
|
// show-more
|
|
256
|
+
/**
|
|
257
|
+
* Represents an event related to video playback.
|
|
258
|
+
*/
|
|
98
259
|
interface IVideoEvent {
|
|
260
|
+
/** The type of the video event. */
|
|
99
261
|
type: VideoEventType;
|
|
262
|
+
/** Properties of video that created the event */
|
|
100
263
|
srcArguments: IVideoProperties;
|
|
101
264
|
}
|
|
102
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Represents the types of video events that can occur.
|
|
268
|
+
*/
|
|
103
269
|
type VideoEventType = 'prepare' | 'play' | 'stop' | 'pause' | 'resume' | 'ended' | 'error';
|
|
104
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Video properties interface for defining the properties of a played video.
|
|
273
|
+
*/
|
|
105
274
|
interface IVideoProperties {
|
|
106
275
|
uri: string;
|
|
107
276
|
x: number;
|
|
@@ -112,6 +281,26 @@ interface IVideoProperties {
|
|
|
112
281
|
|
|
113
282
|
```
|
|
114
283
|
|
|
284
|
+
#### Params
|
|
285
|
+
|
|
286
|
+
| Name | Type | Description |
|
|
287
|
+
|------------|--------------------------------|---------------------------------------------------------------|
|
|
288
|
+
| `listener` | `(event: IVideoEvent) => void` | The listener function to be called when a pause event occurs. |
|
|
289
|
+
|
|
290
|
+
#### Return value
|
|
291
|
+
|
|
292
|
+
Resolves when the listener is successfully set up.
|
|
293
|
+
|
|
294
|
+
#### Example
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
// Play a video and handle the pause event
|
|
298
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
299
|
+
sos.video.onPause((event) => {
|
|
300
|
+
console.log('Video paused:', event); // Logs the pause event
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
115
304
|
<Separator />
|
|
116
305
|
|
|
117
306
|
### onPlay()
|
|
@@ -121,13 +310,24 @@ The `onPlay()` method sets up a listener, which is called whenever a video start
|
|
|
121
310
|
```ts expandable
|
|
122
311
|
onPlay(listener: (event: IVideoEvent) => void): void;
|
|
123
312
|
// show-more
|
|
313
|
+
/**
|
|
314
|
+
* Represents an event related to video playback.
|
|
315
|
+
*/
|
|
124
316
|
interface IVideoEvent {
|
|
317
|
+
/** The type of the video event. */
|
|
125
318
|
type: VideoEventType;
|
|
319
|
+
/** Properties of video that created the event */
|
|
126
320
|
srcArguments: IVideoProperties;
|
|
127
321
|
}
|
|
128
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Represents the types of video events that can occur.
|
|
325
|
+
*/
|
|
129
326
|
type VideoEventType = 'prepare' | 'play' | 'stop' | 'pause' | 'resume' | 'ended' | 'error';
|
|
130
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Video properties interface for defining the properties of a played video.
|
|
330
|
+
*/
|
|
131
331
|
interface IVideoProperties {
|
|
132
332
|
uri: string;
|
|
133
333
|
x: number;
|
|
@@ -138,22 +338,54 @@ interface IVideoProperties {
|
|
|
138
338
|
|
|
139
339
|
```
|
|
140
340
|
|
|
341
|
+
#### Params
|
|
342
|
+
|
|
343
|
+
| Name | Type | Description |
|
|
344
|
+
|------------|--------------------------------|--------------------------------------------------------------|
|
|
345
|
+
| `listener` | `(event: IVideoEvent) => void` | The listener function to be called when a play event occurs. |
|
|
346
|
+
|
|
347
|
+
#### Return value
|
|
348
|
+
|
|
349
|
+
Resolves when the listener is successfully set up.
|
|
350
|
+
|
|
351
|
+
#### Example
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
// Play a video and handle the play event
|
|
355
|
+
await sos.video.prepare('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
356
|
+
sos.video.onPlay((event) => {
|
|
357
|
+
console.log('Video started playing:', event);
|
|
358
|
+
});
|
|
359
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
360
|
+
```
|
|
361
|
+
|
|
141
362
|
<Separator />
|
|
142
363
|
|
|
143
364
|
### onPrepare()
|
|
144
365
|
|
|
145
|
-
The `onPrepare()` method sets up a listener, which is called whenever a video
|
|
366
|
+
The `onPrepare()` method sets up a listener, which is called whenever a video starts to be prepared.
|
|
146
367
|
|
|
147
368
|
```ts expandable
|
|
148
369
|
onPrepare(listener: (event: IVideoEvent) => void): void;
|
|
149
370
|
// show-more
|
|
371
|
+
/**
|
|
372
|
+
* Represents an event related to video playback.
|
|
373
|
+
*/
|
|
150
374
|
interface IVideoEvent {
|
|
375
|
+
/** The type of the video event. */
|
|
151
376
|
type: VideoEventType;
|
|
377
|
+
/** Properties of video that created the event */
|
|
152
378
|
srcArguments: IVideoProperties;
|
|
153
379
|
}
|
|
154
380
|
|
|
381
|
+
/**
|
|
382
|
+
* Represents the types of video events that can occur.
|
|
383
|
+
*/
|
|
155
384
|
type VideoEventType = 'prepare' | 'play' | 'stop' | 'pause' | 'resume' | 'ended' | 'error';
|
|
156
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Video properties interface for defining the properties of a played video.
|
|
388
|
+
*/
|
|
157
389
|
interface IVideoProperties {
|
|
158
390
|
uri: string;
|
|
159
391
|
x: number;
|
|
@@ -164,22 +396,53 @@ interface IVideoProperties {
|
|
|
164
396
|
|
|
165
397
|
```
|
|
166
398
|
|
|
399
|
+
#### Params
|
|
400
|
+
|
|
401
|
+
| Name | Type | Description |
|
|
402
|
+
|------------|--------------------------------|-----------------------------------------------------------------|
|
|
403
|
+
| `listener` | `(event: IVideoEvent) => void` | The listener function to be called when a prepare event occurs. |
|
|
404
|
+
|
|
405
|
+
#### Return value
|
|
406
|
+
|
|
407
|
+
Resolves when the listener is successfully set up.
|
|
408
|
+
|
|
409
|
+
#### Example
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
// Play a video and handle the prepare event
|
|
413
|
+
await sos.video.prepare('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
414
|
+
sos.video.onPrepare((event) => {
|
|
415
|
+
console.log('Video prepared:', event);
|
|
416
|
+
});
|
|
417
|
+
```
|
|
418
|
+
|
|
167
419
|
<Separator />
|
|
168
420
|
|
|
169
421
|
### onResume()
|
|
170
422
|
|
|
171
|
-
The `onResume()` method sets up a listener, which is called whenever a video is resumed
|
|
423
|
+
The `onResume()` method sets up a listener, which is called whenever a video is resumed with the `resume()` method.
|
|
172
424
|
|
|
173
425
|
```ts expandable
|
|
174
426
|
onResume(listener: (event: IVideoEvent) => void): void;
|
|
175
427
|
// show-more
|
|
428
|
+
/**
|
|
429
|
+
* Represents an event related to video playback.
|
|
430
|
+
*/
|
|
176
431
|
interface IVideoEvent {
|
|
432
|
+
/** The type of the video event. */
|
|
177
433
|
type: VideoEventType;
|
|
434
|
+
/** Properties of video that created the event */
|
|
178
435
|
srcArguments: IVideoProperties;
|
|
179
436
|
}
|
|
180
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Represents the types of video events that can occur.
|
|
440
|
+
*/
|
|
181
441
|
type VideoEventType = 'prepare' | 'play' | 'stop' | 'pause' | 'resume' | 'ended' | 'error';
|
|
182
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Video properties interface for defining the properties of a played video.
|
|
445
|
+
*/
|
|
183
446
|
interface IVideoProperties {
|
|
184
447
|
uri: string;
|
|
185
448
|
x: number;
|
|
@@ -190,22 +453,55 @@ interface IVideoProperties {
|
|
|
190
453
|
|
|
191
454
|
```
|
|
192
455
|
|
|
456
|
+
#### Params
|
|
457
|
+
|
|
458
|
+
| Name | Type | Description |
|
|
459
|
+
|------------|--------------------------------|----------------------------------------------------------------|
|
|
460
|
+
| `listener` | `(event: IVideoEvent) => void` | The listener function to be called when a resume event occurs. |
|
|
461
|
+
|
|
462
|
+
#### Return value
|
|
463
|
+
|
|
464
|
+
Resolves when the listener is successfully set up.
|
|
465
|
+
|
|
466
|
+
#### Example
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
// Play a video and handle the resume event
|
|
470
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
471
|
+
sos.video.onResume((event) => {
|
|
472
|
+
console.log('Video resumed:', event); // Logs the resume event
|
|
473
|
+
});
|
|
474
|
+
await sos.video.pause('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
475
|
+
await sos.video.resume('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
476
|
+
```
|
|
477
|
+
|
|
193
478
|
<Separator />
|
|
194
479
|
|
|
195
480
|
### onStop()
|
|
196
481
|
|
|
197
|
-
The `onStop()` method sets up a listener, which is called whenever a video has been stopped.
|
|
482
|
+
The `onStop()` method sets up a listener, which is called whenever a video has been stopped with `stop()` method.
|
|
198
483
|
|
|
199
484
|
```ts expandable
|
|
200
485
|
onStop(listener: (event: IVideoEvent) => void): void;
|
|
201
486
|
// show-more
|
|
487
|
+
/**
|
|
488
|
+
* Represents an event related to video playback.
|
|
489
|
+
*/
|
|
202
490
|
interface IVideoEvent {
|
|
491
|
+
/** The type of the video event. */
|
|
203
492
|
type: VideoEventType;
|
|
493
|
+
/** Properties of video that created the event */
|
|
204
494
|
srcArguments: IVideoProperties;
|
|
205
495
|
}
|
|
206
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Represents the types of video events that can occur.
|
|
499
|
+
*/
|
|
207
500
|
type VideoEventType = 'prepare' | 'play' | 'stop' | 'pause' | 'resume' | 'ended' | 'error';
|
|
208
501
|
|
|
502
|
+
/**
|
|
503
|
+
* Video properties interface for defining the properties of a played video.
|
|
504
|
+
*/
|
|
209
505
|
interface IVideoProperties {
|
|
210
506
|
uri: string;
|
|
211
507
|
x: number;
|
|
@@ -216,31 +512,124 @@ interface IVideoProperties {
|
|
|
216
512
|
|
|
217
513
|
```
|
|
218
514
|
|
|
515
|
+
#### Params
|
|
516
|
+
|
|
517
|
+
| Name | Type | Description |
|
|
518
|
+
|------------|--------------------------------|--------------------------------------------------------------|
|
|
519
|
+
| `listener` | `(event: IVideoEvent) => void` | The listener function to be called when a stop event occurs. |
|
|
520
|
+
|
|
521
|
+
#### Return value
|
|
522
|
+
|
|
523
|
+
Resolves when the listener is successfully set up.
|
|
524
|
+
|
|
525
|
+
#### Example
|
|
526
|
+
|
|
527
|
+
```ts
|
|
528
|
+
// Play a video and handle the stop event
|
|
529
|
+
await sos.video.play('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
530
|
+
sos.video.onStop((event) => {
|
|
531
|
+
console.log('Video stopped:', event);
|
|
532
|
+
});
|
|
533
|
+
// Stop the video later...
|
|
534
|
+
await sos.video.stop('https://example.com/video.mp4', 0, 0, 1920, 1080);
|
|
535
|
+
```
|
|
536
|
+
|
|
219
537
|
<Separator />
|
|
220
538
|
|
|
221
539
|
### pause()
|
|
222
540
|
|
|
223
|
-
The `pause()` method pauses the video
|
|
541
|
+
The `pause()` method pauses the video; playback can be resumed with `resume()`. Stopped video can't be paused.
|
|
224
542
|
|
|
225
543
|
```ts expandable
|
|
226
544
|
pause(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
227
545
|
```
|
|
228
546
|
|
|
547
|
+
#### Params
|
|
548
|
+
|
|
549
|
+
| Name | Type | Description |
|
|
550
|
+
|----------|----------|------------------------------------------------|
|
|
551
|
+
| `uri` | `string` | Address to remote (online) or local video file |
|
|
552
|
+
| `x` | `number` | x-position for video on screen |
|
|
553
|
+
| `y` | `number` | y-position for video on screen |
|
|
554
|
+
| `width` | `number` | Video width on screen |
|
|
555
|
+
| `height` | `number` | Video height on screen |
|
|
556
|
+
|
|
557
|
+
#### Return value
|
|
558
|
+
|
|
559
|
+
Returns a promise that resolves when the video is paused.
|
|
560
|
+
|
|
561
|
+
#### Possible errors
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
- Error If the parameters are not valid.
|
|
565
|
+
- Error If any error occurs during the pausing of the video.
|
|
566
|
+
|
|
567
|
+
#### Example
|
|
568
|
+
|
|
569
|
+
```ts
|
|
570
|
+
// Example of resuming a paused video
|
|
571
|
+
const { filePath } = await sos.offline.cache.loadOrSaveFile('video-1.mp4', 'https://static.signageos.io/assets/video-test-1_e07fc21a7a72e3d33478243bd75d7743.mp4');
|
|
572
|
+
const video = [filePath, 0, 0, 1920, 1080];
|
|
573
|
+
// Prepare the video
|
|
574
|
+
await sos.video.prepare(...video);
|
|
575
|
+
// Play the video
|
|
576
|
+
await sos.video.play(...video);
|
|
577
|
+
// Pause the video after 2 seconds
|
|
578
|
+
setTimeout(() => sos.video.pause(...video), 2000);
|
|
579
|
+
```
|
|
580
|
+
|
|
229
581
|
<Separator />
|
|
230
582
|
|
|
231
583
|
### play()
|
|
232
584
|
|
|
233
|
-
The `play()` method starts the playback of a video previously prepared by `prepare()` method.
|
|
585
|
+
The `play()` method starts the playback of a video or video that has been previously prepared by the `prepare()` method.
|
|
234
586
|
|
|
235
587
|
```ts expandable
|
|
236
588
|
play(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
237
589
|
```
|
|
238
590
|
|
|
591
|
+
#### Params
|
|
592
|
+
|
|
593
|
+
| Name | Type | Description |
|
|
594
|
+
|----------|----------|------------------------------------------------|
|
|
595
|
+
| `uri` | `string` | Address to remote (online) or local video file |
|
|
596
|
+
| `x` | `number` | x-position for video on screen |
|
|
597
|
+
| `y` | `number` | y-position for video on screen |
|
|
598
|
+
| `width` | `number` | Video width on screen |
|
|
599
|
+
| `height` | `number` | Video height on screen |
|
|
600
|
+
|
|
601
|
+
#### Return value
|
|
602
|
+
|
|
603
|
+
Returns a promise that resolves when the video starts playing.
|
|
604
|
+
|
|
605
|
+
#### Possible errors
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
- Error If the parameters are not valid.
|
|
609
|
+
- Error If any error occurs during the playback of the video.
|
|
610
|
+
|
|
611
|
+
#### Example
|
|
612
|
+
|
|
613
|
+
```ts
|
|
614
|
+
const { filePath } = await sos.offline.cache.loadOrSaveFile('fileName', 'https://example.com/video.mp4');
|
|
615
|
+
const video = [filePath, 0, 0, 1920, 1080];
|
|
616
|
+
// Play the video
|
|
617
|
+
await sos.video.play(...video);
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
:::note[GitHub Example]
|
|
621
|
+
|
|
622
|
+
- [ Play one video in infinite loop](https://github.com/signageos/applet-examples/blob/master/examples/content-js-api/video-loop-one)
|
|
623
|
+
- [ Play multiple videos in infinite loop](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/video-multiple)
|
|
624
|
+
- [ Switching video and images in infinite loop](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/video-and-images)
|
|
625
|
+
|
|
626
|
+
:::
|
|
627
|
+
|
|
239
628
|
<Separator />
|
|
240
629
|
|
|
241
630
|
### prepare()
|
|
242
631
|
|
|
243
|
-
The `
|
|
632
|
+
The `prepare()` method loads the video into memory and prepares it for a playback, this is useful for gapless playback.
|
|
244
633
|
|
|
245
634
|
```ts expandable
|
|
246
635
|
prepare(uri: string, x: number, y: number, width: number, height: number, options?: IOptions): Promise<void>;
|
|
@@ -248,7 +637,15 @@ prepare(uri: string, x: number, y: number, width: number, height: number, option
|
|
|
248
637
|
interface IOptions {
|
|
249
638
|
/** @deprecated */
|
|
250
639
|
'4k'?: boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Prepare stream or video in background.
|
|
642
|
+
* @default false
|
|
643
|
+
*/
|
|
251
644
|
background?: boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Initial volume value of the stream.
|
|
647
|
+
* @default 100
|
|
648
|
+
*/
|
|
252
649
|
volume?: number;
|
|
253
650
|
}
|
|
254
651
|
|
|
@@ -256,11 +653,38 @@ interface IOptions {
|
|
|
256
653
|
|
|
257
654
|
#### Params
|
|
258
655
|
|
|
259
|
-
| Name | Type
|
|
260
|
-
|
|
261
|
-
| `
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
656
|
+
| Name | Type | Description |
|
|
657
|
+
|-----------------------------------|------------|------------------------------------------------|
|
|
658
|
+
| `uri` | `string` | Address to remote (online) or local video file |
|
|
659
|
+
| `x` | `number` | x-position for video on screen |
|
|
660
|
+
| `y` | `number` | y-position for video on screen |
|
|
661
|
+
| `width` | `number` | Video width on screen |
|
|
662
|
+
| `height` | `number` | Video height on screen |
|
|
663
|
+
| `options` *(optional)* | `IOptions` | Optional options for preparing the video. |
|
|
664
|
+
| `options.background` *(optional)* | `boolean` | If view should be prepared in background. |
|
|
665
|
+
| `options.volume` *(optional)* | `number` | Initial volume value of the video. |
|
|
666
|
+
|
|
667
|
+
#### Return value
|
|
668
|
+
|
|
669
|
+
Returns a promise which resolves when the video is prepared.
|
|
670
|
+
|
|
671
|
+
#### Possible errors
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
- Error If the parameters are not valid.
|
|
675
|
+
- Error If any error occurs during the preparation of the video.
|
|
676
|
+
|
|
677
|
+
#### Example
|
|
678
|
+
|
|
679
|
+
```ts
|
|
680
|
+
// Example of preparing and playing a video
|
|
681
|
+
const { filePath } = await sos.offline.cache.loadOrSaveFile('video-1.mp4', 'https://static.signageos.io/assets/video-test-1_e07fc21a7a72e3d33478243bd75d7743.mp4');
|
|
682
|
+
const video = [filePath, 0, 0, 1920, 1080];
|
|
683
|
+
// Prepare the video
|
|
684
|
+
await sos.video.prepare(...video);
|
|
685
|
+
// Play the video
|
|
686
|
+
await sos.video.play(...video);
|
|
687
|
+
```
|
|
264
688
|
|
|
265
689
|
<Separator />
|
|
266
690
|
|
|
@@ -276,18 +700,87 @@ removeEventListeners(): void;
|
|
|
276
700
|
|
|
277
701
|
### resume()
|
|
278
702
|
|
|
279
|
-
The `resume()` method resumes the video paused by `pause()
|
|
703
|
+
The `resume()` method resumes the video paused by `pause()` function. Stopped video can't be resumed.
|
|
280
704
|
|
|
281
705
|
```ts expandable
|
|
282
706
|
resume(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
283
707
|
```
|
|
284
708
|
|
|
709
|
+
#### Params
|
|
710
|
+
|
|
711
|
+
| Name | Type | Description |
|
|
712
|
+
|----------|----------|------------------------------------------------|
|
|
713
|
+
| `uri` | `string` | Address to remote (online) or local video file |
|
|
714
|
+
| `x` | `number` | x-position for video on screen |
|
|
715
|
+
| `y` | `number` | y-position for video on screen |
|
|
716
|
+
| `width` | `number` | Video width on screen |
|
|
717
|
+
| `height` | `number` | Video height on screen |
|
|
718
|
+
|
|
719
|
+
#### Return value
|
|
720
|
+
|
|
721
|
+
Returns a promise that resolves when the video is resumed.
|
|
722
|
+
|
|
723
|
+
#### Possible errors
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
- Error If the parameters are not valid.
|
|
727
|
+
- Error If any error occurs during the resuming of the video.
|
|
728
|
+
|
|
729
|
+
#### Example
|
|
730
|
+
|
|
731
|
+
```ts
|
|
732
|
+
// Example of resuming a paused video
|
|
733
|
+
const { filePath } = await sos.offline.cache.loadOrSaveFile('video-1.mp4', 'https://static.signageos.io/assets/video-test-1_e07fc21a7a72e3d33478243bd75d7743.mp4');
|
|
734
|
+
const video = [filePath, 0, 0, 1920, 1080];
|
|
735
|
+
// Prepare the video
|
|
736
|
+
await sos.video.prepare(...video);
|
|
737
|
+
// Play the video
|
|
738
|
+
await sos.video.play(...video);
|
|
739
|
+
// Pause the video after 2 seconds
|
|
740
|
+
setTimeout(() => sos.video.pause(...video), 2000);
|
|
741
|
+
// Resume the video after 3 seconds
|
|
742
|
+
setTimeout(() => sos.video.resume(...video), 5000);
|
|
743
|
+
```
|
|
744
|
+
|
|
285
745
|
<Separator />
|
|
286
746
|
|
|
287
747
|
### stop()
|
|
288
748
|
|
|
289
|
-
The `stop()` method stops the video
|
|
749
|
+
The `stop()` method stops the video; it can't be resumed with the `resume()` method.
|
|
290
750
|
|
|
291
751
|
```ts expandable
|
|
292
752
|
stop(uri: string, x: number, y: number, width: number, height: number): Promise<void>;
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
#### Params
|
|
756
|
+
|
|
757
|
+
| Name | Type | Description |
|
|
758
|
+
|----------|----------|------------------------------------------------|
|
|
759
|
+
| `uri` | `string` | Address to remote (online) or local video file |
|
|
760
|
+
| `x` | `number` | x-position for video on screen |
|
|
761
|
+
| `y` | `number` | y-position for video on screen |
|
|
762
|
+
| `width` | `number` | Video width on screen |
|
|
763
|
+
| `height` | `number` | Video height on screen |
|
|
764
|
+
|
|
765
|
+
#### Return value
|
|
766
|
+
|
|
767
|
+
Returns a promise which resolves when the video is stopped.
|
|
768
|
+
|
|
769
|
+
#### Possible errors
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
- Error If the parameters are not valid.
|
|
773
|
+
- Error If any error occurs during the stopping of the video.
|
|
774
|
+
|
|
775
|
+
#### Example
|
|
776
|
+
|
|
777
|
+
```ts
|
|
778
|
+
// Example of stopping a video
|
|
779
|
+
const { filePath } = await sos.offline.cache.loadOrSaveFile('video-1.mp4', 'https://static.signageos.io/assets/video-test-1_e07fc21a7a72e3d33478243bd75d7743.mp4');
|
|
780
|
+
const video = [filePath, 0, 0, 1920, 1080];
|
|
781
|
+
// Prepare and play the video
|
|
782
|
+
await sos.video.prepare(...video);
|
|
783
|
+
await sos.video.play(...video);
|
|
784
|
+
// Stop the video after 5 seconds
|
|
785
|
+
setTimeout(() => sos.video.stop(...video), 5000);
|
|
293
786
|
```
|