All pastes #243445 Raw Edit

Quelqu'un

public text v1 · immutable
·published 2006-11-08 14:12 UTC
rendered paste body
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;
	}
}


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;
	}
if(!_global.nowPlaying){ restartIt(); }
	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( _phpURL + "?file=" + _vidName + "&to=" + positions[i]);
			//trace("play " + _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
			break;
		} 
	}
}