top

ASFService API

To use Samsung Product API, 

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

Should be loaded in index.html

 

This API enables initiating the AllShare Framework.

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Table of Contents

  1. 1. Type Definitions
    1. 1.1. ItemType
    2. 1.2. ServiceState
    3. 1.3. DeviceType
    4. 1.4. DeviceDomain
    5. 1.5. DeviceId
    6. 1.6. DeviceArray
    7. 1.7. IconArray
    8. 1.8. ItemList
  2. 2. Interfaces
    1. 2.1. Item
    2. 2.2. WebApiAllShareObject
    3. 2.3. AllShare
    4. 2.4. ServiceConnectorObject
    5. 2.5. ServiceProviderCreateSuccessCallback
    6. 2.6. ServiceProviderErrorCallback
    7. 2.7. ServiceConnector
    8. 2.8. ServiceProvider
    9. 2.9. DeviceDiscoveryCallback
    10. 2.10. Icon
    11. 2.11. DeviceFinder
    12. 2.12. Device
    13. 2.13. MediaProviderSuccessCallback
    14. 2.14. MediaProviderErrorCallback
    15. 2.15. MediaProvider
  3. 3. Full WebIDL

Summary of Interfaces and Methods

Interface Method
Item  
WebApiAllShareObject  
AllShare  
ServiceConnectorObject  
ServiceProviderCreateSuccessCallback void onsuccess (ServiceProvider serviceProvider)
ServiceProviderErrorCallback void onerror (WebAPIError error, ServiceState state)
ServiceConnector void createServiceProvider (ServiceProviderCreateSuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback)
void deleteServiceProvider (SuccessCallback successCallback, optional ServiceProviderErrorCallback errorCallback)
ServiceProvider? getServiceProvider ()
ServiceProvider DeviceFinder getDeviceFinder ()
ServiceState getServiceState ()
DeviceDiscoveryCallback void ondeviceadded(Device device)
void ondeviceremoved(Device device)
Icon  
DeviceFinder Device getDevice(DeviceType deviceType, DeviceId id)
DeviceArray getDeviceList(DeviceType deviceType)
void refresh()
long addDeviceDiscoveryListener(DeviceDiscoveryCallback deviceDiscoveryCallback)
void removeDeviceDiscoveryListener(long deviceDiscoveryListener)
Device  
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. ItemType

Specifies the item type.

enum ItemType {
  "AUDIO",
  "FOLDER",
  "IMAGE",
  "UNKNOWN",
  "VIDEO"
};

The following values are supported

  • FOLDER : Folder type
  • AUDIO : Audio type
  • VIDEO : Video type
  • IMAGE : Image type
  • UNKNOWN : Unknown media type

1.2. ServiceState

Specifies the ASF service state.

  enum ServiceState {
      "DISABLED",
      "ENABLED",
      "UNKNOWN"
  };

The following values are supported

  • DISABLED : Disabled
  • ENABLED : Enabled
  • UNKNOWN : Unknown

1.3. DeviceType

Specifies the ASF service state.

enum DeviceType {
  "MEDIAPROVIDER",
  "UNKNOWN"
};

The following values are supported

  • MEDIAPROVIDER : Media provider
  • UNKNOWN : Unknown device type

1.4. DeviceDomain

Specifies the network domain in which the device is located.

enum DeviceDomain { 
  "LOCAL_NETWORK",
  "UNKNOWN" 
};

The following values are supported

  • LOCAL_NETWORK : Located in a local network area
  • UNKNOWN : Located in an unknown area

1.5. DeviceId

Device identifier

typedef DOMString DeviceId;

1.6. DeviceArray

Array of devices

typedef sequence<Device> DeviceArray;

1.7. IconArray

Array of icons

typedef sequence<Icon> IconArray;

1.8. ItemList

Array of items provided by a device on the network

typedef sequence<Item> ItemList;

2. Interfaces

2.1. Item

Constructs an object that represents a media item or folder.

[Constructor(DOMString uri, optional DOMString mimeType, optional DOMString title)]
interface Item {
  readonly attribute DOMString albumTitle;
  readonly attribute DOMString artist;
  readonly attribute Date date;
  readonly attribute unsigned long long duration;
  readonly attribute DOMString extension;
  readonly attribute double fileSize;
  readonly attribute DOMString genre;
  readonly attribute DOMString mimeType;
  readonly attribute unsigned long? width;
  readonly attribute unsigned long? height;
  attribute DOMString? subtitleUri;
  readonly attribute DOMString? thumbnailUri;
  attribute DOMString title;
  readonly attribute ItemType itemType;
  readonly attribute DOMString itemUri;
  readonly attribute boolean isRootFolder;
  readonly attribute ItemContentBuildType contentBuildType;
};

Constructors

Item(DOMString uri, optional DOMString mimeType, optional DOMString title)

Parameters:

  • uri: Item path
  • mimeType [optional]: Item MIME type
  • title [optional]: Item title

Attributes

  • readonly DOMString albumTitle
    Album title
  • readonly DOMString artist
    Artist name
  • readonly Date date
    Date
  • readonly unsigned long long duration
    Duration
  • readonly DOMString extension
    File extension
  • readonly double fileSize
    File size
  • readonly DOMString genre
    Genre
  • readonly DOMString mimeType
    MIME type
  • readonly long width
    Width
  • readonly long height
    Height
  • DOMString subtitleUri
    Subtitle URI
  • readonly DOMString thumbnailUri
    Thumbnail image URI
  • DOMString title
    Title
  • readonly ItemType itemType
    Item type
  • readonly DOMString itemUri
    Item URI
  • readonly boolean isRootFolder
    Whether the item is a root folder
  • readonly ItemContentBuildType contentBuildType
    Content build type

2.2. WebApiAllShareObject

Defines an AllShare object instance.

[NoInterfaceObject] interface WebApiAllShareObject {
  readonly attribute AllShare allshare;
};

  WebApi implements WebApiAllShareObject;

Attributes

  • readonly AllShare allshare
    Provides interfaces for acquiring AllShare devices and connecting to them.

2.3. AllShare

AllShare root API

[NoInterfaceObject] interface AllShare {
};

2.4. ServiceConnectorObject

Defines a WebApi object instance.

[NoInterfaceObject] interface ServiceConnectorObject {
  readonly attribute ServiceConnector serviceconnector;
};

AllShare implements ServiceConnectorObject;

Attributes

  • readonly ServiceConnector serviceconnector
    Provides interfaces for connecting to the ASF service.

2.5. ServiceProviderCreateSuccessCallback

Defines the callback invoked when a ServiceProvider object is created successfully.

[Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderCreateSuccessCallback {
  void onsuccess(ServiceProvider serviceProvider);
};

Methods

onsuccess
Callback method invoked when a ServiceProvider object is successfully created.

void onsuccess(ServiceProvider serviceProvider);

Parameters:

  • serviceProvider: Created ServiceProvider object

2.6. ServiceProviderErrorCallback

Defines the callback invoked if a ServiceProvider object operation fails.

[Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderErrorCallback {
  void onerror(WebAPIError error, ServiceState state);
};

Privilege level: Public

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

Methods

onerror
Callback method invoked if a ServiceProvider operation fails.

void onerror(WebAPIError error, ServiceState state);

Parameters:

  • error: Object indicating the error type and message
  • state: Current service state

2.7. ServiceConnector

Provides the connection to the AllShare Framework(ASF) service.

[NoInterfaceObject] interface ServiceConnector {
  void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback, optional ServiceProviderErrorCallback? errorCallback);
  void deleteServiceProvider(SuccessCallback successCallback, optional ServiceProviderErrorCallback? errorCallback);
  ServiceProvider getServiceProvider();
};

Methods

createServiceProvider
Creates a ServiceProvider object.

void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback, optional ServiceProviderErrorCallback? errorCallback);

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • successCallback: Callback method to invoke if the request is successful
  • errorCallback [optional]: Callback method to invoke if the request fails

Exceptions:

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

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

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

Code example:


// Define the ServiceProvider creation success callback
function sProviderCallback(provider) {
  console.log("The service provider was obtained");
}

// Define the ServiceProvider creation error callback
function eProviderCallback(error, state) {
  console.log(error.name);
  console.log("Current ASF service state: " + state);
}

// Try to create the ServiceProvider object
try {
  webapis.allshare.serviceconnector.createServiceProvider(sProviderCallback, eProviderCallback);
}
catch(e) {
  console.log(e.message);
}
deleteServiceProvider
Deletes a ServiceProvider object.

void deleteServiceProvider(SuccessCallback successCallback, optional ServiceProviderErrorCallback? errorCallback);

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • successCallback: Callback method to invoke if the request is successful
  • errorCallback [optional]: Callback method to invoke if the request fails

Exceptions:

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

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


// You must already have a ServiceProvider object
var serviceProvider;

// Define the ServiceProvider deletion success callback
function sProviderDeleteCallback() {
  console.log("The ASF service provider has been deleted properly.");
}

// Define the ServiceProvider deletion error callback
function eProviderDeleteCallback(error, state) {
  console.log(error.name);
  console.log("The current ASF service state: " + state);
}

// Try to delete the ServiceProvider object
try {
  webapis.allshare.serviceconnector.deleteServiceProvider(sProviderDeleteCallback, eProviderDeleteCallback);
}
catch(e) {
  console.log(e.message);
}
getServiceProvider
Returns a ServiceProvider object that is connected to AllShare framework

ServiceProvider getServiceProvider();

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Return value:

ServiceProvider ServiceProvider object connected to the AllShare Framework

Exceptions:

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

    • with error type UnknownError, for any other error.

Code example:


try {
  // You must already have a ServiceProvider object
  var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();
  if (serviceProvider == null) {
    console.log("Service provider was not created properly");
  }
}
catch(e) {
  console.log(e.message);
}

2.8. ServiceProvider

Provides methods for obtaining a DeviceFinder object.

[NoInterfaceObject] interface ServiceProvider {
  DeviceFinder getDeviceFinder();
  ServiceState getServiceState();
};

Methods

getDeviceFinder
Returns the DeviceFinder object used to find AllShare devices.

DeviceFinder getDeviceFinder();

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Return value:

DeviceFinder DeviceFinder object

Exceptions:

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

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider  = webapis.allshare.serviceconnector.getServiceProvider();
try {
  deviceFinder = serviceProvider.getDeviceFinder();
} catch(e) {
  console.log(e.name);
}
getServiceState
Retrieves the current ASF service state.

ServiceState getServiceState();

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Return value:

ServiceState ServiceState value

Exceptions:

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

    • with error type UnknownError, for any other error.

Code example:


// You must already have a ServiceProvider object
var serviceProvider;

try {
  serviceState = serviceProvider.getServiceState();
} catch(e) {
  console.log(e.name);
}

2.9. DeviceDiscoveryCallback

Defines a generic callback for device discovery event notifications.

[Callback, NoInterfaceObject] interface DeviceDiscoveryCallback {
  void ondeviceadded(Device device);
  void ondeviceremoved(Device device);
};

Methods

ondeviceadded
Callback method invoked when a new device appears on the network.

void ondeviceadded(Device device);

Privilege level: Public

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

Parameters:

  • device: Newly-discovered device

Exceptions:

  • WebAPIException
    • with error type TypeMismatchError, if an 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 input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();

var monitoringCB = {
  ondeviceadded : function (device) { console.log("new device has appeared :" + device.name); },
  ondeviceremoved : function (device) { console.log("a device has disappeared :" + device.name); }
}

try {
  var listenerId = serviceProvider.getDeviceFinder().addDeviceDiscoveryListener(monitoringCB);
} catch(e) {
  console.log(e.name);
}
ondeviceremoved
Callback method invoked when a device disappears from the network.

void ondeviceremoved(Device device);

Privilege level: Public

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

Parameters:

  • device: Device that has disappeared

Exceptions:

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

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();

var monitoringCB = {
  ondeviceadded : function (device) { console.log("new device has appeared :" + device.name); },
  ondeviceremoved : function (device) { console.log("a device has disappeared :" + device.name); }
}

try {
  var listenerId = serviceProvider.getDeviceFinder().addDeviceDiscoveryListener(monitoringCB);
} catch(e) {
  console.log(e.name);
}

2.10. Icon

Defines icon information.

[NoInterfaceObject] interface Icon {
  readonly attribute long depth;
  readonly attribute long height;
  readonly attribute long width;
  readonly attribute DOMString mimeType;
  readonly attribute DOMString iconUri;
};

Attributes

  • readonly long depth
    Icon color depth, in bits per pixel

    Privilege level: Public

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

  • readonly long height
    Icon height

    Privilege level: Public

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

  • readonly long width
    Icon width

    Privilege level: Public

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

  • readonly DOMString mimeType
    Icon MIME type

    Privilege level: Public

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

  • readonly DOMString iconUri
    Icon URI

    Privilege level: Public

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

2.11. DeviceFinder

Provides methods for finding AllShare devices.

[NoInterfaceObject] interface DeviceFinder {
  Device getDevice(DeviceType deviceType, DeviceId id);
  DeviceArray getDeviceList(DeviceType deviceType);
  void refresh();
  long addDeviceDiscoveryListener(DeviceDiscoveryCallback deviceDiscoveryCallback);
  void removeDeviceDiscoveryListener(long deviceDiscoveryListener);
};

Methods

getDevice
Returns a Device object with a specific device ID and type.

Device getDevice(DeviceType deviceType, DeviceId id);

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • deviceType: Device type
  • id: Device ID

Return value:

Device Device object

Exceptions:

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

    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();
var mediaProviderId;  // The MEDIAPROVIDER's device ID is assumed to be known

try {
  var deviceFinder = serviceProvider.getDeviceFinder();
  // Get the MediaProvider device object
  var device = deviceFinder.getDevice("MEDIAPROVIDER", mediaProviderId);
  
  // Print the device ID
  console.log(device.id);
} catch(e) {
  console.log(e.name);
}
getDeviceList
Lists the discovered devices with a specific device type.

DeviceArray getDeviceList(DeviceType deviceType);

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • deviceType: Device type

Return value:

DeviceArray Device array

Exceptions:

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

    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider().

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

  // Print the number of available MediaProvider devices
  console.log(devices.length);
} catch(e) {
  console.log(e.name);
}
refresh
Refreshes the list of devices on the network.

void refresh();

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Exceptions:

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

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();

try {
  var deviceFinder = serviceProvider.getDeviceFinder();
  var providers = deviceFinder.getDeviceList("MEDIAPROVIDER");
  if (providers.length == 0) {
    // Refresh the device list and retrieve the provider list again
    deviceFinder.refresh();
    providers = deviceFinder.getDeviceList("MEDIAPROVIDER");
  }
} catch(e) {
  console.log(e.name);
}
addDeviceDiscoveryListener
Registers a device discovery event listener.

long addDeviceDiscoveryListener(DeviceDiscoveryCallback deviceDiscoveryCallback);

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • deviceDiscoveryCallback: Callback method invoked when a device discovery event occurs.

Return value:

long Event listener ID

Exceptions:

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

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();

var monitoringCB = {
  ondeviceadded : function (device) { console.log("new device has appeared :" + device.name); },
  ondeviceremoved : function (device) { console.log("a device has disappeared :" + device.name); }
}

try {
  var listenerId = serviceProvider.getDeviceFinder().addDeviceDiscoveryListener(monitoringCB);
} catch(e) {
  console.log(e.name);
}
removeDeviceDiscoveryListener
Unregisters a device discovery event listener.

void removeDeviceDiscoveryListener(long deviceDiscoveryListener);

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • deviceDiscoveryListener: Event listener ID

Exceptions:

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

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();
var listenerId; // Listener ID returned from addDeviceDiscoveryListener
var monitoringCB = {
  ondeviceadded : function (device) { console.log("new device has appeared :" + device.name); },
  ondeviceremoved : function (device) { console.log("a device has disappeared :" + device.name); }
}

try {
  var listenerId = serviceProvider.getDeviceFinder().addDeviceDiscoveryListener(monitoringCB);
  serviceProvider.getDeviceFinder().removeDeviceDiscoveryListener(listenerId);
} catch(e) {
  console.log(e.name);
}

2.12. Device

Retrieves information about a device.

[NoInterfaceObject] interface Device {
  readonly attribute DeviceId id;
  readonly attribute DeviceDomain deviceDomain;
  readonly attribute DeviceType deviceType;
  readonly attribute IconArray iconArray;
  readonly attribute DOMString ipAddress;
  readonly attribute DOMString? modelName;
  readonly attribute DOMString name;
  readonly attribute DOMString nic;
};

Privilege level: Public

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

Attributes

  • readonly DeviceId id
    Unique device ID

    Privilege level: Public

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

  • readonly DeviceDomain deviceDomain
    Device domain

    Privilege level: Public

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

  • readonly DeviceType deviceType
    Device type

    Privilege level: Public

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

  • readonly IconArray iconArray
    Device icons

    Privilege level: Public

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

  • readonly DOMString ipAddress
    Device IPv4 address

    Privilege level: Public

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

  • readonly DOMString modelName
    Device model name

    Privilege level: Public

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

  • readonly DOMString name
    Device name

    Privilege level: Public

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

  • readonly DOMString nic
    Device NIC (Network Interface Controller) name

    Privilege level: Public

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

2.13. MediaProviderSuccessCallback

Defines the callback invoked when a provider object completes a retrieval operation successfully.

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

Privilege level: Public

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

Methods

onerror
Callback method for a successful retrieval request.

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

Privilege level: Public

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

Parameters:

  • itemList: Item list. If there are no items, an empty list is returned.
  • endOfItems: End of items flag
  • providerId: Provider device identifier

2.14. MediaProviderErrorCallback

Defines a generic error callback for provider-related operations.

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

Privilege level: Public

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

Methods

onsuccess
Callback method for a successful retrieval request.

void onerror(WebAPIError error, DeviceId providerId);

Privilege level: Public

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

Parameters:

  • error: Object indicating the error type and message
  • providerId: Provider device identifier

2.14. MediaProvider

Enables 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);
  void search(DOMString keyword, unsigned long startIndex, unsigned long requestCount, MediaProviderSuccessCallback successCallback, optional MediaProviderErrorCallback? errorCallback, optional AbstractFilter? searchFilter);
};

Privilege level: Public

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

Attributes

  • readonly boolean isSearchable
    Whether the provider supports the search capability

    Privilege level: Public

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

  • readonly Item rootFolder
    Root folder object

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

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • folderItem: Folder
  • startIndex: Starting zero-based offset
  • requestCount: Requested number of entries
  • browseCallback: 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]: Browse filter to be applied. Parameters can include AttributeFilter objects constructed with ("itemType", null , ItemType[]).
  • sortMode [optional]: Sorting to use on the content list. Sorting by title, date, artist, or albumTitle attribute is only supported on the Tizen Web platform. Other Web platforms ignore this parameter.
  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider  = webapis.allshare.serviceconnector.getServiceProvider();

// Define a browse callback
function browseCB(list, endOfItem, providerId) {
  // Retrieve the item list
}

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

// Define a filter to browse videos 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 the 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 for a specific keyword.

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

Since : 2.3

Product : TV, AV_BD

Privilege level: Public

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

Parameters:

  • keyword: Search keyword
  • startIndex: Starting zero-based offset
  • requestCount: Requested number of entries
  • successCallback: 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
  • searchFilter [optional]: Filter applied to the search result. Parameters can include AttributeFilter objects constructed with ("itemType", null , ItemType[]).
  • sortMode [optional]: Sorting to use on the content list. Sorting by title, date, artist, or albumTitle attribute is only supported on the Tizen Web platform. Other Web platforms ignore this parameter.
  • WebAPIException
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.

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

    • with error type InvalidValuesError, if any input parameter contains an invalid value.

    • with error type UnknownError, for any other error.

Code example:


var serviceProvider = webapis.allshare.serviceconnector.getServiceProvider();
var keyword = "foo";

// Define a browse callback
function searchCB(list, endOfItem, providerId){
  // Retrieve the item list
}

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

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

try {
  var providers = serviceProvider.getDeviceFinder().getDeviceList("MEDIAPROVIDER");
  if (providers.length > 0) {
    // Search for the keyword in the first DMS
    providers[0].search(keyword, 0, 40, searchCB, errorCB, filter);
  }
} catch(e) {
  console.log(e.message);
}

3. Full WebIDL


module ASFService {
  enum ItemType {
    "AUDIO",
    "FOLDER",
    "IMAGE",
    "UNKNOWN",
    "VIDEO"
  };

  enum ServiceState {
    "DISABLED",
    "ENABLED",
    "UNKNOWN"
  };

  enum DeviceType {
    "MEDIAPROVIDER",
    "UNKNOWN" 
  };

  enum DeviceDomain { 
    "LOCAL_NETWORK",
    "UNKNOWN" 
  };

  typedef DOMString DeviceId;

  typedef sequence DeviceArray;

  typedef sequence IconArray;

  typedef sequence ItemList;

  [Constructor(DOMString uri, optional DOMString mimeType, optional DOMString title)]
  interface Item {
    readonly attribute DOMString albumTitle;
    readonly attribute DOMString artist;
    readonly attribute Date date;
    readonly attribute unsigned long long duration;
    readonly attribute DOMString extension;
    readonly attribute double fileSize;
    readonly attribute DOMString genre;
    readonly attribute DOMString mimeType;
    readonly attribute unsigned long? width;
    readonly attribute unsigned long? height;
    attribute DOMString? subtitleUri;
    readonly attribute DOMString? thumbnailUri;
    attribute DOMString title;
    readonly attribute ItemType itemType;
    readonly attribute DOMString itemUri;
    readonly attribute boolean isRootFolder;
    readonly attribute ItemContentBuildType contentBuildType;
  };

  [NoInterfaceObject] interface WebApiAllShareObject {
    readonly attribute AllShare allshare;
  };
  
  WebApi implements WebApiAllShareObject;

  [NoInterfaceObject] interface AllShare {
  };

  [NoInterfaceObject] interface ServiceConnectorObject {
    readonly attribute ServiceConnector serviceconnector;
  };

  AllShare implements ServiceConnectorObject;

  [Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderCreateSuccessCallback {
    void onsuccess(ServiceProvider serviceProvider);
  };

  [Callback=FunctionOnly, NoInterfaceObject] interface ServiceProviderErrorCallback {
    void onerror(WebAPIError error, ServiceState state);
  };

  [NoInterfaceObject] interface ServiceConnector {
    void createServiceProvider(ServiceProviderCreateSuccessCallback successCallback, optional ServiceProviderErrorCallback? errorCallback);
    void deleteServiceProvider(SuccessCallback successCallback, optional ServiceProviderErrorCallback? errorCallback);
    ServiceProvider getServiceProvider();
  };

  [NoInterfaceObject] interface ServiceProvider {
    DeviceFinder getDeviceFinder();
    ServiceState getServiceState();
  };

  [Callback, NoInterfaceObject] interface DeviceDiscoveryCallback {
    void ondeviceadded(Device device);
    void ondeviceremoved(Device device);
  };

  [NoInterfaceObject] interface Icon {
    readonly attribute long depth;
    readonly attribute long height;
    readonly attribute long width;
    readonly attribute DOMString mimeType;
    readonly attribute DOMString iconUri;
  };

  [NoInterfaceObject] interface DeviceFinder {
    Device getDevice(DeviceType deviceType, DeviceId id);
    DeviceArray getDeviceList(DeviceType deviceType);
    void refresh();
    long addDeviceDiscoveryListener(DeviceDiscoveryCallback deviceDiscoveryCallback);
    void removeDeviceDiscoveryListener(long deviceDiscoveryListener);
  };

  [NoInterfaceObject] interface Device {
    readonly attribute DeviceId id;
    readonly attribute DeviceDomain deviceDomain;
    readonly attribute DeviceType deviceType;
    readonly attribute IconArray iconArray;
    readonly attribute DOMString ipAddress;
    readonly attribute DOMString? modelName;
    readonly attribute DOMString name;
    readonly attribute DOMString nic;
  };

  [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);
    void search(DOMString keyword, unsigned long startIndex, unsigned long requestCount, MediaProviderSuccessCallback successCallback, optional MediaProviderErrorCallback? errorCallback, optional AbstractFilter? searchFilter);
  };
};