dcsimg
A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: Looking to create a simple MP3 player

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    10

    Looking to create a simple MP3 player

    Hello!

    First post here

    Ok so I'm looking for help on creating (of if you know where I can get what im looking for) a small MP3 player for my website. All I want it to do it to start and stop the music playing. What I want is a very small player that has bars that move when the music is playing and then you click it, the music stops and the bars stop moving. [Thats the best as I can explain it!] I've seen one before somewhere but a I have no idea where.

    As for my knowledge of flash and actionscript, I have used flash a few times before and know the basics, and I can probably interpret actionscript using programming knowledge I already have.

    I just need help on where to start and what my code should be, preferably I would like to try and do it myself with a bit of help but I dont mind

    Thanks for any help!
    Feel free to ask more questions

    Edit: Whoops, forgot to do what the Guidelines said. I will be using Flash 8

    Ok well Ive got something started and I have an idea on how I should make it:

    What I have at the moment is a single line of bars like ||||||||||| (just the other way up) and every 5 frames there is a keyframe. Keyframe 1 has one bar and the next one 2 and so on and so on. What I was thinking of doing was copying that a few times to make that musib bar thing that jumps up and down and then making a script that randomizes what keyframe the movie plays up to on each bar and then loops back down to the beginning. Giving the impression that it is real. Then I was thinking of making it all into a sort of button where you can start and stop the music only and when it is stopped all the bars return to the single bar at the bottom (keyframe 1).

    So what do you think?
    Last edited by FranzH; 12-30-2007 at 03:33 PM.

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Using Flash 8, you should be able to use the video components. That could be a direction to start.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Could you explain that a bit more please if you don't mind

    I've been messing around a bit and I wrote this code:

    Code:
    	
    var rannumb:Number;
    
    do {
    
    
    rannumb = Math.random();
    if (rannumb > 50) {
    	rannumb = Math.random();
    }
    } while (rannumb > 50);
    
    gotoAndStop(rannumb);
    gotoAndPlay(1);
    What I was aiming for it to do was generate a random number, and then use that to play up to that frame. I have 50 frames so i set it to check if the random number is less then 50 or not.

    The only thing is that I don't know how to actually make it work and do its thing or if the random number is between 1 and 10 or 1 and 100, or even if it will work. All I did was try to adapt my Visual Basic knowledge to action script >.<

    Im pretty sure I have got the part where I want it to play upto 'rannumb' and then go back to 1. Also I need to loop the whole thing.

    Help appreciated
    Last edited by FranzH; 12-30-2007 at 04:26 PM.

  4. #4
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813

    ...Okay...This is untested but.....

    Let just say you have a movie clip named 'myMovie' and it contains 100 frames. You want to generate a random number that will return the playhead to one when the playhead reaches the random number. Okay let try this.

    Code:
    _root.attachMovie("theMovie", "myMovie", _root.getNextHighestDepth());
    myMovie.stop();  //Don't want it to start until we're ready
    
    //Generate a random number between 1 and total number of frames in the MC
    var frmStop:Number = Math.floor(Math.random() * myMovie._totalframes) + 1;
    
    //Adding one because it uses a zero index and there aren't any zeros for frame
    myMovie.play();
    myMovie.onEnterFrame = function(){
      if(myMovie._currentFrame => frmStop){
        //myMovie.gotoAndPlay(1); //To play it from the start
        myMovie.gotoAndStop(1);  //To return to the beginning and stop
      }
    }
    That code should load the movie, determine the total number of frames, and generate a number for it. When that number is reached, then it will stop the playhead and return it to frame one.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  5. #5
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Thank you Ill definitely be reading that code throughly and trying to understand where everything goes. Looks like I have a lot of things to learn about action script and how to integrate it with movies.

    Ill see if I can make the moving bars thing and once its done ill move onto getting music playing and then turning it and the bars on and off.

    Thank you for the great help ^_^

    PS. I meant to write 'wrong' after the last line in my previous message.
    Last edited by FranzH; 12-30-2007 at 06:48 PM.

  6. #6
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Edit: Sorry, message got duplicated (I edited it out) . Looks like my internet it playing up again.

  7. #7
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    No problem.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  8. #8
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Ok well I've got stuck making the bars into a movie clip and where to put the script you wrote.
    Would you like me to give you the .fla to check out?

    Sorry about the newbie questions. Ill be reading up from the beginning on Flash after my January A-Level exams comming up!

  9. #9
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    That is what we're here for....to help with the questions. Sure post the file and I'll look it over.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  10. #10
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Sorry for the late reply, been busy with new year and everything

    Here is my fla up to now. I made the bars pretty big since I didn't want to be working with very small images so then I can just shrink it when it is all done.
    Attached Files Attached Files

  11. #11
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Looks good.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  12. #12
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    So how would I go about applying that code you told me to those bars? I know how to make things into movie clips but not sure on how to do it on the whole set of bars

  13. #13
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Sorry, long night last night...are the bars suppose to represent the current volume level or act as a slider? (I'm still a little fuzzy)
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  14. #14
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Nope. Hmm, I don't know what they are called but you know when you play a song and you see about 10+ bars jumping to the music depending on the sound, in frequencies I believe.. for example in winamp. Im just trying to recreate one bar to look like one and then make a few of them to simulate the whole thing.

    Happy 08 by the way

  15. #15
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Edit: Sorry, it double posted again. I don't know why it does this >.<

  16. #16
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Huh....that interesting. I've never mimicked an equalizer. Let me think about this one.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  17. #17
    Junior Member
    Join Date
    Dec 2007
    Posts
    10
    Ok, no problem!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center