# Playing video from FMS in AS3 with NetConn/Stream classes

**URL:** <https://forum.kirupa.com/t/playing-video-from-fms-in-as3-with-netconn-stream-classes/260213>\
**Category:** flash\
**Created:** [May 13, 2008, 3:23pm UTC](https://forum.kirupa.com/t/playing-video-from-fms-in-as3-with-netconn-stream-classes/260213 "2008-05-13T15:23:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tibberous](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tibberous](https://forum.kirupa.com/u/tibberous)\
**Post date:** [May 13, 2008, 3:23pm UTC](https://forum.kirupa.com/t/playing-video-from-fms-in-as3-with-netconn-stream-classes/260213/1 "2008-05-13T15:23:58Z")

</div>

I know this should be very easy to find, but I can only find examples that use non-streaming files.

Here is what I have:

```php

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 = "video.flv";
        private var connection:NetConnection;
        private var stream:NetStream;

        public function NetConnectionExample() {
            connection = new NetConnection();
            connection.client = new Object();
            connection.client.onBWDone = function(){
                trace('BW Done');
            }
            connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            connection.connect("rtmp://www.server.com/a2547/");
        }

        private function netStatusHandler(event:NetStatusEvent):void {
            trace(event.info.code);
            
            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 {
            var stream:NetStream = new NetStream(connection);
            stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            stream.client = new CustomClient();
            var video:Video = new Video();
            video.attachNetStream(stream);
            stream.receiveVideo(true);
            stream.receiveAudio(true);
            stream.play("WWE/wrestlemania.flv");
            
            addChild(video);
            
        }
    }
}

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);
    }
}

```

And in the main timeline:

import NetConnectionExample;  
var n = new NetConnectionExample();  
addChild(n);

And the rtmp:// url is good, because if I use the FLV playback component, it plays.

Any ideas whats wrong with what I have, or just where I can find a working example for streams?

Thanks.
