[HELP] HTTP Streaming Video Freeze

Hi all,

Sorry, if my English is bad. I have a problem. I have made a Video Player using NetStream Class and using VLC as HTTP Streaming Server.

This is my code :


package  {
    import flash.display.MovieClip;
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.events.NetStatusEvent;
    import flash.events.MouseEvent;
    import flash.media.Video;
    import flash.events.AsyncErrorEvent;
    
    public class VideoPlayer extends MovieClip {
        private var urlRequest:URLRequest;
        private var textLoader:URLLoader = new URLLoader();
        private var runTextField:TextField = new TextField();
        private var textFormat:TextFormat = new TextFormat();
        private var font:Font1 = new Font1();
        private var counter:int = new int();
        private var bgText:mc_BgText = new mc_BgText();
        private var timer:Timer;
        private var infoTextField:TextField = new TextField();
        private var reload:reloadButton = new reloadButton();
        private var video:Video = new Video();
        private var nc:NetConnection = new NetConnection();
        private var ns:NetStream;
        private var client:Object = new Object();
        
        public function VideoPlayer() {
            client.onMetaData = onMeta;
            client.onCuePoint = onCue;
            
            video.x = 0;
            video.y = 0;
            video.height = 360;
            video.width = 480;
            
            bgText.x = 0;
            bgText.y = 340;
            bgText.visible = false;
            
            textFormat.size = 13;
            textFormat.color = 0xffffff;
            textFormat.font = font.fontName;


            runTextField.defaultTextFormat = textFormat;
            runTextField.embedFonts = true;
            runTextField.y = 340;
            runTextField.height = 20;
            
            infoTextField.text = "Stream Not Found";
            infoTextField.textColor = 0xffffff;
            infoTextField.x = 185;
            infoTextField.y = 155;
            
            reload.x = 10;
            reload.y = 300;
            //reload.x = 205;
//            reload.y = 175;
            reload.addEventListener(MouseEvent.CLICK, onClick);
            
            infoTextField.visible = false;
            reload.visible = true;
            
            getVideoStream();
            getTextStream();
            
            addChild(video);
            addChild(bgText);
            addChild(runTextField);
            addChild(infoTextField);
            addChild(reload);
        }
        
        private function getVideoStream():void {            
            nc.connect(null);
            var ns:NetStream = new NetStream(nc);
            ns.client = client;
            ns.bufferTime = 2;
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
            ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
            ns.play("http://localhost:8080?n"+ new Date().getTime());
            video.attachNetStream(ns);
        }
        
        private function onAsyncError(event:AsyncErrorEvent):void {
            trace(event.text);
        }
        
        private function onNetStatus(event:NetStatusEvent):void {
            trace(event.info.code);
            switch(event.info.code) {
                case "NetStream.Play.StreamNotFound":
                    infoTextField.visible = true;
                    reload.visible = true;
                    break;
                default:
                    break;
            }
        }
        
        private function onClick(event:MouseEvent):void {
            infoTextField.visible = false;
            reload.visible = true;
            getVideoStream();
        }


        //this is function for running text
        private function getTextStream():void {
            var urlRequest:URLRequest = new URLRequest("http://localhost:7777?n"+ new Date().getTime());
            
            textLoader.addEventListener(Event.COMPLETE, onCompleteLoaded);
            textLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
            textLoader.load(urlRequest);
        }
        
        private function onCompleteLoaded(event:Event):void {        
            runTextField.x = 480;
            runTextField.text = event.target.data;
            runTextField.width = runTextField.text.length * 9;
            
            counter = runTextField.x + runTextField.width;
            
            var timer:Timer = new Timer(20, counter);
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
            timer.start();
            
            getTextStream();
        }
        
        function onTimer(event:TimerEvent):void {
            bgText.visible = true;
            runTextField.x -= 1;
        }
        
        function onTimerComplete(event:TimerEvent):void {
            bgText.visible = false;
        }
        
        function onIOError(event:IOErrorEvent):void {
            getTextStream();
        }
        
        function onMeta(info:Object):void {
            trace("meta");
        }
        
        function onCue(info:Object):void {
            trace("cue");
        }
    }
}

The output is :


NetStream.Play.Start
NetStream.Buffer.Full
meta
NetStream.Buffer.Empty
NetStream.Buffer.Full

The video player works but after about 10 seconds, the video always stop playing (freeze) and no more output about NetStream. So I made a reload button to recall getStreamVideo() function and the video start playing again. But after about 10 seconds, it’s happened again. The video stop playing again. I don’t know what it caused. It’s been two weeks. I can’t solved it. Help me, please.

Thanks
fauziimamb