14 Replies Latest reply on Jul 21, 2008 9:03 AM by colinod

    MP£ Player

    colinod Level 1
      I have made an mp3 player and am trying to forward the time by 20 seconds at the click of a button, i am trying to use the following code in different formats

      on(release) {
      cue = Math.round(s.position+1000);
      s.start(cue,1);
      }

      I just cant get it to work, the files can be downloaded at

      www.colinwebdesign.co.uk/mp3player.rar

      thanks
        • 1. Re: MP£ Player
          Shandy Elliott Level 1
          First, your code in frame 1 is incorrect. You need to change it to:

          s = new Sound();
          s.loadSound("thisisthe.mp3",true);
          gotoAndPlay("Playing");

          For your advance button, replace with this script.

          on (press) {
          //cue = Math.round(s.position + 1000);
          //s.start(cue,1);
          s.stop();
          trace(s.position);
          skipAmount = 2000;
          newPos = (s.position + skipAmount) / 1000;
          trace(newPos);
          }
          on (release) {
          s.start(newPos);
          trace(s.position);
          }

          You can remove the traces once you get an idea of how it works.
          • 2. Re: MP£ Player
            colinod Level 1
            Hi
            Thanks for that, it seems that if you click the button again it just goes to the end of the mp3 file, is that right,

            also the first line is like that because i am passing a variable from the page address to the swf file to determine the mp3 to be played,

            also if i wanted to go back by 20 seconds could i just change the + to a -
            • 3. Re: MP£ Player
              Shandy Elliott Level 1
              Every time I click the forward button, it skips 2 seconds, so I don't know what your difference would be. Try changing the publish settings to flash player 8 (at least flash player 6) and action script 2. For the back button, just use a negative skipAmount.
              • 4. Re: MP£ Player
                colinod Level 1
                Yes that was it i now have forward 10 and rewind 10 seconds at a time do you know if there is a way of getting the total length of the mp3 before it is all loaded at the moment the total time climbs as the file loads

                thanks
                • 5. Re: MP£ Player
                  Shandy Elliott Level 1
                  If you can wait until later tonight, I will show you how to make a better music player using netStream.
                  • 6. Re: MP£ Player
                    colinod Level 1
                    As long as i can make it look like the current one, it fits in with the website we have that will be cool
                    • 7. Re: MP£ Player
                      Shandy Elliott Level 1
                      I restructured your mp3 player while keeping the same elements as you had before. There is no reason to have additional frames for playing, etc. as you had before. The flash file is here, and you can view the results here. Let me know if you have any questions about what I did.
                      • 8. Re: MP£ Player
                        colinod Level 1
                        Thats fantastic, thanks a lot, the reason for not hard coading the mp3 file is that the site uses nearly 300 mp3 files to play various voiceover clips for various artists. If you look at the site you will see

                        www.yaketyyak.co.uk

                        Not sure we need the percentage bit but i am sure i can remove this from the code and the file, i have looked at the code and understand what most of it does, also the button you were not sure about is to forward the clip by 1 minute at a time, i know that the symbol is not really right but its what they have had on their players for about 4 years.

                        Thakns again
                        • 9. Re: MP£ Player
                          colinod Level 1
                          I do have one question, is it possible to have the seconds playing and seconds total show before the clip is totally loaded, if not can the clip not start playing until it is all loaded as it looks odd with no times and the sound playing??/

                          Thanks
                          • 10. Re: MP£ Player
                            Shandy Elliott Level 1
                            All you have to do is move the code around between the 2 functions. function checkStatus() is always running, so place anything you want to constantly be checked in that funtion. function checkTime() only is called when the current audio has fully loaded. If you go back to that link I gave you, you can re-download the flash file and see how I changed the code up. I had originally put that % in to show you how much was loading, but if you also notice, I added a copy of the mcPosition movie clip and renamed it mcPercentLoaded to display a visual of how much audio is loaded. I also hid the duration time until everything loads.
                            • 11. Re: MP£ Player
                              colinod Level 1
                              Absolutely perfect, and i now have a better understanding of actionscript, thanks for your help
                              • 12. MP£ Player
                                colinod Level 1
                                Hi againg, i have shown the player to the bosses at work and we were wondering if it is possible to show the total length of the mp3 before it has all loaded in

                                What we are really looking for is to have the time plaed counting up, no total time but to have the bar that goes across as the mp3 plays be visible and start moving when the clip starts to play

                                thanks
                                • 13. Re: MP£ Player
                                  Shandy Elliott Level 1
                                  You said you want to display the total length of the mp3 but then in the next sentence you said you don't want "total time". That doesn't make sense. If you do a search for flash and mp3 ID tags, there are options for you to retrieve certain data from the mp3. When you have a sound loading and streaming is set to true, flash cannot establish the length of the mp3 until the whole thing has loaded into cache. If you do another search for loading sounds using netSream and netConnection, you have a lot more options when it comes to controlling the sound and retrieving data from the sound file.
                                  • 14. Re: MP£ Player
                                    colinod Level 1
                                    Yes sorry the second sentence was an addition, the id3 tag thing should cure what i am looking for.

                                    I have tried adding the id3 tag info to a variable with the following

                                    var total_time = s.id3.TLEN;

                                    this does not seem to work all i get is undefined in the dynamic textbox that i have set to contain the variable total_time

                                    any ideas??