Hello every one!
I have worked before with playing flv files, and had no problem such that. So here is a code
var loadedVid:Sprite = new Sprite();
var vid:Video;
var nc:NetConnection;
var ns:NetStream;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
var customClient:Object = new Object();
ns = new NetStream(nc);
ns.client = customClient; // i made that option after help at adobe.com . That helps me do not recieve MetaData error.
vid = new Video();
vid.attachNetStream(ns);
ns.play("video/1.flv");
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
vid.smoothing = true;
vid.width = 200;
vid.height = 150;
ns.seek(1);
ns.pause();
loadedVid.addChild(vid);
addChild(loadedVid);
playVid.addEventListener(MouseEvent.CLICK, playVideo);
function playVideo(e:MouseEvent):void{
ns.resume();
ns.addEventListener(NetStatusEvent.NET_STATUS, checkStreamStatus);
}
function asyncErrorHandler(e:AsyncErrorEvent):void {
trace ("AsyncErrorEvent");
ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
}
function checkStreamStatus(e:NetStatusEvent):void {
switch (e.info.code) {
case "NetStream.Play.Stop":
ns.seek(0);
ns.pause();
break;
}
}
So what i revieve - NS is loaded, seeked to second 0 , and paused. After pushing a play button that resuming playing from 0 second. After Video has completed playing i catch that event and setting seek again to 0, and pausing the strem. So the problem is- after making that option seeking and pausing, my stream video blinking? like disapearing for a moment and revieling again with 0 frame image.
That looks so bad, how can i fix it?