diff --git a/src/TUplayer.mxml b/src/TUplayer.mxml index cb35b1e..92400a5 100644 --- a/src/TUplayer.mxml +++ b/src/TUplayer.mxml @@ -1,5 +1,5 @@ - + Panel { borderAlpha: 1; @@ -37,6 +37,9 @@ private var tvVid:Video; private var cVid:Number; private var curVid:ArrayCollection; + private var onPause:Boolean = false; + private var t:Timer; + private var scrubbing:Boolean = false; /* Streams */ public var tvNC:NetConnection; // NetConnection For Sync Video @@ -61,6 +64,9 @@ tvVid = new Video(400,300); vidHolder.addChild(tvVid); cVid = Number(Application.application.parameters.vid); + + t = new Timer(500,0); + t.addEventListener(TimerEvent.TIMER,timerHander); } /* AMF Fault Handlers */ @@ -72,8 +78,20 @@ } public function onMetaData(info:Object):void { + var min:Number = Math.floor(info.duration/60); + var sec:Number = Math.floor(info.duration%60); + var secStr:String; + + if (sec < 10) + secStr = "0" + sec.toString(); + else + secStr = sec.toString(); + + fTime.text = min + ":" + secStr; + tvVid.width = info.width; tvVid.height = info.height; + timeLine.maximum = info.duration; if ((300 - info.height) > 0) { tvVid.y = ((300 - info.height)/2); @@ -84,9 +102,17 @@ } public function tvNetStatus(e:NetStatusEvent):void { - if (e.info.code == "NetConnection.Connect.Success") { - if (tvST != null) - tvST = null; + switch (e.info.code) { + case "NetStream.Play.Start": + t.start(); + break; + case "NetStream.Play.StreamNotFound": + case "NetStream.Play.Stop": + t.stop(); + break; + case "NetConnection.Connect.Success": + if (tvST != null) + tvST = null; if (tvNS != null) tvNS = null; @@ -94,10 +120,11 @@ tvNS = new NetStream(tvNC); tvNS.client = this; tvVid.attachNetStream(tvNS); - tvNS.close(); + tvNS.close(); tvST = tvNS.soundTransform; tvNS.addEventListener(NetStatusEvent.NET_STATUS, tvNetStatus,false,0,true); gateway.call("tuve.pVid",new Responder(gotVid,null),cVid); + break; } } @@ -105,7 +132,7 @@ if (result) { curVid = null; curVid = new ArrayCollection(result); - tvNS.play(curVid[0].file); + tvNS.play(curVid[0].file); } } @@ -114,6 +141,7 @@ } public function onPlayStatus(info:Object):void { + //Alert.show("test"); } public function updateVolume():void { @@ -121,15 +149,55 @@ st.volume = (volume.value) * .01; tvNS.soundTransform = st; } /* End updateVolume */ + + private function doPause():void { + if (onPause == true) { + pB.label = "||"; + tvNS.resume(); + onPause = false; + } + else { + pB.label = ">"; + tvNS.pause(); + onPause = true; + } + } + + private function timerHander(event:TimerEvent):void { + var min:Number = Math.floor(tvNS.time/60); + var sec:Number = Math.floor(tvNS.time%60); + var secStr:String; + + if (sec < 10) + secStr = "0" + sec.toString(); + else + secStr = sec.toString(); + + cTime.text = min + ":" + secStr; + + if (scrubbing == false) + timeLine.value = tvNS.time; + } + + public function scrubVideo(event:Event):void + { + if (scrubbing == true) { + tvNS.seek(timeLine.value); + scrubbing=false; + } + } + ]]> - - - + + + + +