Hello. I have a very tricky problem with a video player made which uses cs3 as. I’m don’t know as3 and I did not make the player, but I have the source.
The problem is that the player automaticaly loads the first frame of the .flv instead of displaying a screenshot until the user decides to play it. It looks good, but the automatic loading of the 1st frame is a real burden on the streaming server, because very time someone loads a page with the video player, it has to access the streaming server.
I think it has built in functions for screenshots, but I can’t seem to get them to work. All I have managed to do is to stop the .flv from being loaded on “startup” , i think.
Here’s the code :
titlu_arr[0] is the title
titlu_arr[1] is the flv address
titlu_arr[2] is the streaming server
titlu_arr[3] is the preload time variable (3)
titlu_arr[4] is the screenshot -----
playyButton._visible = false;
playyButton.yadr = playyButton._y;
pauseeButton.yadr = pauseeButton._y;
rewindButton.yadr = rewindButton._y;
loader.yadr = loader._y;
fundal_text.yadr = fundal_text._y;
bara.yadr = bara._y;
time_txt.yadr = time_txt._y;
time_txt2.yadr = time_txt2._y;
volumeSlider.yadr = volumeSlider._y;
mute.yadr = mute._y;
theVideo.wadr = theVideo._width;
theVideo.xadr = theVideo._x;
theVideo.hadr = theVideo._height;
theVideo.yadr = theVideo._y;
siglutza.xadr = siglutza._x;
siglutza.yadr = siglutza._y;
questii_txt.xadr=questii_txt._x;
questii_txt.yadr=questii_txt._y;
Stage.scaleMode = "noScale";
var EventListener:Object = new Object();
EventListener.onFullScreen = function(bFull:Boolean) {
if (bFull == true) {
fullscreen._visible = false;
fundal._alpha = 0;
var fundal_mc:MovieClip = _root.attachMovie("fundal2", "fundal2", 1);
xzero = Math.round(0-((Stage.width-477)/2));
yzero = Math.round(0-((Stage.height-425)/2));
fundal_mc._x = xzero;
fundal_mc._y = yzero;
fundal_mc._width = Stage.width;
fundal_mc._height = Stage.height;
fundal_mc.swapDepths(fundal);
playyButton._y = (yzero+Stage.height)-40;
pauseeButton._y = (yzero+Stage.height)-40;
rewindButton._y = (yzero+Stage.height)-40;
loader._y = (yzero+Stage.height)-29;
fundal_text._y = (yzero+Stage.height)-26;
bara._y = (yzero+Stage.height)-26;
time_txt._y = (yzero+Stage.height)-36;
time_txt2._y = (yzero+Stage.height)-36;
volumeSlider._y = (yzero+Stage.height)-40;
mute._y = (yzero+Stage.height)-26;
theVideo._width = Stage.width-40;
theVideo._x = xzero+20;
theVideo._height = Stage.height-80;
theVideo._y = yzero+25;
siglutza._x=xzero+Stage.width-75;
siglutza._y=yzero+50;
questii_txt._x=xzero+20;
questii_txt._y=yzero;
fundal2.useHandCursor=false;
fundal2.onRelease=function(){
Stage.displayState = "normal"
}
} else {
fullscreen._visible = true;
fundal._alpha = 100;
fundal.swapDepths(fundal2);
removeMovieClip(fundal2);
playyButton._y = playyButton.yadr;
pauseeButton._y = pauseeButton.yadr;
rewindButton._y = rewindButton.yadr;
loader._y = loader.yadr;
fundal_text._y = fundal_text.yadr;
bara._y = bara.yadr;
time_txt._y = time_txt.yadr;
time_txt2._y = time_txt2.yadr;
volumeSlider._y = volumeSlider.yadr;
mute._y = mute.yadr;
theVideo._width = theVideo.wadr;
theVideo._x = theVideo.xadr;
theVideo._height = theVideo.hadr;
theVideo._y = theVideo.yadr;
siglutza._x = siglutza.xadr;
siglutza._y = siglutza.yadr;
questii_txt._x = questii_txt.xadr;
questii_txt._y = questii_txt.yadr;
}
};
Stage.addListener(EventListener);
fullscreen.useHandCursor = false;
fullscreen.onRollOver = function() {
_global.follow_int = setInterval(follow, 30, "expl");
};
fullscreen.onRollOut = function() {
clearInterval(_global.follow_int);
_global.transp = 100;
expl._visible = false;
};
fullscreen.onRelease = function() {
Stage.displayState = Stage.displayState == "normal" ? "fullScreen" : "normal";
};
// --- Load ---
titlu_arr = titluri.split(",");
trace(titlu_arr);
questii_txt.text = titlu_arr[0];
// --- <Load Buffer >
var thumby:MovieClip = _root.createEmptyMovieClip("thumby",2000)
thumby._x=31;
thumby._y=54;
var thumbLoader:MovieClipLoader = new MovieClipLoader()
thumbloader.loadClip(titlu_arr[4],thumby);
addChild(thumby);
ns.setBufferTime(titlu_arr[3]);
ns.onStatus = function(info) {
if (info.code == "NetStream.Buffer.Full") {
bufferClip._visible = true;
}
if (info.code == "NetStream.Buffer.Stop") {
bufferClip._visible = true;
ns.seek(0);
}
if (info.code == "NetStream.Buffer.Empty") {
bufferClip._visible = true;
}
};
var nc:NetConnection = new NetConnection();
nc.connect(titlu_arr[2]);
var ns:NetStream = new NetStream(nc);
ns.play(titlu_arr[1]);//titlu_arr[1]
// --- </ Load Buffer >
theVideo.attachVideo(ns);
ns.pause()
playyButton._visible = true;
pauseeButton._visible = false;
// ---</Load>---
// ---<time left> ---
var time_interval:Number = setInterval(checkTime, 100, ns);
function checkTime(my_ns:NetStream) {
var ns_seconds:Number = my_ns.time;
var minutes:Number = Math.floor(ns_seconds/60);
var seconds = Math.floor(ns_seconds%60);
if (seconds<10) {
seconds = "0"+seconds;
}
time_txt.text = minutes+":"+seconds;
}
// --- <Buttons> ---
rewindButton.onRelease = function() {
ns.seek(0);
};
playyButton.onRelease = function() {
thumby._visible = false;
ns.pause();
playyButton._visible = false;
pauseeButton._visible = true;
};
pauseeButton.onRelease = function() {
ns.pause();
pauseeButton._visible = false;
playyButton._visible = true;
};
// ---</Buttons>---
// ---<Buffering>
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duration:Number;
ns.onMetaData = function(infoObject) {
/*playyButton._visible = true;
pauseeButton._visible = false;*/
for (var propName:String in infoObject) {;
trace(propName+" = "+infoObject[propName]);
}
duration = infoObject.duration;
var minutes:Number = Math.floor(duration/60);
var seconds = Math.floor(duration%60);
if (seconds<10) {
seconds = "0"+seconds;
}
time_txt2.text = minutes+":"+seconds;
};
function videoStatus() {
amountLoaded = ns.bytesLoaded/ns.bytesTotal;
loader.loadbar._width = amountLoaded*138;
loader.scrub._x = ns.time/duration*121;
}
var scrubInterval;
loader.scrub.onPress = function() {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit, 10);
loader.scrub.startDrag(false,-4,this._y,121,this._y);
};
loader.scrub.onRelease = loader.scrub.onReleaseOutside=function () {
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus, 10);
this.stopDrag();
};
function scrubit() {
ns.seek(Math.round((loader.scrub._x/121)*duration));
}
// ---</Buffering>---
// --- <Sound> ---
_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
vSound.attachAudio(ns);
var so:Sound = new Sound(vSound);
var volumeRange:Number = volumeSlider.volumeWedge._width-volumeSlider.volumeDot._width/2;
var soundLevel:Number;
volumeSlider.onPress = function() {
trace(_xmouse);
volumeSlider.volumeDot._x = _xmouse-343;
volumeSlider.volumeHit._x = _xmouse-343;
volumeSlider.volumeDot.startDrag(false,0,0,73,0);
volumeSlider.onEnterFrame = function():Void {
var v:Number = Math.round((this.volumeDot._x/volumeRange)*100);
volumeSlider.volumeHit._x = volumeSlider.volumeDot._x;
soundLevel = v;
so.setVolume(v);
if (soundLevel == 0) {
mute.gotoAndStop("mute");
} else {
mute.gotoAndStop("on");
}
};
};
volumeSlider.onRelease = function():Void {
stopDrag();
delete volumeSlider.onEnterFrame;
};
volumeSlider.onReleaseOutside = volumeSlider.onRelease;
mute.onRollOver = function() {
if (so.getVolume() == 0) {
this.gotoAndStop("muteOver");
} else {
this.gotoAndStop("onOver");
}
};
mute.onRollOut = function() {
if (so.getVolume() == 0) {
this.gotoAndStop("mute");
} else {
this.gotoAndStop("on");
}
};
mute.onRelease = function() {
if (so.getVolume() == 0) {
so.setVolume(100);
this.gotoAndStop("onOver");
} else {
so.setVolume(0);
this.gotoAndStop("mute");
}
};
// --- </Sound>---
// </load vars>
var expl_format:TextFormat = new TextFormat();
expl_format.font = "Arial";
expl_format.size = 12;
expl_format.color = 0xFFFFFF;
var expl:MovieClip = _root.createEmptyMovieClip("expl_mov", 1000);
expl._visible = false;
var expl_txt:TextField = expl.createTextField("expl_text", 1, 0, 0, 50, 20);
expl_txt.autoSize = true;
expl_txt.selectable = false;
expl_txt.text = "FULLSCREEN";
expl_txt.setTextFormat(expl_format);
expl_txt.embedFonts = true;
expl.beginFill(0xFFFFFF,25);
expl.lineTo(expl_txt._width,0);
expl.lineTo(expl_txt._width,expl_txt._height);
expl.lineTo(0,expl_txt._height);
expl.lineTo(0,0);
expl.endFill();
_global.transp = 100;
function follow(adresa) {
expl._visible = true;
expl._alpha = _global.transp;
trace(_global.transp);
eval(adresa)._x = _xmouse+10;
eval(adresa)._y = _ymouse;
_global.transp -= 1;
}
Thank you in advance for any suggestion. I’ve been trying blindly all kinds of combinations, but I’m not an as3 programmer