2 Replies Latest reply on Dec 13, 2006 8:07 AM by JDRives

    Sound position incorrect with multiple MP3s

      Hi all, I have a slideshow that has a few different soundtracks that are loaded in dynamically depending on which slide is showing. I have a Pause button that pauses the slideshow and soundtrack and records the position of the soundtrack, so that when the Play button is pressed, the slideshow and soundtrack resume where they left off. The problem is that the Flash player records the position from the begining of the first soundtrack and doesn't restart from zero when a new soundtrack is loaded. So when the play button is pressed, the soundtrack offset gets further and further off depending on how long the slideshow has been running and how many soundtracks have loaded. In other words, if the first soundtrack is 30 seconds long , the second one is 120 seconds long, and the slideshow is paused in the middle of the second soundtrack, the position should be about 60,000, however it is returned as 90,000 because it includes the 30 seconds from the first soundtrack. Does anyone know a quick fix for this, short of creating new sound objects each time I load a new soundtrack? Thanks, JD
      Here is the pertinent code:

      mainSound = new Sound(soundtrack_mc);
      mainSound.setVolume (70);

      function pauseSlideshow(){
      pauseTime = mainSound.position;
      function playSlideshow(){
      startTime = pauseTime/1000;
      loadInterval = setInterval(fadeAndLoad, 4000);
        • 1. Re: Sound position incorrect with multiple MP3s
          I am having a similar problem.
          I just found a comment in livedocs by Mr.Physikoi , but don't really understand his point.. http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm ?context=Flash_MX_2004&file=00001682.html

          Maybe you have found a sollution?
          • 2. Re: Sound position incorrect with multiple MP3s
            JDRives Level 1
            Yes, I did solve this problem simply by creating a new sound object each time I needed to load a new soundtrack instead of loading the next soundtrack into the same sound object. Here is the function I created to load the next soundtrack. This function is being called by another function that checks an array to see if it's time to load the next soundtrack based on the number of the current image that is loading.

            You will notice that each time I load a soundtrack I create a new sound object. I keep the name of the object the same so all my other code still works. This is the line of code that creates the new sound object and puts it in the soundtrack movie clip each time I load a new soundtrack.

            mainSound = new Sound(soundtrack_mc);

            Here is the complete function:

            function fadeDownSoundtrack(endVol){
            setVol = mainSound.getVolume();
            if(setVol < 10){
            setVol = 80;
            soundtrack_mc.onEnterFrame = function(){
            startVol = mainSound.getVolume();
            if(startVol > endVol){
            mainSound.setVolume(startVol - 5);
            volFader1 = startVol;
            delete this.onEnterFrame;
            soundtrackNum += 1;
            mainSound = new Sound(soundtrack_mc);
            mainSound.loadSound(("MP3/Soundtrack-" + soundtrackNum + ".mp3"),true);
            mainSound.setVolume (setVol);
            volFader1 = setVol;

            Hope that helps. JR