In my earlier Flash Lite article I've tested KuneriLite Camera plugin to take picture (klMode=picture). This time I've it's video support (klMode=video) to record video and store it to mobile phone. I've modified my ActionScript source code a little and it worked very nicely on the Nokia N95. This Flash Lite test application sends videos to my server http://ptm.fi/temp/videos folder, so check you uploaded videos from there.

Setting up system
This time I've tested KuneriLite wizard in Microsoft Vista. I've 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 on vista. You can find these modifications on the KuneriLite Wiki: Microsoft Vista Support.
Flash Lite application
The idea of this application is take video, play it to user and send it to a remote server (if the user wants to send it). All the ActionScript code is written to first frame of timeline. I'll describe here only needed lines to understand how to take, show and send video file to the remote server. Please see the FLA source code for more information.
Initialize application
There is one major bug in my previous example with taking picture, have you noticed it? I haven't thought on the situation where a user start to take picture and then press back when Kuneri Lite Camera plugin is active. The application is trying to make a thumbnail picture, which fails if there is no picture taken. In this video example this situation is handled with Camera plugin Status operation (klStatus).
A few variables are defined to handle video filename and KuneriLite plugin gateway errors.
var vidName:String = ""; // video name var klError:Number = -99; // klError number var klStatus:String = ""; // klStatus string var process:Number = 0; // process number var intervalId:Number; // interval number var path:String = "\\Data\\Others\\Trusted\\PTMVideo\\";
Preparing Camera
KuneriLite offers optional prepare command which prepares the camera resource and checks the presence of camera device. I'll check this first and let then user take video.
// check camera condition
process = 1;
intervalId = setInterval(checkProcess,1000);
status_txt.text = "status: preparing camera...";
loadVariables("http://127.0.0.1:1001/Basic/camera?
klCommand=prepare&klIndex=0","");
Taking video
This stage is very similar to the sending picture example from the previous article. The only visible modification is with Video instance. I’ve added one video symbol to the library and dragged it to the timeline (instance name is video). When a user presses the device’s number one key, KuneriLite uses loadVariables()-function to call Camera plugin in order to take video. Here I just take a full size video with main camera.
//Take video
function takeVideo(){
// videoname
vidName = giveDateAndTimeString();
var command:String = "";
command += "http://127.0.0.1:1001/Basic/camera?klCommand=start";
command += "&klMode=video";
command += "&klPath="+path+vidName+".3gp";
command += "&klSize=full";
command += "&klIndex=0";
status_txt.text = "status: taking video...";
process = 2;
klError = -99;
intervalId = setInterval(checkProcess,1000);
loadVariables(command,"");
}
Did user take video or not
As I wrote earlier, I didn’t check if the user had taken a picture in my previous example. Here I will do it after the video screen is closed in KuneriLite plugin. I have one function which checks processes to see what had happened in my application. When Kuneri Lite Camera plugin is closed, I’ll start to check if there’s a video file taken or not.
// .. part of my prosess function
// check if video is taken
case 2:
if (klError == -99) return;
clearInterval(intervalId);
if (klError == 0) {
status_txt.text += "done!";
intervalId = setInterval(checkVideo,2000);
}
process = 0;
break;
//check is video taken
function checkVideo() {
clearInterval(intervalId);
var command:String = "http://127.0.0.1:1001/Basic/camera?klCommand=status";
status_txt.text = "status: checking video...";
process = 3;
klError = -99;
klStatus = "";
intervalId = setInterval(checkProcess,1000);
loadVariables(command,"");
}
If video is available, just start to play it.
// .. part of my prosess function
// is videofile available
case 3:
if (klError == -99) return;
clearInterval(intervalId);
if (klError == 0) {
status_txt.text += "done!";
if (klStatus == "complete") {
intervalId = setInterval(playVideo,2000);
} else if (klStatus == "exit") {
status_txt.text = "status: No video!";
}
} else {
status_txt.text = "status: klError = "+klError;
}
process = 0;
break;
Play video
After video is taken, it will be showed to user with video instance.
// Load and play video
function playVideo(){
clearInterval(intervalId);
status_txt.text = "status: playing video...";
video.play(vidName+".3gp");
}
video.onStatus = function(info){
if (info.code=="completed") status_txt.text += "done!";
}
Sending video file to remot server
Sending is handled the same way I used in my photo example. I added upload status checking to this example. First video will be sent to server and uploading is checked with own made checking function
function checkUploading() {
clearInterval(intervalId);
var command:String = "http://127.0.0.1:1001/Basic/uldl?klCommand=status";
command += "&klTrId=1234";
process = 5;
klError = -99;
klStatus = "";
intervalId = setInterval(checkProcess,1000);
loadVariables(command,"");
}
and process function is checking what is going on with uploading. KuneriLite sends a few different status, I used only two of them: complete if uploading is successfully completed or failed if there where some problems.
case 5:
if (klError == -99) return;
clearInterval(intervalId);
if (klError == 0) {
status_txt.text = "status:" +klStatus;
if (klStatus == "complete" || klStatus == "failed") {
process = 0;
} else {
intervalId = setInterval(checkUploading,1000);
}
} else {
status_txt.text = "status(5): klError = "+klError;
process = 0;
}
break;
Source and SIS files
This application is designed to run 240×320 screens and for testing purposes only. It uses KuneriLite’s default generated SIS package, so if you have my other examples installed you have to remove these first.
Sources: PTMVideo.zip (Flash Lite 2.0 Application)
SIS: PTMVideo_3rd_edition_signed.sis (install it to memory card!)
Feel free to try this example and send video greetings to me with Flash Lite!
Note! I have 20MB upload limit per file with PHP at my server, so dont take too long videos!















hi there
great tutorial, I posted the message on the previes one about doing this on windows mobile, but now I have nokia and I can start testing…
Ok, I installed de sis file and it works perfect!!!
I have few question about kuneri:
Its about uploading to server:
Do I need to install kuneri lite on server? (I think not, kuneri is there to make sis file with the plugin)
And your php scipt Can you post the script?
And last thing: How can I upload the movie via bluetooth to server?
thanks
Daka
Daka,
You cannot install KuneriLite to server side, it is used in mobile phone. You can find that PHP sample script from KuneriLite plugins page (upload/download plugin page). I haven’t use bluetooth for that kind of purpose.
Pasi
Hello! Great tutorial!
((((((( May be i made something wrong ?
But on my Nokia 6300 don’t work…
Kir,
Nokia 6300 is S40 phone – kuneri plugins works only in S60 phones.
Pasi
Video quality for N95 is very bad even at fullsize and original 3gp video is good without using kunerilite. Any one experience this?
Anyway, I think I figure out the video resolution. My next problem is the video size at full resolution cannot record more than 2 minutes. I limited by the maximun size that I got is 7.5MB
Great tutorial indeed.
I was trying to make application auto mode by adding ‘klInstant’ and ‘klLength’ (60 sec) but getting klError code -28 (Given URL is malformed or bad arguments)!
var command:String = “”;
command += “http://127.0.0.1:1001/Basic/camera?klCommand=start”;
command += “&klMode=video”;
command += “&klInstant=1″;
command += “&klLength=60″;
command += “&klPath=”+path+vidName+”.3gp”;
command += “&klSize=medium”;
command += “&klIndex=0″;
Is the command wrong or am I missing anything?
Thanks
Ovais
Ovais,
sorry but I haven’t use Kuneri’s automode. You should check more info from KuneriLite website.
Pasi
Hi everybody
I need to let users to capture a video in MP4 format.
I’m using the Nokia N95, and I know it can record in mp4 format.
the problem is that the kuneri camera plugin is using 3gp only.
maybe the comercial version will work, or I should use the native camera app using kuneri System plugin.
I’ll be very happy to hear your ideas
YuriF,
Kuneri plugin use 3gp only, but you can ask Kuneri to write custom plugin for you. I think there is same situation with commercial plugin.
Pasi
hi Pasi, thanks for your tutorial , I try to recompile PTV a sis file and all work fine but i have a problem when the application try to play the movieclip..with this error message “General: System error”. And if i try to send video i riceve on status(4):KlError=-1
which is the problem with it??
Thank
Max DS,
check that you have added camera and upload/download plugins to you project in kuneriwizard page one. You are using S60 phone, right? If you dont get it working, can you send your FLA, and I will check it.
Pasi
Hi,
I tried installing both your camera and video apps on my phone. They say expired certificate. Could you help me with that ?
Thanks a lot!
Aditi
Aditi,
so there is one year gone now when I made this example and my SIS-file’s sertificate is old. I think that best way now is that you download my sources and try to do own SIS with our own cer ja key files. (sorry I don’t have enough time to do it now)
br,
Pasi