Video Playback
We know how crucial video is for digital signage. So we made it easy. There are several methods you can use for video manipulation.
All methods/events
Methods/Events | Description | Supported since |
---|---|---|
play() | Start video playing | 1.0.3 |
prepare() | Prepare next video | 1.0.3 |
pause() | Pause video | 1.0.3 |
stop() | Completely stop video | 1.0.3 |
resume() | Continue in playing | 1.0.3 |
onceEnded() | Wait until video ends | 1.0.29 |
onEnded() | Event called when video ends | 1.0.3 |
onError() | Event called when video emits error | 1.0.3 |
First 5 parameters (uri, x, y, width, height) are unique identifiers for playing the video using play, stop, resume and pause methods.
If you want to play video in full screen mode, use x = y = 0 and width = document.documentElement.clientWidth and height = document.documentElement.clientHeight as setup parameters.
How it works
play()
Play method calls the internal player and starts the video in correct position.
Parameters
Param | Type | Required | Description |
---|---|---|---|
uri | String | Yes | Address to remote (online) or local video file |
x | Number | Yes | x-position for video on screen |
y | Number | Yes | y-position for video on screen |
width | Number | Yes | Video width on screen |
height | Number | Yes | Video height on screen |
Javascript
await sos.video.play(uri, x, y, width, height);
prepare()
Prepare method calls the internal player and preload the video into memory.
Using prepare()
is mandatory for gapless playback
4k
parameter is no longer needed since Front-display v7.5.0, Tizen Core App v2.1.0.
volume
is supported only on the RaspberryPi.
Parameters
Param | Type | Required | Description |
---|---|---|---|
uri | String | Yes | Address to remote /online/ or local video file |
x | Number | Yes | x-position for video on screen |
y | Number | Yes | y-position for video on screen |
width | Number | Yes | Video width on screen |
height | Number | Yes | Video height on screen |
options | Object | No | Additional video properties |
Options properties
Property | Type | Required | Description |
---|---|---|---|
4k | Boolean | No | Support for 4k video |
^^ | ^^ | ^^ | Deprecated since Tizen Core App v2.1.0 |
background | Boolean | No | Bring video behind the applet html (similar to z-index: -1) |
volume | Number | No | Adjust volume of playing video itself (doesn't adjust display speaker volume) |
^^ | ^^ | ^^ | Supported only on RaspberryPi |
Javascript
// playing video
await sos.video.prepare(uri, x, y, width, height);
// or advanced usage
await sos.video.prepare(uri, x, y, width, height, {
'4k': true,
background: true,
volume: 60,
});
stop(), pause() and resume()
All these methods call the internal player. All variables are mandatory in order to ensure video identification.
Parameters
Param | Type | Required | Description |
---|---|---|---|
uri | String | Yes | Address to remote (online) or local video file |
x | Number | Yes | x-position for video on screen |
y | Number | Yes | y-position for video on screen |
width | Number | Yes | Video width on screen |
height | Number | Yes | Video height on screen |
Javascript
// stop video
await sos.video.stop(uri, x, y, width, height);
// pause
await sos.video.pause(uri, x, y, width, height);
// resume
await sos.video.resume(uri, x, y, width, height);
Event onceEnded
Wait until one specific video is ended.
Parameters
Param | Type | Required | Description |
---|---|---|---|
uri | String | Yes | Address to remote (online) or local video file |
x | Number | Yes | x-position for video on screen |
y | Number | Yes | y-position for video on screen |
width | Number | Yes | Video width on screen |
height | Number | Yes | Video height on screen |
Javascript
// wai on end of video
await sos.video.onceEnded(uri, x, y, width, height);
Events onEnded, onError
All events about played videos can be binded using above mentioned methods. It will emit all events of all playing videos. Video source of emited event can be identified by srcArguments object available in event.
Listener method added as argument accepts event object. It contains these properties:
Property | Description |
---|---|
type | Type of event which can be ended or error string |
srcArguments | Arguments which was passed to play method. Contains uri, x, y, width & height. |
Javascript
// detect video ended
await sos.video.onEnded((event) => { console.log(event); });
// detect video error
await sos.video.onError((event) => { console.log(event); });
Usage with Typescript
You can also use all these methods with signageOS TypeScript.
play(
uri: string,
x: number,
y: number,
width: number,
height: number
): Promise<void>;
prepare(
uri: string,
x: number,
y: number,
width: number,
height: number,
options?: {
'4k'?: boolean;
background?: boolean;
volume?: number;
}
): Promise<void>;
stop(
uri: string,
x: number,
y: number,
width: number,
height: number
): Promise<void>;
pause(
uri: string,
x: number,
y: number,
width: number,
height: number
): Promise<void>;
resume(
uri: string,
x: number,
y: number,
width: number,
height: number
): Promise<void>;
Errors
Although we are doing our best, following errors may occur when working with the video stream.
Code | Type | Message |
---|---|---|
41501 | AppletVideoError | This video was not played yet. The arguments: arguments |
51501 | InternalVideoError | Couldn't play the video. |
51502 | InternalVideoError | Couldn't prepare the video. |
51503 | InternalVideoError | Couldn't stop the video. |
51504 | InternalVideoError | Couldn't pause the video. |
51505 | InternalVideoError | Couldn't resume the video. |