17 Replies Latest reply on Jun 7, 2007 7:16 PM by Newsgroup_User

    Soundbyte Mp3 List

    Vox
      Hi everyone. Im working on a project right now where I have about 70 small sample mp3s (basically soundbytes) that users can listen to. What i have done is just have the name and artist load from a text file and have a play/stop toggle button next to each. My toggle button is in its own MC called musicButtons with a play button on the first frame and a stop button on the second. Actionscript on the first frame I have:

      stop();

      var mySound:Sound = new Sound();
      mySound.loadSound("samples/Track No01.mp3", false);


      and code i have on the play button is:

      on (release){
      mySound.start();
      nextFrame();
      }


      Where Im getting confused now is I need this toggle button for 69 more songs but i cant just keep dropping another instance of the same MC on stage and change the code as it will change for all of them. Do i have to duplicate this MC 69 times, place it on the stage and change the actionscript for each? I hope this makes sense.
        • 1. Re: Soundbyte Mp3 List
          kglad Adobe Community Professional & MVP
          you just need to have access to all the mp3 file names. and you need to decide how you want your project to work.

          for example, do you want to use a textfield that lists your mp3 and have your user select one and then press a play button or select one and have it play automatically?

          or have your user selct an mp3 from a dropdown (or combobox) and then press a play button or select one from a dropdown and have it play automatically?

          or do you want to have 70 buttons on-stage with the mp3 listed next to the button (placed by actionscript to avoid the tedium of placing buttons on-stage in the authoring environment) ?

          or something else?
          • 2. Soundbyte Mp3 List
            Vox Level 1
            well like i said, the way i have it now is that the song/artist just load in from text files I have. Displays in list format. I then have a toggle button next to each song/artist, where i just wanted the user to hit the play button next to each to listen to a clip. I have it set up so the text files are on different frames where it displays 10 songs and artists per frame, with a next and previous button to scroll through the lists. Reason I have it like this is because space is limited and 70 songs is a lot to have going down a page. So basically I guess im looking at your last option of placing these toggle buttons on stage with actionscript.

            I cant figure out how to use the same MC with the play/stop toggle in it over and over without making copies of it and dragging them on stage separately when the code to load the song is also inside that MC.
            • 3. Re: Soundbyte Mp3 List
              kglad Adobe Community Professional & MVP
              then you'll use attachMovie() to attach your buttons. i'm not sure what you're calling a toggle button but in this context that would usually be a button that alternately stops and starts your sound.

              now, by "list" do you mean you have a list component on each of your frames and that list is populated with songs and artists and you have the data property of list item set to your file path/name?
              • 4. Re: Soundbyte Mp3 List
                Vox Level 1
                the toggle button does start and stop the sound, but the way its setup is in an mc with 2 frames. A play button on the first frame and stop button on the second. the first frame has this code:

                stop();

                var mySound:Sound = new Sound();
                mySound.loadSound("samples/Track No01.mp3", false);

                first frame the play button has this code:

                on (release){
                mySound.start();
                nextFrame();
                }

                Second frame, stop button has this code:

                on(release){
                mySound.stop();
                prevFrame();
                }

                The list is a dynamic text box on each frame and the text loads from a text file. I then have actionscript code setup so it formats it into a list display. The code is as follows:

                • 5. Re: Soundbyte Mp3 List
                  Vox Level 1
                  I put up a sample of what i have now and you can actually see what ive done.
                  http://www.abentertainment.ca/test/weddings.html
                  • 6. Re: Soundbyte Mp3 List
                    kglad Adobe Community Professional & MVP
                    and what are the path/file names?
                    • 7. Re: Soundbyte Mp3 List
                      Vox Level 1
                      not sure im following. Path/file names to what?
                      • 8. Re: Soundbyte Mp3 List
                        kglad Adobe Community Professional & MVP
                        to your mp3s that you want to load. or, how do you derive the path/file names from the data that you've shown is loaded?
                        • 9. Re: Soundbyte Mp3 List
                          Vox Level 1
                          the mp3s are all in one folder "samples/Track No01.mp3" numbered from TrackNo01.mp3 to TrackNo80.mp3, is that what you wanted?
                          • 10. Re: Soundbyte Mp3 List
                            kglad Adobe Community Professional & MVP
                            and how are you going to generate those file names given the frame number of the active list and the line number of the list item that a user clicks?

                            for example, if you have 10 items per list and the lists are on frame 5,10,15,..,40 the file names can be derived (assuming No01-No10 is on frame 5,...,No71-No80 are on frame 40).
                            • 11. Soundbyte Mp3 List
                              Vox Level 1
                              im kind of getting lost a little here. I just added all the songs and artists to text files. I place the buttons on the stage and sort of guess align them to the text that gets loaded which displays the song and artist. Then I would have the buttons load the corresponding song in the list. I know this is completely wrong and trying to find the right way to go about this. Heres a zip file that includes the fla of what I have done and it includes all the text files for the song/artists.

                              link
                              • 12. Re: Soundbyte Mp3 List
                                kglad Adobe Community Professional & MVP
                                here's your correct fla: http://www.gladstien.com/Files/Samples.fla

                                i changed your sound loading to streaming because you don't have a preloader for you sound nor an onLoad method so you won't know when to start your sound.

                                also, you're probably going to have trouble with those file names because they have a space between Track and No.

                                all the coding i added is on the buttons layer in songList_mc.
                                • 13. Re: Soundbyte Mp3 List
                                  Vox Level 1
                                  OMG!!! kglad your a champ! thank you so much! I will remove all spaces in the track names and in the code as well.

                                  There are a couple things that seem buggy. I love how you have it so you can just press play on another sample and the previous one stops. When you first test the movie and hit play on a track and continue pressing play on different ones it is flawless, but if you press play on one song go to another and then go back to play the same track you have played already its almost as if you have to double click it to play. Also if you have a song playing and then hit the next or previous buttons it doesnt stop the song.
                                  • 14. Re: Soundbyte Mp3 List
                                    kglad Adobe Community Professional & MVP
                                    ok, those problems have been fixed. same link for the updated file.
                                    • 15. Re: Soundbyte Mp3 List
                                      Vox Level 1
                                      excellent. Now your just gonna hate me but there was another thing I forgot to mention in my last post. the last set of songs where it displays 5 songs only. There are 3 extra toggle buttons there that load mp3s. I need to rid of those last 3 buttons.
                                      • 16. Re: Soundbyte Mp3 List
                                        kglad Adobe Community Professional & MVP
                                        add keyframes to frames 7 and 8 of songlist_mc buttons layer and attach the following:

                                        • 17. Re: Soundbyte Mp3 List
                                          Level 7
                                          Vox wrote:
                                          > Hi everyone. Im working on a project right now where I have about 70 small
                                          > sample mp3s (basically soundbytes) that users can listen to. What i have done
                                          > is just have the name and artist load from a text file and have a play/stop
                                          > toggle button next to each. My toggle button is in its own MC called
                                          > musicButtons with a play button on the first frame and a stop button on the
                                          > second. Actionscript on the first frame I have:
                                          >
                                          > stop();
                                          >
                                          > var mySound:Sound = new Sound();
                                          > mySound.loadSound("samples/Track No01.mp3", false);
                                          >
                                          >
                                          > and code i have on the play button is:
                                          >
                                          > on (release){
                                          > mySound.start();
                                          > nextFrame();
                                          > }
                                          >
                                          >
                                          > Where Im getting confused now is I need this toggle button for 69 more songs
                                          > but i cant just keep dropping another instance of the same MC on stage and
                                          > change the code as it will change for all of them. Do i have to duplicate this
                                          > MC 69 times, place it on the stage and change the actionscript for each? I hope
                                          > this makes sense.
                                          >
                                          why not leave the 1 button on stage as a placeholder/instance, and at
                                          runtime dynamically create the buttons using an array,

                                          Create 1 class to manage the loading, and have it instance/loop through
                                          your file at runtime until it gets to the end, on each loop
                                          create an instance of the movie clip, and save it to an array
                                          of soundbyte clips, in the class extent the movieclip to hold the name,
                                          etc.. and in the class that manages the loading, you can use it to
                                          place the movie clips in the right place,
                                          Look at the flash video showcase example!


                                          matt