Saturday, December 5, 2009

[AIR] Hello NativeProcess with C#

you can read bla bla bla somewhere else not here sry, actually i did this for a while but hardly find time to blog this, btw if you follow my twitter, you will find that i yelling my result for this just the day after AIR2 release, so…twitter still rules for daily update, and more slow+detail via blog ;)

here’s fire starter c++
http://www.adobe.com/devnet/air/flash/quickstart/interacting_with_native_process_02.html

and then java
http://corlan.org/2009/11/30/magnifying-glass-air-2-application-or-how-to-communicate-with-a-java-program-from-air/

and..what is this lang btw? ;)
http://mchristoff.com/2009/12/using-the-air-2-0-nativeprocess-api-to-control-mplayer/

nvm, let’s try with C# (it’s my 1st time on C# , so plz don’t hit me ;p)

using System;
using System.IO;

namespace HelloNativeProcess
{
class Program
{
static void Main(string[] args)
{

using (Stream stdin = Console.OpenStandardInput())
using (Stream stdout = Console.OpenStandardOutput())
{
byte[] buffer = new byte[2048];
int bytes;
while ((bytes = stdin.Read(buffer, 0, buffer.Length)) > 0)
{
stdout.Write(buffer, 0, bytes);
}
}
}
}
}

it’s just work!, so….that’s it! :) btw look like adobe example always call new NativeProcess(); and call process.closeInput(); after thing done, i found that i can keep that hole open by just not close it (so no need to new NativeProcess again) and try rapid call…yeah right why don’t someone try streaming OpenGL screen capture result as ByteArray through this hole and draw them to Flash Bitmap? next question is…what for? LOL

well…just for fun then, from my test i got 2048 bytes rapid call by 30fps enterFrame….i got swing result around 30-50ms for read and write back, is this fast enough?, not sure either, suppose to be a bit faster without debug mode, i try blog this in case someone reading and itchy to try that out!
for me…i got no more free time for that, gotta back to work now ;p


del.icio.us Tags: ,,
Post a Comment