top

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;


Constants

NameValueDescription
deviceapis.camera.PL_CAMERA_EVENT_DISCONNECTED0When a camera device is disconnected
deviceapis.camera.PL_CAMERA_EVENT_CONNECTING1When a camera device is plugged in
deviceapis.camera.PL_CAMERA_EVENT_CONNECTED2When a camera device driver is loaded completely, and camera is ready
deviceapis.camera.PL_CAMERA_STATE_DISCONNECTED0if camera is not connected
deviceapis.camera.PL_CAMERA_STATE_CONNECTING1if camera is being loaded
deviceapis.camera.PL_CAMERA_STATE_READY2if camera is ready
deviceapis.camera.PL_CAMERA_STATE_PLAYING3if camera is running
deviceapis.camera.PL_CAMERA_QUALITY_LOW0The quality of video captured by camera - LOW
deviceapis.camera.PL_CAMERA_QUALITY_MID1The quality of video captured by camera – MID
deviceapis.camera.PL_CAMERA_QUALITY_HIGH2The quality of video captured by camera – HIGH
deviceapis.camera.PL_CAMERA_RESOLUTION_VGA0The resolution of the video captured by camera – VGA
deviceapis.camera.PL_CAMERA_RESOLUTION_HD1The 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 SupportY
SDK ConstraintNone
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 SupportY
SDK ConstraintNone
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 SupportY
SDK ConstraintNone
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 SupportY
SDK ConstraintNone
Example
deviceapis.camera.StopCamVideo();

UnregisterEventCallback

Description
The UregisterEventCallback function deregisters the callback function registered by RegisterEventCallback
Parameters
none
Return■Void
Emulator SupportYes
SDK ConstraintNone
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();