5 Replies Latest reply on Feb 8, 2008 6:30 AM by peterent

    flex sound can not resume at the place it stops

    jerryfleming
      I made a small flex application to load external mp3 and play it. Everything goes smoothly except resuming. I can never resume exactly at the place where I stopped. There is always an obvious gap. This is part of my code:
      quote:


      75 private function onPlay( ) : void // {{{
      76 {
      77 if(btnPlay.enabled)
      78 {
      79 //if(position > 0) position -= 1700;
      80 channel = snd.play(position);
      81 channel.addEventListener(Event.SOUND_COMPLETE, onPlayComplete );
      82 btnPlay.enabled = false;
      83 btnPause.enabled = true;
      84 }
      85 } // onPlay() }}}
      86
      87 private function onPause( ) : void // {{{
      88 {
      89 if(btnPause.enabled)
      90 {
      91 position = channel.position;
      92 channel.stop();
      93 channel.removeEventListener(Event.SOUND_COMPLETE, onPlayComplete );
      94 btnPlay.enabled = true;
      95 btnPause.enabled = false;
      96 }
      97 } // onPause() }}}


      it seems right, but when pause at, say, 1000, and play again, the position will mysteriously be changed somewhere ahead. I guess it is the cache system that cause the trouble, which prevent immediate reaction of all user events go on playing for some short period before it really stops.

      The question is that, how to avoid such a problem? How to resume exactly from my last stop position? It is driving me crazy! Thank you very very much.