Hi all I have a media player code that intends to Cross fade files as the one playing comes close to its end (filelength - dt) , and start playback of the next one just before the end. To get it right (optimize var dt) I tried to trace the position of the file. But get impossible values - the position seems to shift forward as time passes…
function LoadNext_T(e:Event = null):void // set next theme
{
if (A_play) {
nextA = new Sound();
nextA.addEventListener(Event.COMPLETE, PlayNextTheme,false, 0, true);
nextA.load(gettheme);
}
else {
nextB = new Sound();
nextB.addEventListener(Event.COMPLETE, PlayNextTheme,false, 0, true);
nextB.load(gettheme);
}
if( (SC_A != null ) && SC_B != null)) {Xfade();}
}
function PlayNextTheme(e:Event):void
{
if (A_play) {
ThemeLong = nextA.length;
SC_A.soundTransform = volumeform_AB;
}
else {
ThemeLong = nextB.length;
SC_B.soundTransform = volumeform_AB;
}
var timer_AB: Timer = new Timer(ThemeLong - dt,1);
if (special conditions met) {
timer_AB.addEventListener(TimerEvent.TIMER, LoadNext_T,false, 0, true);
timer_AB.start();
}
function Xfade(): void
{
trace("SC_A pos = " , SC_A.position;);
trace("SC_B pos = ", SC_B.position;);
// start of some crossfade code //
}
WIth code as above - I get the surprising result that the positions traced in Xfade are LOWER than the Event argument ThemeLong -dt; that seems very odd, running through code usually takes time ??
Eg, Themelong is 20000ms dt is 500 ms I get outputs like 19345 etc, that is shorter than the supposed position at which the timer timer_AB is instructed to call the next Load function.
??
PLS advice,
Jaxz