« on AIR Bus Tour Boston: AIR API Overview | Main | on AIR Bus Tour Boston: AJAX in AIR »

on AIR Bus Tour Boston: AIR and Flash Video in 20 minutes

Thierry Curis from Akami gave a talk about using Flash Video in AIR.

Akami is creating an open source connection class (main site) that is robust, lightweight, and flexible, with credits to Will Law. Pure AS3 code. Setup to handle on demand content and protocol detection.

He gave a demo using the AkamaiConnection class to show streaming content. Some sample code is below. The complete source is available.

public function init():void {
    var ak:AkamaiConnection = new AkamaiConnection();

    // Some of the setup properties
    ak.createStream = true;
    ak.maxBufferLength = 5;
    ak.useFastStartBuffer = true;

    // Some of the events

    // handle connecting to the content
    ak.addEventListener(AkamaiNotificationEvent.CONNECTED, connectedHandler);
    // handle network connection going online/offline
    ak.addEventListener(AkamaiStatusEvent.NETCONNECTION, netStatusHandler);
    // know when the length of the stream becomes available
    // read it through the ak.streamLength property
    ak.addEventListener(AkamaiNotificationEvent.STREAM_LENGTH, streamLengthHandler);

    // where the stream is located
    ak.connect("hostname");
}

public function connectedHandler(event:AkamaiNotificationEvent):void
{
    var video:Video = new Video();
    video.attachNetStream(ak.netStream);
    ak.requestStreamLength("filename");
}

// once enough content has streamed
ak.play("filename");

// methods to control the playback
ak.resume();
ak.pause();
ak.seek(#);

Tags: air flex onair2007boston video