© 2013 Samsung Electronics Co., Ltd. All rights reserved.
This API allows developers to get a list of discovered AllShare devices with a specified ID, domain and NIC. It also includes provisions for obtaining device discovery update notification.
Interface | Method |
---|---|
DeviceDiscoveryCallback | void ondeviceadded(Device device) void ondeviceremoved(Device device) |
Icon | |
DeviceFinder | Device? getDevice(DeviceType deviceType, DeviceId id, SubFeatureType? subFeatureType) DeviceArray getDeviceList(DeviceType deviceType) DeviceArray getDeviceListByDomain(DeviceType deviceType, DeviceDomain domain) DeviceArray getDeviceListByNIC(DeviceType deviceType, DOMString nic) void refresh() long addDeviceDiscoveryListener(DeviceDiscoveryCallback deviceDiscoveryCallback) void removeDeviceDiscoveryListener(long deviceDiscoveryListener) |
Device |
The device identifier
typedef DOMString DeviceId;
Specifies the device type which can be discovered.
enum DeviceType { "AVPLAYER", "IMAGEVIEWER", "FILERECEIVER", "MEDIAPROVIDER", "TVCONTROLLER", "UNKNOWN" };
Specifies the sub feature type for a specific device type.
enum SubFeatureType {"VIEWCONTROLLER"};
Specifies the network domain in which the device is located.
enum DeviceDomain { "LOCAL_NETWORK", "MY_DEVICE", "REMOTE_NETWORK", "UNKNOWN" };
Provides a generic callback for notification about device discovery events
[Callback, NoInterfaceObject] interface DeviceDiscoveryCallback { void ondeviceadded(DeviceDevice device); void ondeviceremoved(DeviceDevice device); };
ondeviceadded
Invoked when a new device has appeared in the network.
void ondeviceadded(Device device);
ondeviceremoved
Invoked when a device is going to disappear from the network
void ondeviceremoved(Device device);
Represents the 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; };
readonly
long depth
Color depth of the icon in bits per pixel.
readonly
long height
Height of the icon
readonly
long width
Width of the icon
readonly
DOMString mimeType
MIME type of the icon
readonly
DOMString iconUri
Uri of the icon
Provides methods for finding AllShare devices.
[NoInterfaceObject] interface DeviceFinder { DeviceDevice? getDevice(DeviceType deviceType, DeviceId id, optional SubFeatureType? subFeatureType); DeviceArrayDeviceArray getDeviceList(DeviceType deviceType); DeviceArrayDeviceArray getDeviceListByDomain(DeviceType deviceType, DeviceDomain domain); DeviceArrayDeviceArray getDeviceListByNIC(DeviceType deviceType, DOMString nic); void refresh(); long addDeviceDiscoveryListener(DeviceDiscoveryCallback deviceDiscoveryCallback); void removeDeviceDiscoveryListener(long deviceDiscoveryListener); };
getDevice
Provides a device with a specified device ID and device type.
Device? getDevice(DeviceType deviceType, DeviceId id, optional SubFeatureType? subFeatureType);
In case of retrieving sub features such as MediaReceiver or ViewController, the device ID with the device type such MediaProvider or ImageViewer and the proper SubFeatureType will be used.
If no device has been discovered, then null will be returned.
with error type "UnknownError", In any other error case.
with error type "SecurityError", if this functionality is not allowed.
with error type "InvalidValuesError", if the deviceType value does NOT have a subFeatureType value.
with error type "TypeMismatchError", if any input parameter is not compatible with the expected type for that parameter.
var serviceProvider; // it is assumed that you obtained serviceProvider. For further details, see the creatServiceProvider(..). var deviceId; // it is assumed that an avplayer's device ID has already been determined var imageViewerId; // it is assumed that an imageviewer's device ID has already been determined try { var deviceFinder = serviceProvider.getDeviceFinder(); // get AV player device object var device = deviceFinder.getDevice("AVPLAYER", deviceId); // get view controller object with Image Viewer device Id. var viewControllerObj = deviceFinder.getDevice("IMAGEVIEWER", imageViewerId, "VIEWCONTROLLER"); // Print out the device's ID console.log(device.id); } catch(e) { console.log(e.name); }
getDeviceList
Provides a list of discovered devices with specified device types.
DeviceArray getDeviceList(DeviceType deviceType);
If no devices of given device type have been discovered, then the empty list will be returned.
with error type "UnknownError", In any other error case.
with error type "SecurityError", if this functionality is not allowed.
with error type "TypeMismatchError", if any input parameter is not compatible with the expected type for that parameter.
var serviceProvider; // it is assumed that you obtained serviceProvider. For further details, see the createServiceProvider() or getServiceProvider(). try { var deviceFinder = serviceProvider.getDeviceFinder(); var devices = deviceFinder.getDevices("AVPLAYER"); // Print out how many AV player devices are available console.log(devices.length); } catch(e) { console.log(e.name); }
getDeviceListByDomain
Provides a list of discovered devices with specified device type within specified network domain.
DeviceArray getDeviceListByDomain(DeviceType deviceType, DeviceDomain domain);
If no devices of given device type and given domain have been discovered, then an empty list will be returned.
with error type "UnknownError", In any other error case.
with error type "SecurityError", if this functionality is not allowed.
with error type "TypeMismatchError", if any input parameter is not compatible with the expected type for that parameter.
var serviceProvider; // it is assumed that you have obtained a serviceProvider object. For further details, see createServiceProvider() or getServiceProvider(). try { var deviceFinder = serviceProvider.getDeviceFinder(); var devices = deviceFinder.getDevicesByDomain("AVPLAYER", "LOCAL_NETWORK"); // Display the number of available AV player devices on local network console.log(devices.length); } catch(e) { console.log(e.name); }
getDeviceListByNIC
Provides a list of discovered devices with specified types within specified network interface controllers (NICs).
DeviceArray getDeviceListByNIC(DeviceType deviceType, DOMString nic);
If no devices of given device type and given NIC have been discovered, then an empty list will be returned.
with error type "UnknownError", In any other error case.
with error type "SecurityError", if this functionality is not allowed.
with error type "TypeMismatchError", if any input parameter is not compatible with the expected type for that parameter.
var serviceProvider; // it is assumed that you has obtained a serviceProvider object. For further details, see createServiceProvider() or getServiceProvider(). try { var deviceFinder = serviceProvider.getDeviceFinder(); var devices = deviceFinder.getDevicesByNIC("AVPLAYER", "Wireless LAN"); // Display the number of AV player devices available on the wireless LAN console.log(devices.length); } catch(e) { console.log(e.name); }
refresh
Refreshes the list of devices on the network.
void refresh();
with error type "UnknownError", In any other error case.
with error type "SecurityError", if this functionality is not allowed.
var serviceProvider; // it is assumed that you obtained serviceProvider. For further details, see createServiceProvider() or getServiceProvider(). try { var deviceFinder = serviceProvider.getDeviceFinder(); var providers = deviceFinder.getDevices("MEDIAPROVIDER"); if (providers.length == 0) { // Refreshes the device list and retrieves the provider list again. deviceFinder.refresh(); providers = deviceFinder.getDevices("MEDIAPROVIDER"); } } catch(e) { console.log(e.name); }
addDeviceDiscoveryListener
Registers device discovery event listener.
long addDeviceDiscoveryListener(DeviceDiscoveryCallback deviceDiscoveryCallback);
with error type "UnknownError", In any other error case.
with error type "SecurityError", if this functionality is not allowed.
with error type "TypeMismatchError", if any input parameter is not compatible with the expected type for that parameter.
var serviceProvider; // it is assumed that you has obtained a serviceProvider object. For further details, see createServiceProvider() or getServiceProvider(). var monitoringCB = { ondeviceadded : function (device) { console.log("new device is appeared :" + device.name); }, ondeviceremoved : function (device) { console.log("a device is disappeared :" + device.name); } } try { var listenerId = serviceProvider.getDeviceFinder().addDeviceDiscoveryListener(monitoringCB); } catch(e) { console.log(e.name); }
removeDeviceDiscoveryListener
Clears device discovery event listener
void removeDeviceDiscoveryListener(long deviceDiscoveryListener);
with error type "UnknownError", In any other error case.
with error type "InvalidValuesError", if argument is invalid.
with error type "SecurityError", if this functionality is not allowed.
with error type "TypeMismatchError", if any input parameter is not compatible with the expected type for that parameter.
var serviceProvider; // it is assumed that you has obtained a serviceProvider object. For further details, see the createServiceProvider() or getServiceProvider(). var listenerId; // it is assumed that this listener ID was returned from addDeviceDiscoveryListener(). var monitoringCB = { ondeviceadded : function (device) { console.log("new device is appeared :" + device.name); }, ondeviceremoved : function (device) { console.log("a device is disappeared :" + device.name); } } try { var listenerId = serviceProvider.getDeviceFinder().addDeviceDiscoveryListener(monitoringCB); } catch(e) { console.log(e.name); }
Provides the 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; };
For retrieving a device object, see the getDevice(), getDevices(), getDeviceByDomain() or getDeviceByNIC().
readonly
DeviceId id
Specifies the unique ID of the device.
readonly
DeviceDomain deviceDomain
Specifies the device domain
readonly
DeviceType deviceType
Specifies the device type
readonly
IconArray iconArray
Specifies icons associated with the device
readonly
DOMString ipAddress
Specifies the device IPv4 adress
readonly
DOMString? modelName
Specifies the device model name.
readonly
DOMString name
Specifies the device name
readonly
DOMString nic
Specified NIC (Network Interface Controller) name of the device
module DeviceDiscovery { typedef DOMString DeviceId; typedef sequence<DeviceDevice> DeviceArray; typedef sequence<Icon> IconArray; enum DeviceType { "AVPLAYER", "IMAGEVIEWER", "FILERECEIVER", "MEDIAPROVIDER", "TVCONTROLLER", "UNKNOWN" }; enum SubFeatureType {"VIEWCONTROLLER"}; enum DeviceDomain { "LOCAL_NETWORK", "MY_DEVICE", "REMOTE_NETWORK", "UNKNOWN" }; [Callback, NoInterfaceObject] interface DeviceDiscoveryCallback { void ondeviceadded(DeviceDevice device); void ondeviceremoved(DeviceDevice 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 { DeviceDevice? getDevice(DeviceType deviceType, DeviceId id, optional SubFeatureType? subFeatureType); DeviceArrayDeviceArray getDeviceList(DeviceType deviceType); DeviceArrayDeviceArray getDeviceListByDomain(DeviceType deviceType, DeviceDomain domain); DeviceArrayDeviceArray getDeviceListByNIC(DeviceType deviceType, DOMString nic); 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; }; };