SoundChannel object is stopped and played again. When played again it plays small portion from the previous position and suddenly jumps back to the beginning. It doesn't play the whole sound before looping.
This happens only once, then it loops normally. It happens again if I stop and play.
public function play():void {
channel = clip.play();
timer.start();
channel.addEventListener(Event.SOUND_COMPLETE, loopMusic);
}
public function loopMusic(e:Event=null):void {
if (channel != null) {
timer.stop();
channel.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
play();
}
}
private function onTimer(event:TimerEvent):void {
if((clip.position >= trimOut || trimOut - clip.position < timerInterval/1000)) {
timer.stop();
loopMusic();
}
}
Do I need to somehow reset the soundChannel?