Syncplay API

To use Samsung Product API, 

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

This module defines a signage device's Syncplay functionalities, provided by the Tizen Samsung Product API. Devices assigned to the same group can use Syncplay to play the same content.

Since: 6.5

Product: B2B (LFD)


Summary of Interfaces and Methods

Interface Method
SyncplayErrorCallback void onerror();
SyncplayListener void onlistener();
SyncplayManager DOMString getVersion();
void createPlaylist(SyncPlayContent [] contentsArr, SyncplaySuccessCallback onsuccess, optional SyncplayErrorCallback? onerror);
void start(SyncInfo syncinfo, SyncplayListener onlistener);
void stop(SyncplayListener onlistener);
void removePlaylist(SyncplaySuccessCallback onsuccess, optional SyncplayErrorCallback? onerror);

1. Interfaces

1.1. SyncplayErrorCallback

TThis callback interface defines the device set information error callback.

Methods

onerror
Callback parameter.

void onerror(Error data);

Product: B2B (LFD)

Parameters:

  • data: Status of the operation.

Code example:


		var onsuccess = function(val) {
    console.log("[removePlaylist] success : " + val.result);
}
var onerror = function(error) {
    console.log("[removePlaylist] code :" + error.code + " error name: " + error.name + "  message " + error.message);
}

try {
    webapis.syncplay.removePlaylist(onsuccess, onerror);
} catch (e) {
    console.log("[removePlaylist] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

1.2. SyncplayListener

This listener interface defines the set information callback for Syncplay.

Syncplay::SyncplayListener

Methods

onlistener
Callback parameter.

void onlistener(DOMString data);

Product: B2B (LFD)

Parameters:

  • data: Status of the operation.

Code example:


		var onlistener = function(data) {
    console.log("[stop]data:" + data + "changed");
}

try {           
    webapis.syncplay.stop(onlistener);
} catch (e) {       
    console.log("[stop] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

1.3. SyncplayManager

This interface provides methods to use the Syncplay functionalities.

Syncplay::SyncplayManager

Methods

getVersion
This interface provides a method to get a Syncplay module's version.

DOMString getVersion();

Product: B2B (LFD)

Exceptions:

  • WebAPIException
    • with error type SecurityError if the application does not have the privilege to call this method.

      with error type UnknownError in any other error case.

Code example:


		var Version = null;

try {
    Version = webapis.syncplay.getVersion();
} catch (e) {
    console.log("[getVersion] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

if (null !== Version) {
    console.log("[getVersion] call syncFunction type: " + Version);
}
createPlaylist
This interface provides a method to create a Syncplay playlist with video and image content.

  void createPlaylist(SyncPlayContent [] contentsArr, SyncplaySuccessCallback onsuccess, optional SyncplayErrorCallback? onerror);

Product: B2B (LFD)

Parameters:

  • contentsArr: Array that contains the paths and durations of the playlist content.
  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: Callback method to be invoked when an error occurs The error type is SecurityError if the application does not have the privilege to call this method.

Exceptions:

  • WebAPIException
    • with the error type TypeMismatchError if invalid values are passed for an input parameter.

Code example:


	var sharedDir = tizen.application.getAppSharedURI(PackageId);
		var path = sharedDir + "../res/wgt/syncplay/";
		var playlist = ["image6.jpg","image2.jpg","red.mp4","image5.jpg","blue.mp4","yellow.mp4","red.mp4"];
		var onsuccess = function(val) {
			console.log("[createPlaylist] success : " + val);
		}
		var onerror = function(error) {
			console.log("[createPlaylist] code :" + error.code + " error name: " + error.name + "  message " + error.message);
		}
		var contentsArr = [];
		for (var i = 0; i < 7;="" i++)="" {="" contentsarr[i]="{" path="" :="" path="" +="" playlist[i],="" duration="" :="" 10="" }="" }="" try="" {="" webapis.syncplay.createplaylist(contentsarr,="" onsuccess,="" onerror);="" }="" catch="" (e)="" {="" console.log("[createplaylist]="" call="" syncfunction="" exception="" ["="" +="" e.code="" +="" "]="" name:="" "="" +="" e.name="" +="" "="" message:="" "="" +="" e.message);="" }="">
start
This interface provides a method to start Syncplay.

  void start(SyncInfo syncinfo, SyncplayListener onlistener);

Product: B2B (LFD)

Parameters:

  • syncinfo: Syncplay basic information.
  • onlistener: Syncplay status handler.

Exceptions:

  • WebAPIException
    • with the error type SecurityError if the application does not have the privilege to call this method.

      with the error type TypeMismatchError if invalid values are passed for an input parameter.

Code example:


		var start = null;
var syncinfo = {
    "rectX"     : 0,
    "rectY"    : 0,
    "rectWidth" : 960,
    "rectHeight": 540,
    "groupID"   : 55,
    "rotate"    : "OFF"
}
var onlistener = function(data) {
    console.log("[start]data:" + data + "changed");
}

try {           
    webapis.syncplay.start(syncinfo,onlistener);
} catch (e) {       
    console.log("[start] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}
stop
This interface provides a method to stop Syncplay.

  void stop(SyncplayListener onlistener);

Product: B2B (LFD)

Parameters:

  • onlistener: Listener handler.

Exceptions:

  • WebAPIException
    • with the error type SecurityError if the application does not have the privilege to call this method.

      with the error type TypeMismatchError if invalid values are passed for an input parameter.

Code example:


		var onlistener = function(data) {
    console.log("[stop]data:" + data + "changed");
}

try {           
    webapis.syncplay.stop(onlistener);
} catch (e) {       
    console.log("[stop] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}
removePlaylist
This interface provides a method to reset the playlist created by the createPlaylist API.

  void removePlaylist(SyncplaySuccessCallback onsuccess, optional SyncplayErrorCallback? onerror);

Product: B2B (LFD)

Parameters:

  • onsuccess: Callback method to be invoked when this method executes successfully.
  • onerror: Callback method to be invoked when an error occurs The error type is SecurityError if the application does not have the privilege to call this method. The error type is UnknownError in any other error case.

Exceptions:

  • WebAPIException
    • with the error type TypeMismatchError if an invalid ErrorCallback type is passed for the 'onerror' parameter.

Code example:


		var onsuccess = function(val) {
    console.log("[removePlaylist] success : " + val.result);
}
var onerror = function(error) {
    console.log("[removePlaylist] code :" + error.code + " error name: " + error.name + "  message " + error.message);
}

try {
    webapis.syncplay.removePlaylist(onsuccess, onerror);
} catch (e) {
    console.log("[removePlaylist] call syncFunction exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}