CAMERA
This API provides class and methods for control of camera API of TV.
Add the following line for camera class into a html file your own : <script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/deviceapis.js"></script> |
You can declare camera class like this : ex) var camera = deviceapis.camera; |
Contents
Constants
Name | Value | Description |
deviceapis.camera.PL_CAMERA_EVENT_DISCONNECTED | 0 | When a camera device is disconnected |
deviceapis.camera.PL_CAMERA_EVENT_CONNECTING | 1 | When a camera device is plugged in |
deviceapis.camera.PL_CAMERA_EVENT_CONNECTED | 2 | When a camera device driver is loaded completely, and camera is ready |
deviceapis.camera.PL_CAMERA_STATE_DISCONNECTED | 0 | if camera is not connected |
deviceapis.camera.PL_CAMERA_STATE_CONNECTING | 1 | if camera is being loaded |
deviceapis.camera.PL_CAMERA_STATE_READY | 2 | if camera is ready |
deviceapis.camera.PL_CAMERA_STATE_PLAYING | 3 | if camera is running |
deviceapis.camera.PL_CAMERA_QUALITY_LOW | 0 | The quality of video captured by camera - LOW |
deviceapis.camera.PL_CAMERA_QUALITY_MID | 1 | The quality of video captured by camera – MID |
deviceapis.camera.PL_CAMERA_QUALITY_HIGH | 2 | The quality of video captured by camera – HIGH |
deviceapis.camera.PL_CAMERA_RESOLUTION_VGA | 0 | The resolution of the video captured by camera – VGA |
deviceapis.camera.PL_CAMERA_RESOLUTION_HD | 1 | The resolution of the video captured by camera – HD |
Methods
GetCameraState | ||
Description | ||
The GetCameraState() function checks the current camera state. | ||
Parameters | none | |
Return | ■PL_CAMERA_STATE
- camera is not connected : PL_CAMERA_STATE_DISCONNECTED - camera is being loaded : PL_CAMERA_STATE_CONNECTING - camera is ready : PL_CAMERA_STATE_READY - camera is running : PL_CAMERA_STATE_PLAYING | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
var ret = deviceapis.camera.GetCameraState();
switch(ret) { case deviceapis.camera.PL_CAMERA_STATE_DISCONNECTED: alert("Camera is not connected"); break; case deviceapis.camera.PL_CAMERA_STATE_CONNECTING: alert("Camera is connected, but it is not ready"); break; case deviceapis.camera.PL_CAMERA_STATE_READY: alert("Camera is ready"); break; case deviceapis.camera.PL_CAMERA_STATE_PLAYING: alert("Camera already starts"); break; default: break; } |
RegisterEventCallback | ||
Description | ||
The RegisterEventCallback function registers a callback to receive camera related event. When the event arrives, the registered callback function is called with event value. The supported events are as follows, | ||
Parameters | ■rCallback - Callback Function | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
function rCallback(event){ alert("Camera Event[" + event + "]"); switch(event) { case deviceapis.camera.PL_CAMERA_EVENT_DISCONNECTED: alert("Camera is disconnected"); break; case deviceapis.camera.PL_CAMERA_EVENT_CONNECTING: alert("Camera is plugged in and under initialization"); break; case deviceapis.camera.PL_CAMERA_EVENT_CONNECTED: alert("Camera is ready"); break; default: break; } } //register callback deviceapis.camera.RegisterEventCallback(rCallback); |
StartCamVideo | ||
Description | ||
The StartCamVideo function starts to display the video captured by camera. | ||
Parameters | ■positionX - Int - horizontal position of top-left corner of video ■positionY - Int - vertical position of top-left corner of video ■displayW - Int - width of video area ■displayH - Int - height of video area ■resolution - PL_CAMERA_RESOLUTION - deviceapis.camera.PL_CAMERA_RESOLUTION_VGA, deviceapis.camera.PL_CAMERA_RESOLUTION_HD ■quality - PL_CAMERA_QUALITY - deviceapis.camera.PL_CAMERA_QUALITY_LOW, deviceapis.camera.PL_CAMERA_QUALITY_MID, deviceapis.camera.PL_CAMERA_QUALITY_HIGH | |
Return | ■Boolean - true : succeeded - false : failed | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
deviceapis.camera.StartCamVideo(0, 0, 640, 480, deviceapis.camera.PL_CAMERA_RESOLUTION_VGA, deviceapi.camera.PL_CAMERA_QUALITY_HIGH); |
StopCamVideo | ||
Description | ||
The StopCamVideo function stop the camera video. | ||
Parameters | none | |
Return | ■Number - 1 : succeeded 0 : failed | |
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
deviceapis.camera.StopCamVideo(); |
UnregisterEventCallback | ||
Description | ||
The UregisterEventCallback function deregisters the callback function registered by RegisterEventCallback | ||
Parameters | none | |
Return | ■Void | |
Emulator Support | Yes | |
SDK Constraint | None | |
Example | ||
function rCallback(event){ alert("Camera Event[" + event + "]"); switch(event) { case deviceapis.camera.PL_CAMERA_EVENT_DISCONNECTED: alert("Camera is disconnected"); break; case deviceapis.camera.PL_CAMERA_EVENT_CONNECTING: alert("Camera is plugged in and under initialization"); break; case deviceapis.camera.PL_CAMERA_EVENT_CONNECTED: alert("Camera is ready"); break; default: break; } } //register callback deviceapis.camera.RegisterEventCallback(rCallback); // ... //deregister callback deviceapis.camera.UnregisterEventCallback(); |