I have a digital magazine (pageflip) on my site and i want to play video in each page.
my problem is when user want to see the magazine he need to wait untill all the movies preloading…
Im trying to stop FLV from preloading untill the user click on play button or go to other page on our magazine (pageflip).
can someone know how to do it?
this is the code im using for the FLV video
stop();
var n = 0;
trailer = new XML();
trailer.ignoreWhite = true;
trailer.onLoad = function(success) {
if (success) {
video = trailer.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
videoWidth = trailer.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
videoHeight = trailer.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
buffTime = trailer.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;
theVideo.attachVideo(ns);
ns.play(video);
ns.pause(true);
theVideo._width = videoWidth;
theVideo._height = videoHeight;
theborder._width = theVideo._width+20;
theborder._height = theVideo._height+65;
theborder._x = theVideo._x-10;
theborder._y = theVideo._y-10;
the_controls.bigButton._width = theVideo._width;
the_controls.bigButton._height = theVideo._height;
the_controls.bigButton._y = -theVideo._height+45;
the_controls._x = theVideo._x;
the_controls._y = theVideo._y+theVideo._height;
the_controls.controls_bg._width = videoWidth-1;
the_controls.progress_bar.progressBar._width = videoWidth-90;
the_controls.progress_bar.the_load_bar._width = videoWidth-90;
the_controls.sound_btn._x = the_controls.controls_bg._width-40;
buffText._x = theVideo._x+(theVideo._width-85);
buffText._y = theVideo._y+17;
buffText._alpha = 100;
}
};
trailer.load(“xml/myxml.xml”);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.setBufferTime(buffTime[0]);
ns.onStatus = function(info) {
if (info.code == “NetStream.Buffer.Full”) {
buffText._alpha = 0;
}
if (info.code == “NetStream.Buffer.Empty”) {
buffText._alpha = 100;
}
if (info.code == “NetStream.Play.Stop”) {
ns.seek(0);
buffText._visible = false;
ns.pause(true);
if (n == 1) {
the_controls.pause_Btn.gotoAndStop(1);
n = 0;
} else {
the_controls.pause_Btn.gotoAndStop(2);
n = 1;
}
}
};
//video loading bar
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;
ns.onMetaData = function(obj) {
duration = obj.duration;
};
function videoStatus() {
amountLoaded = ns.bytesLoaded/ns.bytesTotal;
the_controls.progress_bar.the_load_bar._width = amountLoadedthe_controls.progress_bar.progressBar ._width;
the_controls.progress_bar.seeker._x = Math.floor(ns.time/duration(the_controls.progress_bar.progressBar._w idth-24));
}
//seeker
var scrubInterval;
the_controls.progress_bar.seeker.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit, 10);
this.startDrag(false,0,this.y,the_controls.progre ss_bar.progressBar. width-24,this._y);
};
the_controls.progress_bar.seeker.onRelease = the_controls.progress_bar.seeker.onReleaseOutside= function () {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus, 100);
this.stopDrag();
};
the_controls.progress_bar.seeker.onRollOver = the_controls.progress_bar.seeker.onDragOver=functi on () {
_root.canflip=false;
the_controls.progress_bar.seeker.gotoAndStop(2);
};
the_controls.progress_bar.seeker.onRollOut = the_controls.progress_bar.seeker.onDragOut=functio n () {
_root.canflip=true;
the_controls.progress_bar.seeker.gotoAndStop(1);
};
function scrubit() {
ns.seek(Math.floor((the_controls.progress_bar.seek er._x/(the_controls. progress_bar.progressBar._width-24))*duration));
}
//pause/play button
the_controls.pause_Btn.onRelease = the_controls.pause_Btn.onReleaseOutside=function () {
ns.pause();
buffText._visible = true;
if (n == 1) {
the_controls.pause_Btn.gotoAndStop(1);
ns.play(video);
n = 0;
} else {
the_controls.pause_Btn.gotoAndStop(2);
n = 1;
}
};
the_controls.pause_Btn.onRollOver = the_controls.pause_Btn.onDragOver=function () {
_root.canflip=false;
};
the_controls.pause_Btn.onRollOut = the_controls.pause_Btn.onDragOut=function () {
_root.canflip=true;
if (n == 1) {
the_controls.pause_Btn.gotoAndStop(2);
} else {
the_controls.pause_Btn.gotoAndStop(1);
}
};
//sound control
this.createEmptyMovieClip(“vSound”,this.getNextHig hestDepth());
vSound.attachAudio(ns);
var so:Sound = new Sound(vSound);
var m = 0;
the_controls.sound_btn.onRollOver = the_controls.sound_btn.onDragOver=function () {
_root.canflip=false;
};
the_controls.sound_btn.onRollOut = the_controls.sound_btn.onDragOut=function () {
_root.canflip=true;
};
the_controls.sound_btn.onRelease = the_controls.sound_btn.onReleaseOutside=function () {
if (m == 0) {
so.setVolume(0);
the_controls.sound_btn.gotoAndStop(2);
m = 1;
} else {
so.setVolume(100);
the_controls.sound_btn.gotoAndStop(1);
m = 0;
}
};