Testing KuneriLite plugins part one: Camera and Upload plugins

Finally I got time to test KunerLite plugins. They have done 11 nice plugins to extend Flash Lite applications. Now I am going to test a few of them and write some lines here in my blog.

My first test is to do Flash Lite application which takes pictures and sends those to server side. This testing application sends pictures to my server http://ptm.fi/temp folder, so check you uploaded photos from there.

PTM Camera pic 1 PTM Camera pic 2 PTM Camera pic 3

Setting up system
I recently reinstalled Windows again, so I have to install Active Perl and Symbian S60 3rd edition SDK Maintenance Release back to my computer to get KuneriLite working. You can find all necessary information’s from KuneriLite Wizard Beginner's Guide (they have done excellent wiki for you which helps setting up KuneriLite to your computer). After Perl and S60 SDK is ready in your computer, you have to install KunerLite, you can download free Basic version from Kuneri’s web site.

Flash Lite application
The idea of application is to take picture and send it to server side. I decided to program Flash Lite 2.0 application because I don’t want to mess with old Flash Lite 1.1 code anymore :-). All code is written to first frame of timeline, I will describe here only needed lines to understand taking and sending picture to server side. Please see source code for more information.

Initialize application
A few variables are defined to handle picture name and KuneriLite plugin gateway errors. I have made small delays between taking/storing picture, making thumbnail and loading thumbnail because you have to wait a little time to get picture ready to resize or loading. These processes are handled with process and intervalId variables and setIntervals. Pictures and thumbnails are stored in application installation directory.

var picName:String = "";
var klError:Number = -99;
var process:Number = 0;
var intervalId:Number;
var path:String = "\\Data\\Others\\Trusted\\PTMCamera\\";

Taking picture
When user press mobile phones number one key, a new mc is created to store and show picture’s thumbnail. KuneriLite uses loadVariables()-function to call Camera plugin to take picture. You can find more information about Camera plugin from their web site. Here I just take full size picture with main camera.

/* take picture */
function takePicture(){
  // create new mc to display new image
  if (image_mc != undefined) {
    removeMovieClip(image_mc);
    picture_txt.text = "";
  }
  this.createEmptyMovieClip("image_mc",this.getNextHighestDepth());
  image_mc._x = 40; image_mc._y = 105;
  picName = giveDateAndTimeString();
  var command:String = "";
  command += "http://127.0.0.1:1001/Basic/camera?klCommand=start";
  command += "&klMode=picture";
  command += "&klPath="+path+picName+".jpg";
  command += "&klSize=full";
  command += "&klIndex=0";
  status_txt.text = "status: taking picture...";
  bottom_mc.image_txt.text = "";
  process = 1; klError = -99;
  loadVariables(command,"");
}

Making thumbnail and show it to user
After picture is taken it will be resized and loaded to Flash Lite application. You can resize pictures with KuneriLite Camera plugin and load pictures with MovieClipLoader.

/* make thumbnail */
function resizePicture() {
  clearInterval(intervalId);
  var command:String = "";
  command += "http://127.0.0.1:1001/Basic/camera?klCommand=resize";
  command += "&klPath="+path+picName+".jpg";
  command += "&klSize=160*120";
  command += "&klTargetFile="+path+picName+"_thumb.jpg";
  status_txt.text = "status: resizing picture...";
  process = 2; klError = -99;
  loadVariables(command,"");
}

/* load picture */
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
function loadPicture(){
  clearInterval(intervalId);
  status_txt.text = "status: loading thumbnail...";
  mcLoader.loadClip(picName+"_thumb.jpg",image_mc);
  picture_txt.text = picName+".jpg";
}

function onLoadError(mc:MovieClip) {
  status_txt.text = "status: error loading thumbnail!";
}

function onLoadComplete(mc:MovieClip) {
  status_txt.text += "done!";
}

Sending original picture to server side
Sending is very similar process, just call KuneriLite Upload plugin and it sends picture to server. In server side you have to use for example PHP to get and store picture (you can find example PHP code from Kuneri’s web site). Remember give write permission to folder where images will be uploaded.

/* send picture */
function sendPicture(){
  var command:String = "";
  command += "http://127.0.0.1:1001/Basic/uldl?klCommand=upload";
  command += "&klTrId=1234";
  command += "&klUrl=http://www.ptm.fi/flashlite/kuneri/getImage.php";
  command += "&klFile="+path+picName+".jpg";
  command += "&klType=image/jpeg";
  status_txt.text = "status: sending picture...";
  process = 3; klError = -99;
  loadVariables(command,"");
}

There are also function which handles user interactivity with mobile keys and function which just check processes what is happening in Flash Lite application and updates dynamic status textfield. Please see those in source codes.

Creating SIS-file
You can create SIS file with KuneriLite Wizard. It is very easy process – create project, select plugins, add files to your project and finally create SIS file. I have made own cer and key files with makekeys command. More info to sign SIS files can be found for example from Adobes site.

Creating SIS file

Source and SIS files
This application is designed to run 240x320 screens and for testing purposes only. It uses KuneriLite’s default generated UID in SIS package.

Sources: PTMCamera.zip (Flash Lite 2.0 Application)
SIS: PTMCamera_3rd_edition_signed.sis (install it to phone memory)

It is amazing easy to do this kind of application with KuneriLite plugin’s, thanks to all KuneriLite team members!

32 Comments

  • […] created this wonderful article, showing how to use device camera to take pictures, resize them and upload to a […]

  • Great work Pasi, well done!

  • […] Magnífico tutorial creado por Pasi, que nos muestra el uso de dos de los plugins más interesantes de los que dispone actualmente kuneri lite: camara y upload. El tutorial nos muestra como realizar una fotografía con nuestro dispositivo y subira a un servidor mediante una conexión de datos, y por el camino, prepara la imagen para ser enviada reescalándola […]

  • […] Manninen shown a good example of using Kuneri lite Camera and Upload plugins.  powered the Flash lite capabilities on mobile devices. Extend the Flash lite capabilities on […]

  • […] will be using Pasi’s KuneriLite Picture uploader, so you can see latest pictures from web […]

  • Amazing!
    Since I found the kuneri wiki not very helpful for doing my first steps with FlashLite and Kuneri I am very thankful, Pasi, You present Your application and even the source code here. Thank You very much!

  • Hi ptm,
    I would ask a question about the sis certificate: i can create a sis file without official certificate?Because at the moment I can’t make a sis from your .fla because I don’t have any usefull certificate?
    And if there’s no solution how much cost the certificate?
    Thanks a lot!

  • You can create your own self signed sis with makekeys. More info can be found for example here: http://www.adobe.com/devnet/devices/articles/creating_sis_files.html

    Pasi

  • […] I installed Active Perl and Symbian S60 3rd edition SDK Maintenance Release as I did earlier in my Camera and Upload plugins -article. I had to make small modifications to get KuneriLite Wizard working at vista. You can find […]

  • hy, I was wondering if this is possible to do with windows mobile 6 pro?
    With windows flash player is embeded in internet explorer, so no stnand alone player.

  • daka

    good question – I haven’t tested kuneri plugins in browser. I think it won’t work because you’ll need to package kuneri plugins to SIS-file with your Flash Lite content.

    Pasi

  • hy, I’m trying to make sis file from your fla…I made certificate and key file with makekeys.exe. This is how I did:
    ——————First Step———-
    Project Name: Your FrAME
    Project Path: C:\KuneriLite\Projects\Your FrAME\
    Installation Note: Your FrAME
    Plugins: Camera
    ForceFlashLite: FlashLite 2.x/3.x
    Maximum Memory: Deafult
    Use external Hub: checked
    Use stub checked
    ——————Second Step———
    Folder to add: C:\Documents and Settings\daka\Bureaublad\PTMVideo\
    Content selected: PTMVideo.swf
    ——————Third Step———–
    Main swf: C:\Documents and Settings\daka\Bureaublad\PTMVideo\PTMVideo.swf
    Grid Info: Blank
    Grid Menu: Applications
    Grid Caption: Your FrAME
    Install Path: blank
    UID: blank
    UID pck: blank
    Version: blank
    port: blank
    vendor: blank
    Certificate: C:\KuneriLite\Projects\mycert.cer
    Key file: C:\KuneriLite\Projects\mykey.key
    Passwoord: mypasswoord
    ————–then compile project————–
    Send YourFrAME_3rd_edition_signed.sis file to nokia n78
    and install….click yes
    ************AND HIER COMES THE TROUBLE****************
    the certificate may not yet be valid, is expired or phone date setting may be incorrect

    Now, can you help me on this one???
    What did I forgot to do???
    And if you know how can I make it???
    thanks,
    Daka

  • Daka,

    there are a lot of discussion about this issue in different forums. Try for example this:
    http://discussion.forum.nokia.com/forum/showthread.php?t=111738

    Pasi

  • it solved my problem,
    just:
    Your Development Machine Date & Time must not be more then Device Date & Time
    and installation was good!
    Now, I have other problem:
    When opening aplication it gives me status:preparing camera and it keeps prepering camera all the time!
    I looked all codes in fla file:
    and this line should give me what kind of error is it:
    case 1: // prepare camera
    if (klError == -99) return;
    clearInterval(intervalId);
    if (klError == 0) {
    status_txt.text += “done!”;
    } else {
    status_txt.text = “status(1): klError = “+klError;
    But it gives me whole time: status: preparing camera…
    What seems to be problem, I’m thinking it is again at kunerilite and not at fla file…..

  • Daka,

    have you tested my SIS-file, does it work in your N78?

    Pasi

  • it works perfectly!
    that’s why I’m shure that it about kunerilite!
    To make whole story clear I will illustate everything on my website!
    Hier is the Link: http://websiteplaats.nl/KuneriLite-and-FlashLite-Problem

  • Daka,

    I tested your SIS and it works in my E71, so there might be some issue with your N78. But it is strange that my SIS works in your phone :-)

    Pasi

  • Daka, I have exactly the same problem for N95. I can install the sis and it is working but the the source code.

  • Just tested this apps. and it works great :)

    cheers
    vivek

  • Hi Pasi,

    When I try to install your SIS in my N95, I received a message “update error”.

    After this, I adapt your code to do a camera operation to take a picture. I generate a new SIS and install without problems. Now, the problem that happens, when I try to take a picture (takePicture method), a new message “server not found” is shown.

    Could you help me to solve this issue?

    Thanks in advance.

  • Anthony,

    do you have any other kuneri examples installed in your N95? I think I used basic (not commercial version) when I created example SIS-file. You can install only one kuneri examples at same time to phone (basic versions). That example SIS uses kuneri plugins, so you have to use kuneri wizard when you make a new SIS (and add camera plugin).

    Pasi

  • Ok Pasi. I use a kuneri basic version too. When I created a SIS file I used the wizard to do this task.
    If you have any way to receive my file (fla) to see where I am missing.
    Regards.

  • hi folks,
    can you post the php-code of the getImage.php file?

    thanks a lot

  • mm,

    you can find example php-code from Kuneri’s website (get.php):
    http://wiki.kunerilite.net/index.php?title=Upload/Download_plugin

    Pasi

  • Hi Pasi, I have some very primitive questions, hope you can help me with.
    1) Can this .flv be tested by the Adobe Device Central in CS. I am guessing not, cos it kept on showing the status: preparing for carema…or some extra steps need to take.
    2) Is that true that when I install the KuneriLite packet to my computer, I already have those plugins for Flash Lite. DoI have to do anything else, so flash lite will recognize these KuneriLite plugins.
    3) Is this SIS file only supportted by Nokia, can it be installed on other cellphones? I am asking since I noticed that this requires the nokia SDK.

  • ohh, and almost forget. Do I use the Adobe CS to work with your .flv, or with the KuneriLite kit?

  • BobUsingCS3,

    1) I think you mean swf, you cannot test it in DC because SWF uses Kuneri Plugins and those works only in mobile or KuneriLite Emulator
    2) You have to use KuneriWizard and select all plugins what you use in your SWF. So those plugins are included in SIS file.
    3) KuneriLite works only with Nokia S60 devices
    4) I think you mean here .FLA, it works with CS3/CS4 and then compile your project to .SWF and then you have to use KuneriLite Wizard to package your .SIS.

    Pasi

  • Hi Pasi,

    Thank you, that surely answered most of my question. I am not too sure about the usage of KuneriLite Emulator. You said I can use KuneriLite Emulator to test the SWF file. If I do so, the Emulator will use the webcam that connect to my computer as the cellphone carema? I am asking this because I current do not possess a nokia s60 series.
    When I tried to use the KuneriLite Emulator. I put the path of my application in the “Application Path” field as follows: d:\myApp .
    It gave me an error message saying the path has to start with “\”. I don’t know what I did wrong. Must the application be placed in a specific folder under “KuneriLite root directory” ?

  • BobUsingFL3,

    I am not sure about this camera thing. Maybe you can test it only in real device. I suggest that you write this to kuneri forum at http://forum.kuneri.net/

    Pasi

  • I get the following message while testing the setup after installing Kunerilite.

    ———————————————————–
    Using rsc\ as default KuneriLite path.
    Projects\KuneriLiteTest\KuneriLiteTest.pkg is successfully created.
    Link to notes file Projects\KuneriLiteTest\release.txt is successfully added int
    o Projects\KuneriLiteTest\KuneriLiteTest.pkg.

    MySIS by Kuneri. All rights reserved.

    Using rsc\ as default KuneriLite path.
    Basic version detected
    Using AF105151(generated) as UID.
    Using rsc\default.svg as default icon.
    Using GCCE as default compiler.
    Using 0.1.0 as default version number.
    Not using KuneriLite, just generating SWF launcher.
    Using 1001 as default communication port.
    Using AF105151 as SIS package UID.
    Installation path: \KuneriLiteTest
    Please wait… this will take some seconds.

    KuneriLite Basic ver. 0.9.8 by Kuneri

    Processing.

    File open error!’$$$.cmd’ is not recognized as an internal or external command,
    operable program or batch file.

    Closing due to errors.
    Press any key

    ———————————————————–

    Just to confirm the installations and the sequence, I have the following:

    1. C:\Kunerilite
    2. C:\Perl
    3. C:\Symbian

    Please help.

    Regards,
    Supriya Tenany

  • Supriya,

    your installation dir’s looks good to me. I think you have posted this issue to kunerilite forums also. I will ask kuneri boys to answer it.

    Pasi

  • Hi,

    As mentioned in the Symbian Signed process, I should be using the allotted UID and then do a test on my handset, with the DevCert created through the Publisher ID (p12 file from the trust center), before I submit for the Certified Signed. I guess, this step cannot be perfomed with this packager as when I enter the protected UID provide the DevCert, the private key and the password, the SIS created doent install my app on the phone. I get and error :”Unable to install, contrained by the certificate.”. However an unprotected default UID, with a kuneri self-generated 1024 char cert and key works; but that is not what we intend to test.

    Please help.

    Regards,
    Supriya Tenany

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>