SoundChannel object plays small portion after being stopped and played again

Posted by gok on Stack Overflow See other posts from Stack Overflow or by gok
Published on 2010-06-05T19:50:47Z Indexed on 2010/06/05 19:52 UTC
Read the original article Hit count: 433

Filed under:
|
|
|

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(trimIn);
  volume(currentVolume);
  isPlaying = true;
  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();
  }
}

Do I need to somehow reset the soundChannel?

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript-3