Camera plugin
From KuneriLite wiki
Contents |
Introduction
KuneriLite Camera plug-in provides an API to use the full potential of device camera in your Flash Lite applications.
KuneriLite Camera supports front and back cameras, auto(instant) mode, video recording, camera flash, three quality settings and thumbnail picture of snapshot.
Interface
loadVariables("http://127.0.0.1:<Port>/<Key>/camera?klCommand=<Command>&<Arguments>, "<TargetMc>" );
| General Parameters | |
| <Port> | Specific port KuneriLite is listening commands from (default 1001) |
| <Key> | Unique key for your KuneriLite license (default Basic) |
| <Command> | Name of the command to be called. |
| <Arguments> | Required arguments for commands. Each command may have different arguments with various parameter values. |
| <TargetMC> | Flash Lite movie clip that will receive the response back. |
Status of a command can be controlled via klError and klEnd variables. klError returns the response message from KuneriLite server application and klEnd value indicates that conversation is finalized and all data is received. For meaning of klError values, please refer to "Error Values" section below
Commands
Prepare
This is an optional command. It prepares the camera resource and checks the presence of camera device. After next picture/video taken camera resource is released.
Returns
Returns 0 to klError if successful, or an error code if there is any problem.
Arguments
klIndex
| Camera identifier (0 is main camera and 1 is front camera) |
Example
loadVariables("http://127.0.0.1:1001/Basic/camera?klCommand=prepare&klIndex=0", "" );
Start
Starts the camera. Camera can be started to
- viewfinder mode User can take the snapshot or start recording with softkey
- instant mode where picture is taken or recording started immediately
Note: After 'start' is successfully returned without an error, use 'status' command to verify that picture was taken and saved successfully into file, before using the file (ex. uploading).
Returns
Returns 0 to klError if successful, or an error code if there is any problem starting camera.
Arguments
klIndex
| Camera identifier (0 is main camera and 1 is front camera) |
klPath
| Path of the target file. File extensions should be jpg for picture and 3gp or mp4 for video clips. If folder of file is not given, file is saved into application installation folder. |
klMode
| Camera function: picture or video |
klSize
| Size and quality setting: full, medium, small or [width]*[height]. |
klInstant
| klInstant=1, enables instant mode. Camera will shoot/video recording will start automatically when camera is initialized. klTime specifies the length(time) for recording. |
klTime
| This is valid only when klInstant=1. Specifies how long (when klInstant=1) video will be recorded, in seconds. After seconds are passed, camera will be closed and Flash Lite application will be activated. |
klFlash
| klFlash=1 enables camera flash (in picture mode). By default Flash is enabled. Flash can be disabled also by pressing Clear (C) key in viewfinder mode. |
About Picture and Video sizes
Size of picture or video record is specified with klSize argument and its effect to quality and file size is:
- klSize=small, smallest size and poorest quality. For pictures, resolution is VGA (640x480) and for videos QCIF (176x144). It produces 25-35kb of filesize for picture and for videos size is around 16kb/sec.
- klSize=medium, good quality/size ratio. For pictures, resolution depends of phone (1024x768 or 800x600) and for videos resolution is CIF (352x288), 15fps. Size of file is around 40-60 kb for pictures and for videos starting from 64kb. If mode is not supported by camera, video rate is dropped and then resolution, until next best supported mode is found.
- klSize=full, best quality/big size of file. For pictures, resolution depends of phone (1536x2048 for instance) and for videos 640*480, 30fps. VGA in video recording is supported in Nokia N95 only, usually 352*288 30fps is used instead. Size of file is around 100-300 kb for pictures and for videos starting from 92kb-160kb. For picture mode this setting is always supported. If resolution is not supported by camera, video speed is dropped and then resolution, until next best supported size is found.
Controlling camera
Left sofkey takes the picture and right softkey cancels. Key up zooms the camera and down unzooms. 'C' (clear) key sets the camera flash on/off.
Examples
loadVariables("http://127.0.0.1:1001/Basic/camera?klCommand=start&
klMode=picture&klPath=\\Data\\Images\\image.jpg&klSize=
640*480&klFlash=0" );
loadVariables("http://127.0.0.1:1001/Basic/camera?klCommand=start&
klMode=video&klPath=\\Data\\Images\\video.3gp&klSize=
full" );
Status
Gets status of camera operation.
Note: this should be always called after 'start' command is success, for to verify that picture was taken and saved successfully into file, before starting using it (resizing, reading or sending).
Returns
Returns 0 to klError if successful, or an error code if there is any problem.
Returns to klStatus :
- exit if user just exits camera without taking picture.
- saving if saving is still ongoing or video is recording.
- complete if picture/video was saved successfully.
Arguments
None.
Example
loadVariables("http://127.0.0.1:1001/Basic/camera?klCommand=status", "" );
Resize
After snapshot, image might require downscaling. Resize command simply resizes JPEG-image given in width*height dimensions.
Note: Use 'status' command to verify that picture was taken and saved successfully into file, before resizing it.
Returns
Returns 0 to klError if successful, or an error code if there is any problem in resizing.
If klTargetFile variable wasn't given, it will be generated and returned back
in form klTargetFile=[klFile][hash] (for example myfilebg8d13.jpg).
Arguments
klPath
| Path to source image |
klTargetFile
| Target image path.
If target file is not given, target file will be random name in form [klFile][hash].jpg, (name will be returned back in klTargetFile variable). |
klSize
| New image dimensions in pixels |
klOverwrite
| Overwrites existing file, on by default. |
Example
loadVariables("http://127.0.0.1:1001/Basic/camera?klCommand=resize& klPath=test.jpg&klSize=200*320&klTargetFile=test_thumb.jpg&klOverwrite=false", "");
Notes
To use (or add your own) camera and video shutter sounds; include shutter.wav and video.wav (use these filenames!) in extra.pkg file under KuneriLite\ folder.
Example of extra.pkg:
"\myproject\shutter.wav"-"!:\private\A0002631\shutter.wav"
"\myproject\video.wav"-"!:\private\A0002631\video.wav"
(targetpaths must not be changed.)
(This works only for free Camera-plugin version, for commercial version
UID (A0002631) should be different)
Extra.pkg is not project specific; after SIS is built, clear the example.pkg, so that other projects are not affected.
Error values
Common error statuses are mentioned below.
| 0 | Success |
| -1 | Plug-in is not found / KuneriLite components are missing |
| -5 | Plug-in name / command or type in URL is not supported / restricted command |
| -6 | Given data is out of range |
| -12 | Given path is not found |
| -14 / -18 | This may happen if Nokia Camera is launched exactly at the same time with KuneriLite Camera plug-in, another situations Nokia Camera does not affect to KL Camera. |
| -28 | Given URL is malformed or bad arguments |
| -44 | Camera device not found |

