© 2013 Samsung Electronics Co., Ltd. All rights reserved.
This API allows developers to control the view available on a Samsung Smart TV in detail. This feature provides expanded control of Digital Media Renderer (DMR) for images.
It can control Samsung Smart TVs manufactured since 2012.
Interface | Method |
---|---|
ViewControllerSuccessCallback | void onsuccess(DeviceId imageViewerId) |
ViewControllerErrorCallback | void onerror(WebAPIError error, DeviceId imageViewerId) |
ViewControllerEventCallback | void ondisconnected(DeviceId imageViewerId) |
ViewController | void connect(ViewControllerSuccessCallback successCallback, ViewControllerErrorCallback? errorCallback) void disconnect(ViewControllerSuccessCallback successCallback, ViewControllerErrorCallback? errorCallback) void move(unsigned long cx, unsigned long cy, boolean isReleased, ViewControllerSuccessCallback successCallback, ViewControllerErrorCallback? errorCallback) void setViewAngle(ViewAngle angle, ViewControllerSuccessCallback successCallback, ViewControllerErrorCallback? errorCallback) void zoom(unsigned long cx, unsigned long cy, unsigned long zoomPercent, ViewAngle angle, unsigned long sourceWidth, unsigned long sourceHeight) long addViewControllerEventListener(ViewControllerEventCallback eventCallback) void removeViewControllerEventListener(long eventListenerId) |
Specifies the value for the angle of the view.
enum ViewAngle { "0", "90", "180", "270" };
Generic success callback for viewcontroller related operations.
[Callback=FunctionOnly, NoInterfaceObject] interface ViewControllerSuccessCallback { void onsuccess(DeviceId imageViewerId); };
onsuccess
Callback function invoked when operation is completed successfully.
void onsuccess(DeviceId imageViewerId);
Generic success callback for viewcontroller related operations.
[Callback=FunctionOnly, NoInterfaceObject] interface ViewControllerErrorCallback { void onerror(WebAPIError error, DeviceId imageViewerId); };
onerror
Callback function invoked when error occurs.
void onerror(WebAPIError error, DeviceId imageViewerId);
Callback interface that notifies the application when the ViewController event is received.
[Callback, NoInterfaceObject] interface ViewControllerEventCallback { void ondisconnected(DeviceId imageViewerId); };
ondisconnected
Callback function invoked when the device is disconnected.
void ondisconnected(DeviceId imageViewerId);
This interface provides a means of controlling the view.
[NoInterfaceObject] interface ViewController { readonly attribute DeviceId id; readonly attribute boolean isConnected; readonly attribute unsigned long viewHeight; readonly attribute unsigned long viewWidth; void connect(ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void disconnect(ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void move(unsigned long cx, unsigned long cy, boolean isReleased, ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void setViewAngle(ViewAngle angle, ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void zoom(unsigned long cx, unsigned long cy, unsigned long zoomPercent, ViewAngle angle, unsigned long sourceWidth, unsigned long sourceHeight); long addViewControllerEventListener(ViewControllerEventCallback eventCallback); void removeViewControllerEventListener(long eventListenerId); };
After getting the object of ImageViewer, the developer can request the object of ViewController.
var serviceProvider; // it is assumed that you obtained serviceProvider. For further details, see the creatServiceProvider(..). var deviceId; // it is assumed that an ImageViewer's device ID has already been determined try { var imageViewer = serviceProvider.getDeviceFinder().getDevice("IMAGEVIEWER", deviceId); var viewController = imageViewer.getViewController(); if (viewController != null) { // Developer can control view controller } } catch (e) { console.log(e.name); }
readonly
DeviceId id
Specifies the unique ID of the receiver.
It will be the same ID of an imageviewer device which provides this view controller.
readonly
boolean isConnected
Flag indicates whether the connection is established or not.
readonly
unsigned long viewHeight
Height of the view.
readonly
unsigned long viewWidth
Width of the view.
connect
Establish a connection to Smart TV.
void connect(ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback);
The error callback is launched with these error types:
with error type NotSupportedError, if this feature is not supported.
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 viewController; // it is assumed that a proper view controller object is stored; //Define a success callback. function viewControllerSCB(controllerId) { console.log("connection has been made properly."); } //Define an error callback function viewControllerECB(error, controllerId){ console.log(error.message); } try { viewController.connect(viewControllerSCB, viewControllerECB); } catch (e) { console.log(e.name); }
disconnect
Break off the connection to the Smart TV.
void disconnect(ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback);
The error callback is launched with these error types:
with error type NotSupportedError, if this feature is not supported.
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 viewController; // it is assumed that a proper view controller object which has connected //Define a success callback. function viewControllerSCB(controllerId) { console.log("connection has been made properly."); } //Define an error callback function viewControllerECB(error, controllerId) { console.log(error.message); } try { viewController.disconnect(viewControllerSCB, viewControllerECB); } catch (e) { console.log(e.name); }
move
Move the center of the view
void move(unsigned long cx, unsigned long cy, boolean isReleased, ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback);
The error callback is launched with these error types:
with error type NotSupportedError, if this feature is not supported.
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 viewController; // it is assumed that a proper view controller object which has connected //Define a success callback. function viewControllerSCB(controller) { console.log("connection has been made properly."); } //Define an error callback function viewControllerECB(error, controller) { console.log(error.message); } try { if (viewController.isConnected) { viewController.move(18, 18, true, viewControllerSCB, viewControllerECB); } } catch (e) { console.log(e.name); }
setViewAngle
Set the view angle.
void setViewAngle(ViewAngle angle, ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback);
The error callback is launched with these error types:
with error type NotSupportedError, if this feature is not supported.
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 viewController; // it is assumed that a proper view controller object which has connected; //Define a success callback. function viewControllerSCB(controller) { console.log("connection has been made properly."); } //Define an error callback function viewControllerECB(error, controller) { console.log(error.message); } try { if (viewController.isConnected) { viewController.setViewAngle("90", viewControllerSCB, viewControllerECB); } } catch (e) { console.log(e.name); }
zoom
Zoom the view in or out.
void zoom(unsigned long cx, unsigned long cy, unsigned long zoomPercent, ViewAngle angle, unsigned long sourceWidth, unsigned long sourceHeight);
Although zoom rate of original image has been changed in TV, if the angle of the view of the mobile device is changed, the view of the TV is shown in 100 percent size.
with error type NotSupportedError, if this feature is not supported.
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 viewController; // it is assumed that a proper view controller object which has connected. var zoomRatio = 100; var originalWidth, originalHeight; // assumed to be the original size of the stored image. //Define a success callback. function viewControllerSCB(controller) { console.log("connection has been made properly."); } //Define an error callback function viewControllerECB(error, controller) { console.log(error.message); } try { if (viewController.isConnected) { viewController.zoom(8, 8, zoomRatio * 1, "180", orginalWidth, orginalHeight); } } catch (e) { console.log(e.name); }
addViewControllerEventListener
Set the view controller event listener.
long addViewControllerEventListener(ViewControllerEventCallback eventCallback);
with error type UnknownError, In the case of any other error
with error type NotSupportedError, if this feature is not supported.
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 eventListener = { ondisconnected(viewController) {console.log("disconnected."); } }; try { if (viewController.isConnected) { var handle = viewController.addViewControllerEventListener(eventListener); } } catch (e) { console.log(e.name); }
removeViewControllerEventListener
Remove the event listener.
void removeViewControllerEventListener(long eventListenerId);
with error type UnknownError, any other error case.
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if this functionality is not allowed.
with error type InvalidValuesError, if any input parameter contains invalid values.
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
var eventHandle; // it is assumed that an event handle which is registered. try { if (viewController.isConnected) { viewController.removeViewControllerEventListener(eventHandle); } } catch (e) { console.log(e.name); }
module ViewController { enum ViewAngle { "0", "90", "180", "270" }; [Callback=FunctionOnly, NoInterfaceObject] interface ViewControllerSuccessCallback { void onsuccess(DeviceId imageViewerId); }; [Callback=FunctionOnly, NoInterfaceObject] interface ViewControllerErrorCallback { void onerror(WebAPIError error, DeviceId imageViewerId); }; [Callback, NoInterfaceObject] interface ViewControllerEventCallback { void ondisconnected(DeviceId imageViewerId); }; [NoInterfaceObject] interface ViewController { readonly attribute DeviceId id; readonly attribute boolean isConnected; readonly attribute unsigned long viewHeight; readonly attribute unsigned long viewWidth; void connect(ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void disconnect(ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void move(unsigned long cx, unsigned long cy, boolean isReleased, ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void setViewAngle(ViewAngle angle, ViewControllerSuccessCallback successCallback, optional ViewControllerErrorCallback? errorCallback); void zoom(unsigned long cx, unsigned long cy, unsigned long zoomPercent, ViewAngle angle, unsigned long sourceWidth, unsigned long sourceHeight); long addViewControllerEventListener(ViewControllerEventCallback eventCallback); void removeViewControllerEventListener(long eventListenerId); }; };