A Flash Developer Resource Site

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

Thread: please help me with mp3 player...

  1. #1
    Member
    Join Date
    Aug 2003
    Posts
    30

    please help me with mp3 player...

    I have made and mp3 player that the design expands and contracts the mp3 player like "itunes". It also has a "drag" on it so you can move the player around.

    When you open the player it plays the 1st song straight away, which is fine, BUT when u contract the player then re-open it plays its self again, but u are hearing both at the same time but one delayed. This also screws up the buttons as well.

    Any ideas how I can make this wk the way it should?

    I originally used a tutorial to get as far as making it work, my additions were the "drag" & "contract & expand".

    Driving me nuts....please help me?

    To explain it easier, here is my fla.
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    Aug 2003
    Posts
    30
    I posted this before in the "actionscript forum", didnt see the "sound and music forum". I hope I have better luck here.

  3. #3
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    unfortunatly, I dont have time to look at your FLA, maybe someone else can.

    -----
    BUT when u contract the player then re-open it plays its self again, but u are hearing both at the same time but one delayed. This also screws up the buttons as well.
    -----
    To me this sounds as if the code to expand and contract the interface is reloading the sound. Review the code and make sure it does not re-execute a function or replay a frame containing your code to load sound.

  4. #4
    Member
    Join Date
    Aug 2003
    Posts
    30
    here is the code where I think the problem is...."I think". I am not sure how to root the problem out. Still a novice, I am.

    I have used so many diffrent tut's for this, but wish I took note who done what & from where.


    CONTRACTED PLAYER

    1st frame

    on (press) {
    gotoAndPlay(2);
    }



    EXPANDED PLAYER

    Action Layer/Frame 2

    radioVisible = false;


    Music Layer/Frame 2

    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();

    -------------------------------------BUTTONS------------------------------------------

    PLAY BUTTON

    2nd frame


    //play button
    on (release) {
    //Play button.
    //Sound is not playing and has not been paused
    if (playing!=true) {
    if (paused!=true) {
    playing=true;
    paused=false;
    stopped=false;
    myConditionText="playing";
    s.start(0,0);
    }
    //Sound has been paused
    if (paused==true) {
    playing=true;
    paused=false;
    stopped=false
    s.start(myMusicPosition,0);
    myConditionText="playing";
    s.onSoundComplete = function() {
    s.start();
    }
    }
    }
    }


    GRIP "on contracted player"

    1st frame


    on (press) {
    startDrag(getProperty(_x, _y));
    }
    on (release) {
    stopDrag();
    }

    --------------------------------------

    Thanks reading to blubering desperation, be easy on me...Cheers

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Maybe you can check in the EXPANDED PLAYER Music Layer/Frame 2 if sound is already there:

    if (Number(s.getBytesTotal)>0){
    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();
    }

    I dont know if this actually works, dont have Flash near by to test it

  6. #6
    Member
    Join Date
    Aug 2003
    Posts
    30
    Hi Tonypa, u made my day just replying!!!. I tried the code, but still seems to have the same problem of the song playing over each other when expanded the 2nd time.

    I feel real close finishing this but its just this hurdle. Very frustrating, better have a coffee to wake up a little.

  7. #7
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Silly me, the code should of course read

    if (Number(s.getBytesTotal)==0){

    The idea being if that sound object already exists and has some size (its getBytesTotal property is bigger then 0), then it wont start new instance.

  8. #8
    Member
    Join Date
    Aug 2003
    Posts
    30
    Ok, I think we are nearly there (WaaHoo!). It wks Tonypa, with the first song. Now what happens is that if you play the next track & u contract then expand it has the same problem as before. Repeting it self...

    would I use this:

    if (Number(s.getBytesTotal)==0){

    for the other tracks in the timeline. I have 16 frames and in each frame has except frame 2.

    Music Layer/Frame 2

    if (Number(s.getBytesTotal)>0){
    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();
    }

    Music Layer/Frame's 3/4/5/6/etc....

    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();

    Music Layer/Frame 2

    if (Number(s.getBytesTotal)>0){
    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();
    }


    thanks Tonypa

  9. #9
    Member
    Join Date
    Aug 2003
    Posts
    30
    please ignore the last piece of code, got triger happy with cut n paste.

    Music Layer/Frame 2

    if (Number(s.getBytesTotal)>0){
    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();
    }


    Sorry...

  10. #10
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    Code:
    if(!s) { // check if s does not exist as variable
      // code to make sound object
    }

  11. #11
    Member
    Join Date
    Aug 2003
    Posts
    30
    sorry, Im not sure, Im with you there. Can you please show me how it should be written out?. Or are you saying to replace this line on Music Layer/Frame 2?.

    if (Number(s.getBytesTotal)==0){

    with

    if(!s) {
    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();
    }

  12. #12
    Member
    Join Date
    Aug 2003
    Posts
    30
    Tonypa, sorry this is what I put in, just in case you thought I didn't do it right.

    Music Layer/Frame 2

    if (Number(s.getBytesTotal)==0){
    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();
    }

    Music Layer/Frame's 3/4/5/6/etc....

    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();

    wks for the first track, now the same old problem has jumped to the next track in frame 3 & plays while the 1st song is playing if you skip to the second track.

    here is the fla, with the new changes. I hope it would show you what I mean.


  13. #13
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Well, as hp3 pointed out, and I trust him on this more then myself, you can probably replace the line

    if (Number(s.getBytesTotal)==0){

    with much simpler

    if(!s) {

    like you did in previous post.

    But surely you have to add the if statement in every frame. The idea of including sound creation code into if statement, is to check first if such sound already exists (and might be playing) and only if it doesnt, you make new sound. If you have 16 frames, then you need to change code in all 16 frames

  14. #14
    Member
    Join Date
    Aug 2003
    Posts
    30
    something is still funny here, its wking like you said, but only the first song in frame 2.

    When "frame 2" is playing the song and I try going to the "next" song. It doesn't play at all or any other after "frame 2". In the "currenTrack" display says "my_music.mp3", which Im guessing its just held up in frame 2. Instead of going to frame 3 to play "my_music_2.mp3" and so on to frame 16.

    Is it because my action for my next button needs to be modified for the the new if statement?. I have feeling ur gonna laugh there.


    //next button
    on(release) {
    nextFrame();
    s.stop();
    myConditionText="playing";
    }

    This is what I have fro all 16 frames

    if(!s) {
    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();
    }

    could you please have a look at my fla and just inspect the mess Ive created?. I feel maybe Im explaining the problem real crap.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    I think we are chasing the tiger's tail here. Instead of trying to solve this problem piecmeal, please tell us the concept of your player.

    Why do you have 16 frames each creating a new sound object?

  16. #16
    Member
    Join Date
    Aug 2003
    Posts
    30
    o.k, I got frankienstien'd this tutorial, which I manged to have a wking mp3 player with:

    Music Layer/Frame 1/2/3/4....

    s = new Sound();
    s.loadSound("my_music.mp3", true);
    currentTrack="my_music";
    stopped=false;
    paused=false;
    stop();

    SO what I wanted to do was to design a expand and contract type of player. Just like itunes when "itunes & winamp" when u minimise the player & maximise.

    So the features I added was the expanded part to the design and the grab.

    And the rest is history....

    All I want to do is open and close the iterface while the selected song is playing, without the prob of playing over another and just play normal as you would expect it should do.

    I have been working on my little flash site. And you can see what I mean. But I haven't uploaded any mp3's to the serevr. Maybe it will give you the general idea.


    you will see the player in the left side corner. If you click on review and select any review. You can see why its important to contract the player.

    Please not this sit is in working progress. Feel fre to comment on the site as well

    If you do know a better way how this player should wk, I would love to know

    cheers
    Last edited by toodave; 09-19-2003 at 06:19 PM.

  17. #17
    Member
    Join Date
    Aug 2003
    Posts
    30
    oh yea...I don't mean to frustrate you guys, as I know Im starting to be a pain in the ass for this. Appreaciate sticking it out with me.


  18. #18
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    if all you are doing is to expand and contract an interface why do you need 16 frames?

    What are the 16 frames for?

    I can understand 2 frames, one for contracted and one for expanded, but what are the other 14 frames for?

  19. #19
    Member
    Join Date
    Aug 2003
    Posts
    30
    well I got 16 tracks I want to play, I figured that when you select nxt track it will jump from the current frame to the next to start to play the nxt track or if you selct previous, same rule applies.

    wont that wk?

    I have a bad felling about this.......

  20. #20
    Member
    Join Date
    Aug 2003
    Posts
    30
    this is what I had origianlly:

    frame 2

    s = new Sound();
    s.loadSound("my_music1.mp3", true);
    currentTrack="my_music1";
    stopped=false;
    paused=false;
    stop();

    frame 3

    s = new Sound();
    s.loadSound("my_music2.mp3", true);
    currentTrack="my_music2";
    stopped=false;
    paused=false;
    stop();

    frame 3

    s = new Sound();
    s.loadSound("my_music3.mp3", true);
    currentTrack="my_music3";
    stopped=false;
    paused=false;
    stop();

    frame 4

    s = new Sound();
    s.loadSound("my_music4.mp3", true);
    currentTrack="my_music4";
    stopped=false;
    paused=false;
    stop();

    and this goes upto frame 16. So the plan was to use a next and previous button with:


    //next button
    on(release) {
    nextFrame();
    s.stop();
    myConditionText="playing";
    }

    //previous button
    on(release) {
    prevFrame();
    s.stop();
    myConditionText="playing";
    }

    Does this explain what Im doing clearer?....am I really diigin my grave deeper?

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