Skip to main content
This topic has been closed for replies.

1 reply

Participating Frequently
November 6, 2013

you'll want to use the netconnection and netstream classes.

This link is your friend, bookmark it:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/

Participating Frequently
November 6, 2013

Thanks for your reply

Can you share some examples for using netconnection and netstream ?

Participating Frequently
November 6, 2013

Here's an example taken from the as3 language reference library from the above link to get started, likely you'll have to use rtmp streaming with livestream...

package {

    import flash.display.Sprite;

    import flash.events.NetStatusEvent;

    import flash.events.SecurityErrorEvent;

    import flash.media.Video;

    import flash.net.NetConnection;

    import flash.net.NetStream;

    import flash.events.Event;

    public class NetConnectionExample extends Sprite {

        private var videoURL:String = "http://www.helpexamples.com/flash/video/cuepoints.flv";

        private var connection:NetConnection;

        private var stream:NetStream;

        private var video:Video = new Video();       

        public function NetConnectionExample() {

            connection = new NetConnection();

            connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

            connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

            connection.connect(null);

        }

        private function netStatusHandler(event:NetStatusEvent):void {

            switch (event.info.code) {

                case "NetConnection.Connect.Success":

                    connectStream();

                    break;

                case "NetStream.Play.StreamNotFound":

                    trace("Stream not found: " + videoURL);

                    break;

            }

        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {

            trace("securityErrorHandler: " + event);

        }

        private function connectStream():void {

            addChild(video);

            var stream:NetStream = new NetStream(connection);

            stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

            stream.client = new CustomClient();

            video.attachNetStream(stream);

            stream.play(videoURL);

        }

    }

}

class CustomClient {

    public function onMetaData(info:Object):void {

        trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);

    }

    public function onCuePoint(info:Object):void {

        trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);

    }

}