2.1.1-master.756 • Published 3 months ago

@signageos/smil-player v2.1.1-master.756

Weekly downloads
7
License
MIT
Repository
gitlab
Last release
3 months ago

Draft

SMIL player

How To Install

npm install @signageos/smil-player --save-dev

Basic usage

Smil player is configurable either via options object passed in constructor or from signageOS box using timings.

Basic usage - no signageOS Applet used

When not using signageOS timings you have to specify smil file url.

import { SmilPlayer } from '@signageos/smil-player';

const smilPlayer = new SmilPlayer({
	smilUrl: 'http://example.com/smilFile.smil'
});

// runs indefinitely
await smilPlayer.start();

Basic usage - with signageOS Applet used

When using signageOS timings you can specify number of options which are directly passed to Smil player itself. List of options is defined in package.json. Timings example

import { SmilPlayer } from '@signageos/smil-player';

const smilPlayer = new SmilPlayer();

// runs indefinitely
await smilPlayer.start();

More advanced usage with extra configuration is being developed. Here is a sneak peek

Smil player accepts various options which allows you to customize player behaviour. This is an example how you can inject your custom functionality and modify smil player.

import { SmilPlayer } from '@signageos/smil-player';

const smilPlayer = new SmilPlayer({
	smilUrl: 'http://example.com/smilFile.smil',
	startupHtmlFile: 'https://my.server.com/ma-startupHtmlFile.html',
	backupImageUrl: 'https://my.server.com/failover-image.png',
	serialPortDevice: '/device/ttyUSB0',
	sync: {
		serverUrl: 'https://applet-synchronizer.com',
		groupName: 'mySyncGroup',
		groupIds: ['Display1', 'Display2', 'Display3'],
		deviceId: 'Display1',
	},
	videoBackground: true,
	onlySmilUpdate: true,
	defaultContentDurationSec: 100,
	validator: (smilFileContent: string): boolean => {
		return MyValidator.validate(smilFileContent);
	},
	smilFileDownloader: async (downloadUrl?: string) => {
		const response = await fetch(downloadUrl, {
			method: 'GET',
			headers: {
				'Authorization': MyCustomAuthorizationHeader,
				Accept: 'application/json',
			},
			mode: 'cors',
		});
		return response.json();
	},
	lastModifiedChecker: async (fileSrc: string): Promise<null | string | number> => {
		try {
			const downloadUrl = createDownloadPath(fileSrc);
			const authHeaders = window.getAuthHeaders?.(downloadUrl);
			const promiseRaceArray = [];
			promiseRaceArray.push(
				fetch(downloadUrl, {
					method: 'HEAD',
					headers: {
						...authHeaders,
						Accept: 'application/json',
					},
					mode: 'cors',
				}),
			);
			promiseRaceArray.push(sleep(SMILScheduleEnum.fileCheckTimeout));

			const response = (await Promise.race(promiseRaceArray)) as Response;

			const newLastModified = await response.headers.get('last-modified');
			return newLastModified ? newLastModified : 0;
		} catch (err) {
			debug('Unexpected error occured during lastModified fetch: %O', err);
			return null;
		}
	},
	reporter: async (payload: Payload) => {
		await fetch('https://my-api-url.com/my-endpoint', {
			method: 'POST', // or 'PUT'
			headers: {
				'Content-Type': 'application/json',
			},
			body: JSON.stringify(payload),
		});
	},
	playbackController: async (payload: Payload) => {
		return fetch('https://my-api-url.com/my-endpoint/playbackController', {
			method: 'POST',
			headers: {
				'Content-Type': 'application/json',
			},
			body: JSON.stringify(payload),
		});
	},
});

// runs indefinitely
await smilPlayer.start();

Table of options

OptionDescription
smilUrlUrl where actual smil file is hosted.
startupHtmlFileUrl where smil player welcome html file is hosted.
backupImageUrlUrl for backup image which is displayed in case player cant download smil file, or when something goes wrong during xml parsing.
serialPortDeviceSerial port used for Nexmosphere sensors.
sync.serverUrlUrl where synchronization server is running. Used during synchronization of multiple devices.
sync.groupNameName of the synchronization group which determines which devices will be synchroniized with each other.
sync.groupIdsIds of all devices within synchronization group.
sync.deviceIdId of current device. Must be present in sync group.
videoBackgroundDetermines if videos will be playing in background. With this option on, you can use image overlay over videos.
onlySmilUpdateDetermines if smil player will check for updates all media files in smil file, or only smil file itself.
defaultContentDurationDefault duration of media when no duration is specified in smil file.
validatorModule used for input xml validation.
smilFileDownloaderModule used for downloading smil file from given url.
fetchLastModifiedModule responsible for checking media files for updates.
reporterModule responsible for reporting about events inside player. Example: content downloaded, content playback started, content playback finished etc..
playbackControllerModule used for checking if current element in playlist should be played or not based on api response
2.1.1-master.756

3 months ago

2.1.1-master.754

3 months ago

2.1.0

4 months ago

2.1.0-master.730

4 months ago

2.1.0-master.684

11 months ago

2.1.0-master.610

2 years ago

2.1.0-master.608

2 years ago

2.1.0-master.581

2 years ago

2.1.0-master.604

2 years ago

2.1.0-master.557

2 years ago

2.0.0

2 years ago

2.1.0-master.551

2 years ago

2.1.0-master.548

2 years ago

2.0.0-master.535

2 years ago

1.9.2-master.473

2 years ago

1.9.1-master.448

2 years ago

1.9.1

2 years ago

1.9.1-master.451

2 years ago

1.9.1-master.440

2 years ago

1.9.1-master.432

3 years ago

1.9.1-master.430

3 years ago

1.9.1-master.426

3 years ago

1.9.0-master.417

3 years ago

1.9.0-master.419

3 years ago

1.9.0

3 years ago

1.8.1-master.410

3 years ago

1.8.1-master.407

3 years ago

1.8.1-master.405

3 years ago

1.8.0

3 years ago

1.8.0-master.400

3 years ago

1.7.1-master.398

3 years ago

1.7.1-master.385

3 years ago

1.7.1-master.377

3 years ago

1.7.0-master.362

3 years ago

1.7.1-master.369

3 years ago

1.7.1-master.367

3 years ago

1.7.0

3 years ago

1.6.1-master.353

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.6.0-master.349

3 years ago

1.6.0-master.336

3 years ago

1.6.0-master.335

3 years ago

1.5.0-master.286

3 years ago

1.5.0

3 years ago

1.4.1-master.284

3 years ago

1.3.1-master.272

3 years ago

1.4.0

3 years ago

1.3.1-master.275

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.3.0-master.260

3 years ago

1.2.1

3 years ago

1.2.1-master.250

3 years ago

1.2.1-master.241

3 years ago

1.2.1-master.237

3 years ago

1.2.0

3 years ago

1.2.0-master.232

3 years ago

1.1.1-master.222

3 years ago

1.1.1-master.220

3 years ago

1.1.0

3 years ago

1.1.0-master.215

3 years ago

1.1.0-master.214

3 years ago

1.1.0-master.205

3 years ago

1.0.4

3 years ago

0.1.0-master.202

3 years ago

0.1.0-master.200

3 years ago

0.1.0-master.189

3 years ago

0.1.0-master.182

3 years ago

0.1.0-master.180

3 years ago

0.0.2-master.174

4 years ago

0.0.2-master.166

4 years ago

0.0.2-master.163

4 years ago

0.0.2-master.159

4 years ago

0.0.2-master.149

4 years ago

0.0.2-master.144

4 years ago

0.0.2-master.137

4 years ago

0.0.2-master.132

4 years ago

0.0.2-master.126

4 years ago

0.0.2-master.122

4 years ago

0.0.2-master.120

4 years ago

0.0.2-master.117

4 years ago

0.1.0-master.96

4 years ago

0.1.0-master.50

4 years ago

0.1.0-master.49

4 years ago

0.1.0-master.40

4 years ago

0.0.1

4 years ago

0.1.0-master.31

4 years ago

0.1.0-master.23

4 years ago

0.1.0-master.13

4 years ago

0.1.0-master.10

4 years ago

0.1.0-master.9

4 years ago

0.1.0-master.8

4 years ago