Tag Archive for 'KuneriLite'

Leaving for San Francisco to attend Adobe MAX 2008

San Francisco

Friday (yes today!) I will leave for San Francisco to attend Adobe MAX 2008. My program is to attend MAX Pre Conference Education Developer Day on Sunday and then in Max I will attend mostly in Adobe Flash Lite and Adobe Flex sessions.

Sorry - I haven't written any entries to my blog for a long time and reason for that is I have been really busy with teaching and making a mobile learning Flash Lite application for Mobiletools. The guys at Mobiletools specialise in  integrating their mobile learning technology into existing eLearning  systems, sort of mobilizing the learning experience.

Mobiletools is making the project with Nokia and Prewise Finland - the application utilizes Prewise's learning portal and contents and  is being used by Nokia staff.

Nokia M-Kit

The application provides a full mobile learning and participation  suite with media materials, interesting quizzes and a challenge to  create your own content using a mobile device that supports Flash  Lite technology. We're using KuneriLite to package the application to  the end-users.

If you want to see how it works in action, try to reach me in MAX!

Nokia N95 firmware v30.0.015 and Flash Lite

I tested new Nokia N95 v30.0.015 firmware with KuneriLite Accelerometer plugin. In v21.0.0.16 there was problems with socket connections. LoadVars connection took then about 1 second with KuneriLite Accelerometer plugin in Flash Lite 3.0 Player (and it hangs UI drawing also for same time). Now in new firmware LoadVars calls seems to take same time but UI doesn't hangs anymore.

v30.0.015 firmware

One another note is that now playing streaming video with Flash Lite 3.0 doesn't rotate Flash Lite application to landscape automatically - great!

Testing KuneriLite plugins part three: Take, play and send video file from Flash Lite to server

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.

PTM Video pic 1 PTM Video pic 2 PTM Video pic 3

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!

Testing KuneriLite plugins part two: Accelerometer plugin

I want to test N95 Accelerometer and I installed Nokia N95 Accelerometer plugin package and made a small test with KuneriLite Accelerometer plugin. After a few test I noticed that getting a new axis values takes around one second. Oh it is ok I think but finally I noticed that all redrawing of the UI is hang also for a second. I have installed a new firmware to my N95 with Flash Lite 3.0 Player, which seems to have XML Socket bug and very slow. You can read more from Forum Nokia thread and Kuneri bloggy.

Like you can see at below picture, calling XML Socket in KuneriLite Accelerometer plugin in Flash Lite 3.0 Player takes about 1 second, and it hang UI drawing also to same time.

True and sad :-(

Edit:
Getting a new axis values:
- Nokia N95 (V 21.0.0.16, Flash Lite 3.0 Player) about 1101 ms. (left)
- Nokia N95 (V 20.0.015, Flash Lite 2.0 Player) about 100 ms. (right)

PTM Accel Pic 1 PTM Accel Pic 2

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

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!

Play FLV and Live Video with Flash Lite 3.0

I have made a few test with Flash Lite 3.0 and Flash Media Server 3 and I have to say that it is pretty easy to stream FLV Video files and Live Video from local web camera to mobile phone. Here are a quick instructions how to do it in Windows (I will publish Linux version later).

Play FLV-video from Flash Media Server 3:

  • Install Flash Media Server 3 (download developer version)
  • There are a few sample FLV files in applications/vod/media folder, so you can use one of them for testing
  • Create a new Flash Lite 3.0 file in Flash
  • Add a new Video symbol to library
  • Drag this Video symbol to Stage and give instance name to it: video
  • Type following programming to timeline:
// make a new video-object
var video:Video;
// make a new NetConnection-object
var nc:NetConnection = new NetConnection();

// check connection status from server
nc.onStatus = function(info:Object):Void {
  status_txt.text=info.code;
  if (info.code == "NetConnection.Connect.Success") {
    startStreaming();
  }
}

// start streaming video to phone
function startStreaming() {
  ns = new NetStream(nc);
  ns.setBufferTime(5);
  video.attachVideo(ns);
  // play sample.flv from server
  ns.play("sample",0);
}

// show info to user
status_txt.text = "Connecting server...";

// connect FMS 3 video on demand service (default port 1935)
nc.connect("rtmp://your.server.ip.here:1935/vod");
  • Go to Publish Settings...
  • Set Local playback security: Access network only
  • Publish your SWF-file
  • Send your SWF-file to your phone
  • Test and you should see FLV-video playing in your phone

Play live video from Flash Media Server 3:

  • Install Flash Media Server 3 (download developer version)
  • Install Flash Media Encoder 2 (Windows only)
  • Start Flash Media Encoder 2
  • You should see your live camera in Input screen
  • Press Start-button to start sending live video to Flash Media Server 3
  • Create a new Flash Lite 3.0 file in Flash
  • Add Video symbol and programming as you did earlier
  • Modify your programming:
// in startStreaming()-function
// Flash Media Encoder 2 publish stream name is "livestream"
ns.play("livestream",-1,-1,true);

// start connection to Flash Media Server 3
// Flash Media Encoder 2 publishes Flash Media Server's default
// live publishing point, so connect it
nc.connect("rtmp://your.server.ip.here:1935/live");
  • Publish, test and enjoy

Download sources: all



Get Adobe Flash playerPlugin by wpburn.com wordpress themes