10 Replies Latest reply on Jun 9, 2006 3:10 PM by adrianTNT

    How to stop a sound from loading ? my_sound.unload or something ?

    adrianTNT
      I want the sound to stop loading when I press the stop button, I have:

      var my_sound:Sound = new Sound(_root);
      my_sound.onLoad = function() {
      my_sound.start();
      };
      preload_btn.onRelease = function() {
      my_sound.loadSound("some_sound.mp3", false);
      };
      stop_btn.onRelease = function() {
      my_sound.stop();
      };

      Say I click the "load" button, the sound starts loading, when I press the "stop" button the sound should stop playing but I also want it to stop loading, the sound keeps loading from given URL, it loads in background and making network traffic. I can only fix this by giving my sound an empty sound file to load, but it must be some other way, right? Something like my_sound.unload ?

      Thank you.
      Adrian.
        • 2. How to stop a sound from loading ? my_sound.unload or something ?
          adrianTNT Level 1
          So I guess this means there isn't an easy way like my_sound.unload.
          I think what you said should work fine by looking at your posts count (17197), so you are not a beginner :)
          Before I got your reply I found another solution, I created an empty file nosound.mp3 and each time I click the stop button I tell my_sound to load that empty sound instead of the sound is currently downloading. I needed this for the sounds player at FFILES.com

          Thank you.
          • 3. Re: How to stop a sound from loading ? my_sound.unload or something ?
            kglad Adobe Community Professional & MVP
            you're welcome. with your solution loading another mp3, are you sure it stops the download of the first mp3?
            • 4. How to stop a sound from loading ? my_sound.unload or something ?
              adrianTNT Level 1
              quote:

              Originally posted by: kglad
              you're welcome. with your solution loading another mp3, are you sure it stops the download of the first mp3?

              Yes, it seems to work fine, it loads another sound in same sound (my_sound) and it seems to replace loaded progress with the empty sound I gave and stops previous loading.
              I look at traffic icons on task bar and I see that there is no network traffic after I click "stop"; before this I could see continuous traffic while sound was loading in background.

              • 5. Re: How to stop a sound from loading ? my_sound.unload or something ?
                Level 7
                "adrianTNT" <adriantnt@adriantnt.com> wrote in message news:e6aitv$hkm$1@forums.macromedia.com...
                >
                quote:

                Originally posted by: kglad
                > you're welcome. with your solution loading another mp3, are you sure it stops
                > the download of the first mp3?

                > Yes, it seems to work fine, it loads another sound in same sound (my_sound)
                > and it seems to replace loaded progress with the empty sound I gave and stops
                > previous loading.
                > I look at traffic icons on task bar and I see that there is no network traffic
                > after I click "stop" before this I could see continuous traffic while sound was
                > loading in background.

                Yeah, I remember someone posted that solution a long time ago. It seems if you load a file with the same name the cache doesn't
                know any better and adjusts the download size to the smaller one. Maybe it's a good way to do it! Could it be a way to remove an
                mp3 from someone's cache after it plays? hmmmm Will have to do more testing.

                tralfaz


                • 6. Re: How to stop a sound from loading ? my_sound.unload or something ?
                  kglad Adobe Community Professional & MVP
                  i don't think it would work that way tralfaz. probably if the empty/dummy file had the same name as a previously cached file, the attempt to force a 2nd download (and overwrite the first) would result in the file being retrieved from the cache and not downloaded (and not overwritten).
                  • 7. Re: How to stop a sound from loading ? my_sound.unload or something ?
                    Level 7
                    "kglad" <webforumsuser@macromedia.com> wrote in message news:e6b0ri$2qu$1@forums.macromedia.com...
                    >i don't think it would work that way tralfaz. probably if the empty/dummy file
                    > had the same name as a previously cached file, the attempt to force a 2nd
                    > download (and overwrite the first) would result in the file being retrieved
                    > from the cache and not downloaded (and not overwritten).

                    Seems like I remember that it worked before because it was in a different folder on the server but I have to check it again, it's
                    been a long time.
                    tralfaz


                    • 8. Re: How to stop a sound from loading ? my_sound.unload or something ?
                      adrianTNT Level 1
                      As I said problem is solved now, seems to work fine, but since you talked about cache... I looked into my temporary internet files and kept refreshing the folder to see when the mp3 appears there, the large sound that is being loaded doesn't appear there if I clicked the stop button before it was completely loaded, then I clicked the stop button the my empty sound appears in temporary internet files (nosound.mp3). If I clicked stop and then clicked the load button again the large sound starts from zero (it has a preloaded so I can see this).
                      • 9. Re: How to stop a sound from loading ? my_sound.unload or something ?
                        kglad Adobe Community Professional & MVP
                        tralfaz and i are discussing a possible fix for preventing the caching of mp3 (and possibly swf) files which would be a great file-protection benefit to flash programmers.

                        for an mp3 to be protected you would need to append a large amount (for broadband users) of data to the end to prevent complete download while streaming through the part you wanted the user to hear. it's doable though.

                        for a swf you would also need to add a large amount of data to prevent complete download while the swf is streaming and you would need to close the browser window before the swf completes download. for linear timeline based swfs that's doable.
                        • 10. Re: How to stop a sound from loading ? my_sound.unload or something ?
                          adrianTNT Level 1
                          quote:

                          Originally posted by: kglad
                          tralfaz and i are discussing a possible fix for preventing the caching of mp3 (and possibly swf) files which would be a great file-protection benefit to flash programmers...

                          That would be nice :)