Complete Event will not fire for Audio Player
jamestyner opened this issue · 1 comments
I have the following code and the "COMPLETE" event never fires. I have the com folder in the same directory as my .fla, and the awave.swc in my library path.
I am also getting "AUDIO CLIPPING" repeatedly traced out to the output panel. I changed the amplitude to 0.2 and even -5.0 it still plays just as loudly. I assume the amplitude is for the loudness? I thought lowering it would make the "AUDIO CLIPPING" go away and maybe that has something to do with the "COMPLETE EVENT" not firing.
import com.noteflight.standingwave3.elements.*
import com.noteflight.standingwave3.filters.*
import com.noteflight.standingwave3.formats.*
import com.noteflight.standingwave3.generators.;
import com.noteflight.standingwave3.modulation.;
import com.noteflight.standingwave3.output.*
import com.noteflight.standingwave3.performance.;
import com.noteflight.standingwave3.sources.;
import com.noteflight.standingwave3.utils.*;
import flash.events.Event;
var player:AudioPlayer = new AudioPlayer();
play_btn.addEventListener(MouseEvent.CLICK,playSinewave);
function playSinewave(e:Event):void{
var sinewave:IAudioSource = new SineSource(new AudioDescriptor(),5,440,0.2);
play_btn.enabled = false;
player.addEventListener(Event.COMPLETE,doComplete);
player.play(sinewave);
}
function doComplete(e:Event):void{
trace("COMPLETE")
play_btn.enabled = true;
}
In the AudioPlayer constructor it adds a listener for SOUND_COMPETE and in the handler dispatches that same event so I'm guessing you should probably listen for that.
public function AudioPlayer(framesPerCallback:Number = 4096)
{
_sampleHandler = new AudioSampleHandler(framesPerCallback);
_sampleHandler.addEventListener(Event.SOUND_COMPLETE, handleComplete);
_progressTimer.addEventListener(TimerEvent.TIMER, handleProgressTimer);
}
private function handleComplete(e:Event):void
{
dispatchEvent(e);
_progressTimer.stop();
}