var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); var _vidName = "movie.flv"; var _vidURL = "http://www.boozza.com:4031/" + _vidName; //var _phpURL = "http://www.boozza.com:4031/scrubber.swf"; var ending = false; var amountLoaded:Number; var duration:Number; var loaderwidth = loader.loadbar._width; theVideo.attachVideo(ns); ns.setBufferTime(2); statusID = setInterval(videoStatus, 200); ns.onStatus = function(info) { trace(info.code); if(info.code == "NetStream.Buffer.Full") { bufferClip._visible = false; ending = false; clearInterval( statusID ); statusID = setInterval(videoStatus, 200); } if(info.code == "NetStream.Buffer.Empty") { if ( !ending ) { bufferClip._visible = true; } } if(info.code == "NetStream.Play.Stop") { bufferClip._visible = false; //ending = true; } if(info.code == "NetStream.Play.Start") { ending = false; } if(info.code == "NetStream.Buffer.Flush") { ending = true; } } playButton.onRelease = function() { ns.pause(); } play_btn.onRelease = function() { restartIt(); this._visible = false; } rewindButton.onRelease = function() { restartIt(); } ns["onMetaData"] = function(obj) { duration = obj.duration; //trace(obj.width); //trace(obj.height); // suck out the times and filepositions array, this was added by flvmdi27b times = obj.keyframes.times; positions = obj.keyframes.filepositions; } function videoStatus() { amountLoaded = ns.bytesLoaded / ns.bytesTotal; loader.loadbar._width = amountLoaded * loaderwidth; loader.scrub._x = ns.time / duration * loaderwidth; } loader.scrub.onPress = function() { clearInterval (statusID ); ns.pause(); this.startDrag(false,0,this._y,loaderwidth,this._y); } loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() { scrubit(); this.stopDrag(); } function scrubit() { var tofind = Math.floor((loader.scrub._x/loaderwidth)*duration); if (tofind <= 0 ) { restartIt(); return; } for (var i:Number=0; i < times.length; i++){ var j = i + 1; if( (times[i] <= tofind) && (times[j] >= tofind ) ){ trace("match at " + times[i] + " and " + positions[i]); bufferClip._visible = true; ns.play( _vidURL + "&start=" + positions[i]); trace("play " + _vidURL + "&start=" + positions[i]); break; } } } function pauseIt() { ns.pause(); } function stopIt() { ns.seek(0); ns.pause(); } function restartIt() { ns.play( _vidURL ); } //restartIt(); // holds sound _root.createEmptyMovieClip("vSound",_root.getNextHighestDepth()); vSound.attachAudio(ns); var so:Sound = new Sound(vSound); so.setVolume(100); mute.onRollOver = function() { if(so.getVolume()== 100) { this.gotoAndStop("onOver"); } else { this.gotoAndStop("muteOver"); } } mute.onRollOut = function() { if(so.getVolume()== 100) { this.gotoAndStop("on"); } else { this.gotoAndStop("mute"); } } mute.onRelease = function() { if(so.getVolume()== 100) { so.setVolume(0); this.gotoAndStop("muteOver"); } else { so.setVolume(100); this.gotoAndStop("onOver"); } } /* var theMenu:ContextMenu = new ContextMenu(); theMenu.hideBuiltInItems(); _root.menu = theMenu; var item1:ContextMenuItem = new ContextMenuItem("::::: Video Controls :::::",trace); theMenu.customItems[0] = item1; var item2:ContextMenuItem = new ContextMenuItem("Play / Pause Video",pauseIt,true); theMenu.customItems[1] = item2; var item3:ContextMenuItem = new ContextMenuItem("Replay the Video",restartIt); theMenu.customItems[2] = item3; */