This document describes the Signagelive Widget SDK methods available and their purpose. Currently the SDK has not been rolled out on all devices so some features are limited to: Samsung, LG, Chrome OS or Brightsign players only.
Copy the javascript file into your project and include it in your HTML page as shown in the example below:
<scriptsrc="js/signagelive.js"></script>
Methods
Signagelive.sendReadyToDisplay()
Description
To be used to signal when the player has downloaded the data and assets within the widget and is ready for the content to be shown on screen. By default the media player will automatically show the widget after 2 seconds as this method will not allow it to be delayed further.
Signagelive.sendReadyToDisplay().then(function(){console.log('Widget is displayed...');});
Signagelive.setData(key, value, shared)
Description
A localStorage alternative; where data can be stored on the player and can persist between reloading the widget.
Parameters
key (string): The name/reference for the data being stored. value (string): The data that is going to be stored. shared (boolean): If set to true then data will be accessible to all widgets published to the player
A localStorage alternative; where data stored with Signagelive.setData(key, value, shared) can be retrieved.
Parameters
key (string): The name/reference for the previously stored data. shared (boolean): If set to true, it will search for this key in the global storage of the player.
Signagelive.log('ERROR','Unable to load items from data storage.').then(function(){// Logged});
Signagelive.playVideo()
Description
Used to play video natively on Samsung SSP Tizen displays. Native playback can offer a better visual experience over standard HTML5 video when used in a playlist with other videos and when wanted to render 2 videos with video concurrently.
Parameters
fileURI(s) - a relative URI or array of relative URIs pointing to video files to play (relative to index.html). x - the x coordinate of the video relative to the zone. If you want the video to cover the entire widget zone then this should be 0. y - the y coordinate of the video relative to the zone. If you want the video to cover the entire widget zone then this should be 0. width - the width of the video. If this is larger than the width of the widget zone, this will be scaled down to fit the zone height - the height of the video. If this is larger than the height of the widget zone this will be scaled down to fit the zone. loop - whether or not to loop the video(s) - This will be true by default (makes sense to me) play4K - if playing a 4k video this must be true callbacks - pass in functions to be called when specific events fire. The exact events you can add listeners for are:- onTimeUpdate - use this to receive the current play time of the video- onComplete - fired when a video completes- onError - fired when there is a playback error
Limitations
Your widget must have a transparent background in order for video to be visible. Only 1 video can be played per widget at any one time You can play up to 2 widget zones each with 1 video concurrently @ FHD resolution If playing 4K only 1 video can be played at a time (across all widgets) Videos should not be larger than the widget zone they are scheduled to. Videos that are larger than the widget zone will be scaled down to fit the zone
style.csshtml{background-color:transparent!important;}main.js// Use the new playVideo() SDK API to play a single videoSignagelive.playVideo('content/1.mp4',// File to play (relative to index.html)0,// x pos0,// y pos1920,// width1080,// heighttrue,// loop videofalse,// 4k video (supported screens only)// Video events{onTimeUpdate:onVideoTimeUpdate,onComplete:onVideoComplete,onError:onVideoError}).then(function(success){// Was playback successful?success?console.log('Video playback started successfully.'):console.error('Video playback failed.');});functiononVideoTimeUpdate(video,currentTime){varmessage='Video Time Update: '+currentTime;}functiononVideoComplete(video){varmessage='Video Complete';console.log(message);}functiononVideoError(video,errorMessage){varmessage='Video Error: '+errorMessage;console.error(message);}varvideoPlaylist=['content/1.mp4','content/2.mp4','content/3.mp4',];// Use the new playVideo() SDK API to play a playlist of videosSignagelive.playVideo(videoPlaylist,// Array of video files to play (relative to index.html)0,// x pos0,// y pos1920,// width1080,// heighttrue,// loop videofalse,// 4k video (supported screens only)// Video events{onTimeUpdate:onVideoTimeUpdate,onComplete:onVideoComplete,onError:onVideoError}).then(function(success){// Was playback successful?success?console.log('Video playback started successfully.'):console.error('Video playback failed.');});functiononVideoTimeUpdate(video,currentTime){varmessage='Video Time Update: '+currentTime;document.getElementById('eventText').textContent=message;}functiononVideoComplete(video){varmessage='Video Complete';console.log(message);document.getElementById('eventText').textContent=message;}functiononVideoError(video,errorMessage){varmessage='Video Error: '+errorMessage;console.error(message);document.getElementById('eventText').textContent=message;}
Signagelive.stopVideo()
Description
Used to stop a video that is currently playing as a result of a call to Signagelive.playVideo()
Signagelive.stopVideo().then(function(success){success?console.log('Video stopped.'):console.error('An error occurred stopping the video.');});
Signagelive.getPlayerDetails()
Description
Get details about the player the widget is playing on including Signagelive serial number, site details, model details, and firmware and client information.
Parameters
None
Returns
A promise that resolves to a JSON object containing all of the player details. Example:
{"serial_number":12345,"client_id":"4A:38:95:01:23:54","site_description":"Player 1","address_1":"123 Bond Street","address_2":"","city":"London","state":"London","zip_code":"E17 8BB","reference_code_1":"Ref 1","reference_code_2":"Ref 2","reference_code_3":"Ref 3","time_zone":"Europe/London","utc_offset":0,"player_type":"Tizen","manufacturer":"Samsung","model":"PMF","client_version":"1.15","firmware_version":"T-HKMLAC-2100.2"}
Get detailed information about the TLS (SSL) support of the player.
Parameters
None
Returns
A promise that resolves to a JSON object with TLS support details. The following example shows how the response should look if we are able to get detailed data from the howsmyssl.com API. Note that if the detailed data is available, the detailed_tls_settings_included property will be true and detailed_tls_settings will be populated.
Find out if the player has a network connection and is connected to the internet.
Parameters
None
Returns
A promise that resolves to a JSON object with network and internet connectivity status. The response object contains two boolean values that can be used to determine if the player is connected to a LAN and whether or not it has internet access. Example:
Register a callback that will get called when the widget is to be closed because the media player is moving to the next asset.Note that if the widget does not register a callback using this function then the media player will forcibly close the widget and move next as normal.
Parameters
function callback(Promise resolve, timeInfo) - A reference to a function or anonymous function that will be executed when the Signagelive media player notifies the widget that the widget is about to close.The callback function will have 2 parameters The first is a reference to resolve the promise and notify the media player that the cleanup code has finished executing. The widget developer should always call resolve() after their cleanup code has executed. The second parameter timeInfo provides details about the timing until the widget will be closed, which is dependent on the configuration options provided to the initial call. The timeInfo parameter object has the following properties: millisecondsNotifiedInAdvance millisecondsUntilClosed millisecondsUntilForciblyClosed options - (optional) An optional options object. Configurable options include: millisecondsToNotifyInAdvance - This is the time in milliseconds that the callback is called in advance of the Widget being closed. Default: 500ms, Max: 2000ms millisecondsToWaitForCallbackResolution - This is the time in milliseconds that the media player will wait for the callback method to call resolve() before forcibly closing the widget and moving to the next asset. Default: 500ms, Max: 2000ms
Check HTML5 feature support on the player using Modernizr.
Parameters
featuresToCheck - [Array of strings] representing the features to check. The full list of available features to check are defined in the Modernizr documentation.
Returns
A promise that resolves to a JSON object that contains results for the features that were requested to be tested. Each feature that was tested will be returned as a boolean property of the results object with the feature name and “_supported” appended to it (see example below). Example response:
Gets data (or files) from an external data source.
Parameters
dataSource - The source of the data. Currently “DSS” will be the only option here integrationId - The public Id of the integration, such as com.signagelive.datasyncservices.authenticatedwebsites objectId - the id of the integration object as defined in the Widget preferences onDataUpdate - a reference to a callback function that will be fired when new data for this data source is available
Returns
A promise that resolves to a JSON object containing the requested data. The actual fields and data returned will be very different for each integration. Developers will need to read the documentation specific to the integration they are using to understand what they can expect to be returned. The example below shows data that might be returned for a corporate dashboard web page made available by the authenticated websites integration. Example: { “webpage”: { “id”: { “id”: “85c91571-a47d-471c-a845-7f9748301dd9” }, “name”: “Corporate Dashboard 1”, “latestSuccessfulCaptureTimestamp”: “2021-03-19T10:00:00”, “latestSuccessfulCapture”: { “name”: “file1”, “src”: “/com.signagelive.datasyncservices.authenticatedwebites/Corporate_Dashboard_1.jpg” } } }
Example
functiononDashboardUpdated(data){console.log('Dashboard Updated: '+JSON.stringify(data,undefined,2));$("#dashboard-img").attr('src',data.webpage.latestSuccessfulCapture.url);$("#last-updated-time").html(data.webpage.latestSuccessfulCaptureTimestamp);}window.addEventListener('widget-init',function(e){// Load dashboard values from Widget preferencesvarcytheDashboardId=Widget.preferences.getItem("Cythe");// Get Data and RenderSignagelive.getExternalData("DSS","com.signagelive.datasyncservices.authenticatedwebsites",cytheDashboardId,onDashboardUpdated).then(function(data){onDashboardUpdated(data);}).catch(function(error){console.error('Error getting data: '+error);});});