top

Provider API

To use Samsung Product API, 

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

Should be loaded in index.html

This API allows developers to share media contents between DLNA devices.

Since : 1.0

Privilege level: public

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

Table of Contents

  1. 1. Type Definitions
    1. 1.1. ItemList
  2. 2. Interfaces
    1. 2.1. MediaProviderSuccessCallback
    2. 2.2. MediaProviderErrorCallback
    3. 2.3. MediaProvider
  3. 2. Full WebIDL

Summary of Interfaces and Methods

Interface Method
MediaProviderSuccessCallback void onsuccess (ItemList itemList, boolean endOfItems, DeviceId providerId)
MediaProviderErrorCallback void onerror (WebAPIError error, DeviceId providerId)
MediaProvider void browse (Item folderItem, unsigned long startIndex, unsigned long requestCount, MediaProviderSuccessCallback browseCallback, optional MediaProviderErrorCallback? errorCallback, optional AbstractFilter? browseFilter, optional SortMode? sortMode)
void search (DOMString keyword, unsigned long startIndex, unsigned long requestCount, MediaProviderSuccessCallback successCallback, optional MediaProviderErrorCallback? errorCallback, optional AbstractFilter searchFilter)

1. Type Definitions

1.1. ItemList

Array of Items which are provided from a device on the network.

  typedef sequence<Item> ItemList;

Since : 1.0

Privilege level: public

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

2. Interfaces

2.1. MediaProviderSuccessCallback

Callback invoked when the retrieving operations of a Provider object is completed successfully.

  [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderSuccessCallback {
      void onsuccess(ItemList itemList,
                     boolean endOfItems,
                     DeviceId providerId);
  };

Since : 1.0

Privilege level: public

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

Methods

onsuccess
Callback function for successful retrieve request.

  void onsuccess(ItemList itemList,
                 boolean endOfItems,
                 DeviceId providerId);

Since : 1.0

Privilege level: public

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

Parameters:

  • itemList: A list of items. If there is no item it will return an empty list.
  • endOfItems: The end of items flag.
  • providerId: The identifier of the provider device.

2.2. MediaProviderErrorCallback

Generic error callback for provider related operations.

  [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderErrorCallback {
      void onerror(WebAPIError error,
                   DeviceId providerId);
  }; 

Since : 1.0

Privilege level: public

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

Methods

onerror
Callback function invoked when error occurs.

  void onerror(WebAPIError error,
               DeviceId providerId);

Since : 1.0

Privilege level: public

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

Parameters:

  • error: object which indicates error type and message.
  • providerId: The identifier of the provider device.

2.3. MediaProvider

This interface provides a means of sharing media content between devices.

  [NoInterfaceObject] interface MediaProvider : Device {
      readonly attribute boolean isSearchable;
      readonly attribute Item rootFolder;

      void browse(Item folderItem,
                  unsigned long startIndex,
                  unsigned long requestCount,
                  MediaProviderSuccessCallback browseCallback,
                  optional MediaProviderErrorCallback? errorCallback,
                  optional AbstractFilter? browseFilter,
                  optional SortMode? sortMode
                  ) raises(WebAPIException);
      void search(DOMString keyword,
                  unsigned long startIndex,
                  unsigned long requestCount,
                  MediaProviderSuccessCallback successCallback,
                  optional MediaProviderErrorCallback? errorCallback,
                  optional AbstractFilter searchFilter) raises(WebAPIException);
  };

Since : 1.0

Privilege level: public

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

Attributes

  • readonly boolean isSearchable
    Specifies whether the provider supports search capability.

    Since : 1.0

    Privilege level: public

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

  • readonly Item rootFolder
    Object of the root folder.

    Since : 1.0

    Privilege level: public

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

Methods

browse
Gets the item list in a folder at the specified starting index and count.

  void browse(Item folderItem,
              unsigned long startIndex,
              unsigned long requestCount,
              MediaProviderSuccessCallback browseCallback,
              optional MediaProviderErrorCallback? errorCallback,
              optional AbstractFilter? browseFilter,
              optional SortMode? sortMode
              ) raises(WebAPIException);

Since : 1.0

Privilege level: public

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

Parameters:

  • folderItem: The item which represents a folder to be retrieved.
  • startIndex: The starting zero-based offset to enumerate children under the specific item.
  • requestCount: The requested number of entries.
  • browseCallback: Success callback invoked when the browse operation is successful  it returns a set of items matching the filter.
  • errorCallback [optional]: Generic error callback for provider related operations.
  • browseFilter [optional]: Filter applied for the browsing.  An AttributeFilter object constructed with ("itemType", null , ItemType[]) can be valid as a parameter.
  • sortMode [optional]: sortMode Sorting mode to be used for arranging the list of content upon completion of the browsing.  Sorting with a title, date, artist and albumTitle as the attribute is only supported on the Tizen Web platform. Other Web platforms will ignore this parameter.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  var serviceProvider; // it is assumed that you has obtained a serviceProvider object. For further details,  see the createServiceProvider() or getServiceProvider().        

  //Define browse callback
  function browseCB(list, endOfItem, providerId) {
      // the item list can be retrieved here
  }         

  function errorCB(error, deviceId) {
      console.log(error.message);
  }                

  // Define a filter to browse a video type only
  var filter = new webapis.AttributeFilter("itemType", null, {"VIDEO"});        

  // Define a sort mode
  var mode = new webapis.SortMode("title", "ASC");                  

  try {
      var providers = serviceProvider.getDeviceFinder().getDeviceList("MEDIAPROVIDER");

      if (providers.length > 0) {
          // retrieves first DMS from the root folder
          providers[0].browse(providers[0].rootFolder, 0, 10, browseCB, errorCB, filter, mode);
      }
  } catch(e) {
      console.log(e.message);
  }
search
Searches content items with a keyword.

  void search(DOMString keyword,
              unsigned long startIndex,
              unsigned long requestCount,
              MediaProviderSuccessCallback successCallback,
              optional MediaProviderErrorCallback? errorCallback,
              optional AbstractFilter searchFilter) raises(WebAPIException);

Since : 1.0

Privilege level: public

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

Parameters:

  • keyword: The keyword which will be used for the search.
  • startIndex: The starting zero-based offset to enumerate children under the specific item.
  • requestCount: The requested number of entries.
  • successCallback: Success callback invoked when the search operation is successful. it returns a set of items matching the filter.
  • errorCallback [optional]: Generic error callback for provider related operations.
  • searchFilter [optional]: Filter applied to the search result. An AttributeFilter object constructed with ("itemType", null , ItemType[]) can be valid as a parameter.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  var serviceProvider; // it is assumed that you has obtained a serviceProvider object. For further details,  see the createServiceProvider() or getServiceProvider().
  var keyword = "foo";         

  //Define browse callback
  function searchCB(list, endOfItem, providerId){
      // the item list can be retrieved here
  }         

  function errorCB(error, device){
      console.log(device + " raises " + error);
  }                 

  // Define a filter to browse a video type only
  var filter = new webapis.AttributeFilter("itemType", null, {"VIDEO"});                  

  try {
      var providers = serviceProvider.getDeviceFinder().getDeviceList("MEDIAPROVIDER");

      if (providers.length > 0) {
          // search the keyword on the first DMS.
          providers[0].search(keyword, 0, 40, searchCB, errorCB, filter);
      }
  } catch(e) {
      console.log(e.message);
  } 

3. Full WebIDL


  module Provider {
      typedef sequence<Item> ItemList;

      [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderSuccessCallback {
          void onsuccess(ItemList itemList,
                         boolean endOfItems,
                         DeviceId providerId);
      };

      [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderErrorCallback {
          void onerror(WebAPIError error,
                       DeviceId providerId);
      }; 

      [NoInterfaceObject] interface MediaProvider : Device {
          readonly attribute boolean isSearchable;
          readonly attribute Item rootFolder;

          void browse(Item folderItem,
                      unsigned long startIndex,
                      unsigned long requestCount,
                      MediaProviderSuccessCallback browseCallback,
                      optional MediaProviderErrorCallback? errorCallback,
                      optional AbstractFilter? browseFilter,
                      optional SortMode? sortMode
                      ) raises(WebAPIException);
          void search(DOMString keyword,
                      unsigned long startIndex,
                      unsigned long requestCount,
                      MediaProviderSuccessCallback successCallback,
                      optional MediaProviderErrorCallback? errorCallback,
                      optional AbstractFilter searchFilter) raises(WebAPIException);
      };
  };

To use Samsung Product API, 

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

Should be loaded in index.html

This API allows developers to share media contents between DLNA devices.

Since : 1.0

Privilege level: public

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

Table of Contents

  1. 1. Type Definitions
    1. 1.1. ItemList
  2. 2. Interfaces
    1. 2.1. MediaProviderSuccessCallback
    2. 2.2. MediaProviderErrorCallback
    3. 2.3. MediaProvider
  3. 2. Full WebIDL

Summary of Interfaces and Methods

Interface Method
MediaProviderSuccessCallback void onsuccess (ItemList itemList, boolean endOfItems, DeviceId providerId)
MediaProviderErrorCallback void onerror (WebAPIError error, DeviceId providerId)
MediaProvider void browse (Item folderItem, unsigned long startIndex, unsigned long requestCount, MediaProviderSuccessCallback browseCallback, optional MediaProviderErrorCallback? errorCallback, optional AbstractFilter? browseFilter, optional SortMode? sortMode)
void search (DOMString keyword, unsigned long startIndex, unsigned long requestCount, MediaProviderSuccessCallback successCallback, optional MediaProviderErrorCallback? errorCallback, optional AbstractFilter searchFilter)

1. Type Definitions

1.1. ItemList

Array of Items which are provided from a device on the network.

  typedef sequence<Item> ItemList;

Since : 1.0

Privilege level: public

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

2. Interfaces

2.1. MediaProviderSuccessCallback

Callback invoked when the retrieving operations of a Provider object is completed successfully.

  [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderSuccessCallback {
      void onsuccess(ItemList itemList,
                     boolean endOfItems,
                     DeviceId providerId);
  };

Since : 1.0

Privilege level: public

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

Methods

onsuccess
Callback function for successful retrieve request.

  void onsuccess(ItemList itemList,
                 boolean endOfItems,
                 DeviceId providerId);

Since : 1.0

Privilege level: public

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

Parameters:

  • itemList: A list of items. If there is no item it will return an empty list.
  • endOfItems: The end of items flag.
  • providerId: The identifier of the provider device.

2.2. MediaProviderErrorCallback

Generic error callback for provider related operations.

  [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderErrorCallback {
      void onerror(WebAPIError error,
                   DeviceId providerId);
  }; 

Since : 1.0

Privilege level: public

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

Methods

onerror
Callback function invoked when error occurs.

  void onerror(WebAPIError error,
               DeviceId providerId);

Since : 1.0

Privilege level: public

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

Parameters:

  • error: object which indicates error type and message.
  • providerId: The identifier of the provider device.

2.3. MediaProvider

This interface provides a means of sharing media content between devices.

  [NoInterfaceObject] interface MediaProvider : Device {
      readonly attribute boolean isSearchable;
      readonly attribute Item rootFolder;

      void browse(Item folderItem,
                  unsigned long startIndex,
                  unsigned long requestCount,
                  MediaProviderSuccessCallback browseCallback,
                  optional MediaProviderErrorCallback? errorCallback,
                  optional AbstractFilter? browseFilter,
                  optional SortMode? sortMode
                  ) raises(WebAPIException);
      void search(DOMString keyword,
                  unsigned long startIndex,
                  unsigned long requestCount,
                  MediaProviderSuccessCallback successCallback,
                  optional MediaProviderErrorCallback? errorCallback,
                  optional AbstractFilter searchFilter) raises(WebAPIException);
  };

Since : 1.0

Privilege level: public

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

Attributes

  • readonly boolean isSearchable
    Specifies whether the provider supports search capability.

    Since : 1.0

    Privilege level: public

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

  • readonly Item rootFolder
    Object of the root folder.

    Since : 1.0

    Privilege level: public

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

Methods

browse
Gets the item list in a folder at the specified starting index and count.

  void browse(Item folderItem,
              unsigned long startIndex,
              unsigned long requestCount,
              MediaProviderSuccessCallback browseCallback,
              optional MediaProviderErrorCallback? errorCallback,
              optional AbstractFilter? browseFilter,
              optional SortMode? sortMode
              ) raises(WebAPIException);

Since : 1.0

Privilege level: public

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

Parameters:

  • folderItem: The item which represents a folder to be retrieved.
  • startIndex: The starting zero-based offset to enumerate children under the specific item.
  • requestCount: The requested number of entries.
  • browseCallback: Success callback invoked when the browse operation is successful  it returns a set of items matching the filter.
  • errorCallback [optional]: Generic error callback for provider related operations.
  • browseFilter [optional]: Filter applied for the browsing.  An AttributeFilter object constructed with ("itemType", null , ItemType[]) can be valid as a parameter.
  • sortMode [optional]: sortMode Sorting mode to be used for arranging the list of content upon completion of the browsing.  Sorting with a title, date, artist and albumTitle as the attribute is only supported on the Tizen Web platform. Other Web platforms will ignore this parameter.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  var serviceProvider; // it is assumed that you has obtained a serviceProvider object. For further details,  see the createServiceProvider() or getServiceProvider().        

  //Define browse callback
  function browseCB(list, endOfItem, providerId) {
      // the item list can be retrieved here
  }         

  function errorCB(error, deviceId) {
      console.log(error.message);
  }                

  // Define a filter to browse a video type only
  var filter = new webapis.AttributeFilter("itemType", null, {"VIDEO"});        

  // Define a sort mode
  var mode = new webapis.SortMode("title", "ASC");                  

  try {
      var providers = serviceProvider.getDeviceFinder().getDeviceList("MEDIAPROVIDER");

      if (providers.length > 0) {
          // retrieves first DMS from the root folder
          providers[0].browse(providers[0].rootFolder, 0, 10, browseCB, errorCB, filter, mode);
      }
  } catch(e) {
      console.log(e.message);
  }
search
Searches content items with a keyword.

  void search(DOMString keyword,
              unsigned long startIndex,
              unsigned long requestCount,
              MediaProviderSuccessCallback successCallback,
              optional MediaProviderErrorCallback? errorCallback,
              optional AbstractFilter searchFilter) raises(WebAPIException);

Since : 1.0

Privilege level: public

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

Parameters:

  • keyword: The keyword which will be used for the search.
  • startIndex: The starting zero-based offset to enumerate children under the specific item.
  • requestCount: The requested number of entries.
  • successCallback: Success callback invoked when the search operation is successful. it returns a set of items matching the filter.
  • errorCallback [optional]: Generic error callback for provider related operations.
  • searchFilter [optional]: Filter applied to the search result. An AttributeFilter object constructed with ("itemType", null , ItemType[]) can be valid as a parameter.

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if the input parameter is not compatible with the expected type.

    • with error type NotSupportedError, if this feature is not supported.

    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


  var serviceProvider; // it is assumed that you has obtained a serviceProvider object. For further details,  see the createServiceProvider() or getServiceProvider().
  var keyword = "foo";         

  //Define browse callback
  function searchCB(list, endOfItem, providerId){
      // the item list can be retrieved here
  }         

  function errorCB(error, device){
      console.log(device + " raises " + error);
  }                 

  // Define a filter to browse a video type only
  var filter = new webapis.AttributeFilter("itemType", null, {"VIDEO"});                  

  try {
      var providers = serviceProvider.getDeviceFinder().getDeviceList("MEDIAPROVIDER");

      if (providers.length > 0) {
          // search the keyword on the first DMS.
          providers[0].search(keyword, 0, 40, searchCB, errorCB, filter);
      }
  } catch(e) {
      console.log(e.message);
  } 

3. Full WebIDL


  module Provider {
      typedef sequence<Item> ItemList;

      [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderSuccessCallback {
          void onsuccess(ItemList itemList,
                         boolean endOfItems,
                         DeviceId providerId);
      };

      [Callback=FunctionOnly, NoInterfaceObject] interface MediaProviderErrorCallback {
          void onerror(WebAPIError error,
                       DeviceId providerId);
      }; 

      [NoInterfaceObject] interface MediaProvider : Device {
          readonly attribute boolean isSearchable;
          readonly attribute Item rootFolder;

          void browse(Item folderItem,
                      unsigned long startIndex,
                      unsigned long requestCount,
                      MediaProviderSuccessCallback browseCallback,
                      optional MediaProviderErrorCallback? errorCallback,
                      optional AbstractFilter? browseFilter,
                      optional SortMode? sortMode
                      ) raises(WebAPIException);
          void search(DOMString keyword,
                      unsigned long startIndex,
                      unsigned long requestCount,
                      MediaProviderSuccessCallback successCallback,
                      optional MediaProviderErrorCallback? errorCallback,
                      optional AbstractFilter searchFilter) raises(WebAPIException);
      };
  };