A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 36

Thread: How to create a music player

  1. #1
    Junior Member
    Join Date
    Oct 2002
    Posts
    23

    How to create a music player

    I was wondering if anybody knew how to create a music player complete with a Play button, Stop button, Next button ,Previous button and a small area containing the song name, similar to the one located at www.ChristinaMilian.com .

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    u need to work with action script for that:

    files= new array("file1.mp3","file2.mp3","file3.mp3")
    now=0
    vol=100
    soundPlaying=new sound()
    soundPlaying.attachSound(files[now])

    now we r ready for the buttons:
    play button:
    Code:
    on(press){
    soundPlaying.play()
    }
    stop:
    Code:
    on(press){
    soundPlaying.stop()
    }
    next:
    Code:
    on(press){
    soundPlaying.attachSound(files[(++now)%files.length])
    soundPlaying.play()
    }

    back:
    Code:
    on(press){
    now--;
    if(now<0){
    now=files.length
    }
    soundPlaying.attachSound(files[now])
    soundPlaying.play()
    }
    vol + button:
    Code:
    on(press){
    vol=vol+5
    soundPlaying.setVolume(vol)
    }
    vol - button:
    Code:
    on(press){
    vol=vol-5
    soundPlaying.setVolume(vol)
    }
    mey the swartz be with you

    http://www.amirlotan.com

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    the first lines u need to put in the first frame
    mey the swartz be with you

    http://www.amirlotan.com

  4. #4
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    thanks for the help.. still a bit of trouble though because i'm not an advanced user.. but i'm guessing i have to replace some things with my filenames i'm just not sure where they go. could you help out a bit more please?

  5. #5
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    what u need to do is to put
    Code:
    files= new array("file1.mp3","file2.mp3","file3.mp3")
    now=0
    vol=100
    soundPlaying=new sound()
    soundPlaying.attachSound(files[now])
    in the first frame of the movie.
    in the first line u change the file1.mp3 etc.. to the file name u have let say hello.mp3.

    then u add to every button the code that i wrote
    mey the swartz be with you

    http://www.amirlotan.com

  6. #6
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    hmmm... i did everything exactly the way you said it but it doesn't seem to be working when i test it. have you tried it to see if it works? and if so, could you please create it for me and send it to me so all i have to do is add my music into it?

  7. #7
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    it will be easyer if u send me yours, just the fla file
    mey the swartz be with you

    http://www.amirlotan.com

  8. #8
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    well when i save the file with my mp3s attached it becomes 133MB.. so do you want me to give you the .fla file without the mp3s attached?

  9. #9
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    like i wrote before, just the fla file
    mey the swartz be with you

    http://www.amirlotan.com

  10. #10
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    here it is
    Attached Files Attached Files

  11. #11
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    u forgot to tell me that u r working with mx.

    now it's woking
    Attached Files Attached Files
    mey the swartz be with you

    http://www.amirlotan.com

  12. #12
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    ok now i have another problem... when i test the music player it gives me this message:

    Error opening URL "file:///C|/Documents%20and%20Settings/Pierce%20Selman/Desktop/1.mp3"

    now even though i replaced your 1.mp3 with my file it still came up as 1.mp3. but then when i hit the "next" button on the music player, it gives me this message:

    Error opening URL "file:///C|/Documents%20and%20Settings/Pierce%20Selman/Desktop/blah blah.mp3"

    "blah blah" representing the filename of my mp3. but the thing is, the mp3 that i specified isn't located on my desktop so i don't know why it's going there to locate it. can you help?

  13. #13
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    u need to put all the mp3 and the fla and the swf in the same directory for it to work
    mey the swartz be with you

    http://www.amirlotan.com

  14. #14
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    ok. it worked but when i test it i still get the error message saying it cannot find 1.mp3. do you know why it could be doing that? and if i wanted to put this on the web would i have to import the files to the library?

  15. #15
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    and is there any way of showing the artists and title of the song as they are being played?

  16. #16
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    also, when i add my 3 songs and test it and hit the "back" button, it gives me the following message:

    Error opening URL "file:///C|/Documents%20and%20Settings/Pierce%20Selman/Desktop/"

    do you know what could be causing that? and dont worry about helping me with the "Error opening URL "file:///C|/Documents%20and%20Settings/Pierce%20Selman/Desktop/1.mp3"" problem because i fixed it. and by the way i appreciate all of your help, thanks ALOT!

  17. #17
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    by the way, you have a very nice site... i just checked it out.. i dont understand one word on the site, but it's nice!!

  18. #18
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    10x about the site,
    about the names, u should make an array to put all the names or u can change the names of your mp3 to be the names example:
    "britny sprears - hoops i did it again.mp3"

    and then take the name and show it.

    about the import don't do that don't import nothing to the fla it's not the idea of the function.
    about the back change it to this:
    Code:
    on (press) {
    	_root.now--;
    	if (now<0) {
    		_root.now = files.length-1;
    	}
    	soundPlaying.stop()
    	soundPlaying.loadSound(files[now]);
    	soundPlaying.play();
    }
    mey the swartz be with you

    http://www.amirlotan.com

  19. #19
    Junior Member
    Join Date
    Oct 2002
    Posts
    23
    wow it worked!! thats good! but i'm not exactly sure how to do the names thing. could you explain it please?

  20. #20
    Senior Member
    Join Date
    Jan 2001
    Posts
    1,017
    write in the first frame:
    names= new array("britny spears - oops","u2 - one","bla - bla")
    songName=names[now]


    and make a box that get a varible: songName

    that's it
    mey the swartz be with you

    http://www.amirlotan.com

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