Pausing and resuming a looping sound

Hello all,

I am currently working on a class to control sound. Having tried various work arounds for the looping, it seems that I will only get a loop with out a break if i pass a looping parameter to the sound channel object.

Here lies my problem. When i paused the sound, i save the playback position into a variable, audioProgress.

I would resume the sound by using

 sndPlayback = sndSound.play(audioProgress, 2147483647);

This causes a problem such that if you let the loop play for a while, the number in audioProgress becomes rather big, and trying to resume will cause the authoring environment to crash. In addition to that, pausing and resuming the sound causes the sound to loop from that position offset.


private function stopAudio(event:MouseEvent):void{
   audioProgress = sndPlayback.position;
   sndPlayback.stop();
   stopbtn.buttonMode = false;
   stopbtn.removeEventListener(MouseEvent.CLICK, stopAudio);
   trace(audioProgress);
   playbtn.buttonMode = true;
   playbtn.addEventListener(MouseEvent.CLICK, playAudio);
}
		
private function playAudio(event:MouseEvent):void{
   sndPlayback = sndSound.play(audioProgress, 2147483647);
			
   playbtn.buttonMode = false;
   playbtn.removeEventListener(MouseEvent.CLICK, playAudio);
			
   stopbtn.buttonMode = true;
   stopbtn.addEventListener(MouseEvent.CLICK, stopAudio);
}

Any ideas appreciated.

Cheers :smiley: