Bonjour,
avant tout j'espère que je ne suis pas trop ambitieux dans ma requête . J'en demande peut etre un peu trop mais il y aura peu etre un pro de flash pour qui ca ne prendra que 2min, j'essaye.
Donc, sur mon blog, je mets en ligne des vidéos flv. Elle sont lues grâce à flvplayer.swf mais le problème c'est que les vidéos sont toutes chargés en même temps que la page, seulement je voudrais que la vidéo se charge lorsque que l'on clique sur play et pas avant.
J'ai trouvé le .fla du lecteur flv. Je me suis penché sur le code, fais plusieurs test mais pas trouvé de résultat. Si quelqu'un pourrait me dire les modifications à apporter.
Merci beaucoup
(Voici le code présente dans .fla)
//--------------------------------------------------------------------------
// a couple of variables you can change ..
//--------------------------------------------------------------------------
// toggle for which file to play if none was set in html
// you can change the 'test.flv' in your filename
!_root.file ? file = "video.flv" : file = _root.file;
// toggle for showing the fullscreen button
// you can change the 'false' in 'true'
!_root.showFs ? showFs = false : showFs = _root.showFs;
// toggle for aturostarting the video
// you can change the 'true' in 'false'
!_root.autoStart ? autoStart = true : autoStart = _root.autoStart;
//--------------------------------------------------------------------------
// from here it's just code and code ..
//--------------------------------------------------------------------------
// stage vars
this._visible = false;
Stage.scaleMode = "noScale";
Stage.align = "CC";
Stage.showMenu = false;
bw = 0;
// Create netstream:
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.setBufferTime(5);
// function to set the right size for the controlbar items
function resizeIt(w,h) {
// set videodisplay dimensions
videoDisplay._width = w;
videoDisplay._height = h;
videoDisplay._x = 150-w/2;
videoDisplay._y = 150-h/2;
// put videodisplay dimensions in vars
myX = videoDisplay._x;
myY = videoDisplay._y + videoDisplay._height;
myW = videoDisplay._width;
// resize the items on the left ..
leftBg._x = myX - 2;
leftBg._y = myY + 2;
playBut._x = pauseBut._x = myX + 10;
playBut._y = pauseBut._y = myY + 12;
// resize the items in the middle ..
centerBg._x = percentBar._x = progressBar._x = backBar._x = myX + 19;
centerBg._y = myY + 2;
percentBar._y = progressBar._y = myY + 10;
bw = centerBg._width = percentBar._width = progressBar._width = myW - 39;
// and resize the ones on the right ..
rightBg._x = myX + myW - 20;
rightBg._y = myY + 2;
muteBut._x = unmuteBut._x = myX + myW - 10;
muteBut._y = unmuteBut._y = myY + 12;
this._visible = true;
};
ns.onMetaData = function(obj) {
// Retrieve duration meta data
this.totalTime = obj.duration;
// set the right size for the videodisplay if metadata is found
if(obj.width != 0) { resizeIt(obj.width,obj.height); }
};
ns.onStatus = function(object) {
if(object.code == "NetStream.Play.Start" ) {
// set the right size for the videodisplay if playing starts
if (videoDisplay.width != 0) { resizeIt(videoDisplay.width,videoDisplay.height); }
} else if(object.code == "NetStream.Buffer.Full" ) {
// set the right size for the videodisplay if buffer is filled
if (videoDisplay.width != 0 && fs != true) { resizeIt(videoDisplay.width,videoDisplay.height); }
} else if(object.code == "NetStream.Play.Stop" ) {
// rewind and pause on stop
ns.seek(0);
ns.pause();
playBut._visible = true;
pauseBut._visible = false;
}
};
//attach videodisplay
videoDisplay.attachVideo(ns);
ns.play(file);
// build sound object
this.createEmptyMovieClip("snd", 0);
snd.attachAudio(ns);
audio = new Sound(snd);
unmuteBut._visible = false;
// mute button action
muteBut.onPress = function() {
audio.setVolume(0);
unmuteBut._visible = true;
this._visible = false;
};
// unmute button action
unmuteBut.onPress = function() {
audio.setVolume(100);
muteBut._visible = true;
this._visible = false;
};
// if autoStart=false it shows the first frame
// hide play or pause button
if (autoStart == true) {
playBut._visible = false;
} else {
ns.seek(0);
ns.pause();
pauseBut._visible = false;
}
// pause button action
pauseBut.onPress = function() {
ns.pause();
playBut._visible = true;
this._visible = false;
};
// play button action
playBut.onPress = function() {
ns.pause();
pauseBut._visible = true;
this._visible = false;
};
// file load progress
percentBar.onEnterFrame = function() {
loaded = this._parent.ns.bytesLoaded;
total = this._parent.ns.bytesTotal;
if (loaded == total && loaded>1000) {
percentBar._width = bw;
delete this.onEnterFrame;
} else {
percentBar._width = int(bw*loaded/total);
}
};
// play progress
progressBar.onEnterFrame = function() {
this._width = bw*ns.time/ns.totalTime;
};
// start playhead scrubbing
centerBg.onPress = function() {
this.onEnterFrame = function() {
scl = this._xmouse*this._xscale/bw/100;
ns.seek(scl*ns.totalTime);
};
};
// stop playhead scrubbing
centerBg.onRelease = centerBg.onReleaseOutside=function () {
delete this.onEnterFrame;
pauseBut._visible == false ? videoDisplay.pause() : null;
};
// fullscreen button placement
fsBut._y = 154 - Stage.height/2;
fsBut._x = Stage.width/2 + 132;
if (showFs == false) { fsBut._visible = false; }
// catch resizing of the canvas
myListener = new Object();
myListener.onResize = function () {
fsBut._y = 154 - Stage.height/2;
fsBut._x = Stage.width/2 + 132; };
Stage.addListener(myListener);
// fullscreen button action
fsBut.onPress = function() {
oldw = videoDisplay._width;
oldh = videoDisplay._height;
resizeIt(Stage.width,Stage.height);
fs = true;
this._visible = false;
};
fsBut.onMouseDown = function() {
if(fs == true) {
resizeIt(oldw,oldh);
fs = false;
this._visible = true;
}
};