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 B2B 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)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

Summary of Interfaces and Methods

Interface Method
SyncInfo

SyncplayManagerObject

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);

SyncplaySuccessCallback

void onsuccess(Result data);

SyncplayErrorCallback

void onerror(Error data);

SyncplayListener

void onlistener(DOMString data);

1. Type Definitions

1.1 Rotate

Syncplay rotation value. When Syncplay is active, rotation between vertical and horizontal orientations can be enabled or disabled.

enum Rotate {
  "ON",
  "OFF"
};

The following values are supported

  • ON : Enabled.
  • OFF : Disabled.

1.2 Result

Stores the results and information of successful callbacks

dictionary Result {
  DOMString result;
  DOMString data;
};

The following values are supported

  • result : Result of the successful callback
  • data : Saved data of the callback result

1.3 Error

Error value of a callback function

dictionary Error {
  long code;
  DOMString name;
  DOMString message;
};

The following values are supported

  • code : Error code
  • name : Error name
  • message : Error message

1.4 SyncPlayContent

The attribute stores the path and playback time information of Syncplay content.

dictionary SyncPlayContent {
  DOMString path;
  long duration;
};

The following values are supported

  • path : Content path (local and remote paths supported)
  • duration : Content duration time (in seconds)

2. Interfaces

2.1 SyncInfo

Syncplay settings information object

[NoInterfaceObject] interface SyncInfo {
  attribute long rectX;
  attribute long rectY;
  attribute long rectWidth;
  attribute long rectHeight;
  attribute long groupID;
  attribute Rotate rotate;
};

Attributes

  • long rectX
    Syncplay x coordinate
  • long rectY
    Syncplay y coordinate
  • long rectWidth
    Syncplay width value
  • long rectHeight
    Syncplay height value
  • long groupID
    Syncplay group ID (range: 16-bit int). Each device with the same group ID operates Syncplay as a single group.
  • Rotate rotate
    Syncplay display orientation

2.2 SyncplayManagerObject

The interface defines what is instantiated by the Syncplay object of the Tizen Samsung Product API.
A webapis.syncplay object allows access to the functionality of the Syncplay API.

[NoInterfaceObject] interface SyncplayManagerObject {
  readonly attribute SyncplayManager syncplay;
};
WebApi implements SyncplayManagerObject;

Since : 6.5

Attributes

  • readonly SyncplayManager syncplay
    Namespace for the Syncplay API
    Since : 6.5

2.3 SyncplayManager

This interface provides methods to use the Syncplay functionalities.

[NoInterfaceObject] interface 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);
};

Methods

getVersion

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

DOMString getVersion();

Product : B2B (LFD)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

Return Value :

  • DOMString : Version of a Syncplay module

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

Since : 6.5

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)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

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 [optional][nullable] : 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

Since : 6.5

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)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

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 passed for an input parameter

Since : 6.5

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)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

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

Since : 6.5

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)

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

Parameters :

  • onsuccess : Callback method to be invoked when this method executes successfully
  • onerror [optional][nullable] : 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

Since : 6.5

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);
}

2.4 SyncplaySuccessCallback

This callback interface defines the device set information success callback.

[Callback = FunctionOnly, NoInterfaceObject] interface SyncplaySuccessCallback {
  void onsuccess(Result data);
};

Methods

onsuccess

Callback parameter

void onsuccess(Result data);

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

Parameters :

  • data : Status of the operation

Since : 6.5

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);
}

2.5 SyncplayErrorCallback

This callback interface defines the device set information error callback.

[Callback = FunctionOnly, NoInterfaceObject] interface SyncplayErrorCallback {
  void onerror(Error data);
};

Methods

onerror

Callback parameter

void onerror(Error data);

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

Parameters :

  • data : Status of the operation

Since : 6.5

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);
}

2.6 SyncplayListener

This listener interface defines the set information callback for Syncplay.

[Callback = FunctionOnly, NoInterfaceObject] interface SyncplayListener {
  void onlistener(DOMString data);
};

Methods

onlistener

Syncplay listener

void onlistener(DOMString data);

Privilege Level : Partner

Privilege : http://developer.samsung.com/privilege/syncplay

Parameters :

  • data : Status of the operation

Since : 6.5

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);
}

3. Full WebIDL

module Syncplay {
  enum Rotate {
    "ON",
    "OFF"
  };

  dictionary Result {
    DOMString result;
    DOMString data;
  };

  dictionary Error {
    long code;
    DOMString name;
    DOMString message;
  };

  dictionary SyncPlayContent {
    DOMString path;
    long duration;
  };

  [NoInterfaceObject] interface SyncInfo {
    attribute long rectX;
    attribute long rectY;
    attribute long rectWidth;
    attribute long rectHeight;
    attribute long groupID;
    attribute Rotate rotate;
  };

  [NoInterfaceObject] interface SyncplayManagerObject {
    readonly attribute SyncplayManager syncplay;
  };

  WebApi implements SyncplayManagerObject;

  [NoInterfaceObject] interface 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);
  };

  [Callback = FunctionOnly, NoInterfaceObject] interface SyncplaySuccessCallback {
    void onsuccess(Result data);
  };

  [Callback = FunctionOnly, NoInterfaceObject] interface SyncplayErrorCallback {
    void onerror(Error data);
  };

  [Callback = FunctionOnly, NoInterfaceObject] interface SyncplayListener {
    void onlistener(DOMString data);
  };

};