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!