dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Streaming music slowing a movie

  1. #1
    Member
    Join Date
    Apr 2004
    Posts
    72

    Streaming music slowing a movie

    A few months ago I built a music player from scratch for my myspace page. I've recently started to design a website for a local band and the want music on their site. I figured I'd just use the same basic player in their site. The problem that I'm running into is that when the music is playing, the entire flash site slows way down (music is normal but the animations chug). Now that I've gone back and looked at my myspace verson (a lot less animated) it has the same problem. What could cause this?

    Here's how it works:
    I have two clips (A and B). ClipA.swf is the main movie that has an empty clip for the player. ClipB.swf is the player. It has a streaming mp3 file and all the player buttons in it. When music is picked in ClipA, ClipB is loaded into it and the music plays.

    Here are some possible answers to the problem:
    The frame rate of the main clip is 30fps while the frame rate of the player is 12fps. I didn't think that would be the issue as the main clip is what governs the frame rate but I tried changing ClipB to 30fps and the problem remained.

    Since the file is streaming, is the main clip slow because it is loading the music? I've noticed that as long as the music plays the movie is slow, but as soon a I hit "stop" (the clip is still there, just stopped) the movie goes back to normal speed.

    Lastly, I thought that maybe 30fps was just to fast for the internet. I tried testing the 30fps movie from both flash and online and the problem persisted. (the 12fps clip was online both times if it matters).


    Thank you in advance for an advice you might have.

  2. #2
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    are you loading native mp3s or mp3s in swf?
    aviarts.com - web development and flash development

  3. #3
    Member
    Join Date
    Apr 2004
    Posts
    72
    It's an mp3 in a swf. here is a link to one of the music files.

    http://www.thedfc.com/music/music01.swf

    this would be "clip b" in my example

  4. #4
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    If your sound is in a keyframe set to stream sync then the flash player behaves differently than it normally would. stream sync requires the player to sync graphics and sound. If Flash cannot render a frame in time to keep up with sound it will drop the frame.

    So my guess is that stream sync is the culprit.

    Some alternatives:
    - set the sound to event sync, though it must download completely before playing.
    - try progressive loading a native mp3 instead, though if you stream a native mp3 it may behave the same way, but you would need to test.
    - try fully loading a native mp3 instead of streaming it.
    aviarts.com - web development and flash development

  5. #5
    Member
    Join Date
    Apr 2004
    Posts
    72
    What do you mean by progressive loading the native mp3? Like having a preloader that starts the movie at, say 30%? Could you explain further if I'm wrong. I was trying to avoid totally loading the clip first but if that is what it takes, so be it I suppose. Thanks for your help.

  6. #6
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    When people refer to flash "streaming" they really mean progressive loading, which means that Flash is loading the song while is plays. True streaming is a little different, so I've gotten into the habit of saying progressive load instead of streaming.

    Anycase, you can progressively load mp3 through the sound object loadSound() method.

    so = new Sound();
    so.loadSound("urlto.mp3",true); // true means progressive load

    Flash will load the mp3 as it plays rather than waiting for the entire mp3 to load first. Most importantly, the mp3 does not need to be wrapped in a swf, you can just load mp3 on its own.

    Again I am not sure if progressively loading mp3 will cause the sound/graphic sync behavior. Let us know how this works out.
    aviarts.com - web development and flash development

  7. #7
    Member
    Join Date
    Apr 2004
    Posts
    72
    Ok, I think I see what you mean. I'll mess with it and see what happens. Now, this presents me with a new issue. Sorry, but I don't work with sound much. My music player is based on the mp3 having its own swf. This way I can play/pause/scrub through the clip by finding the current frame when it is paused and playing from that frame when it is started again. If I use your method, how can I control the play/pause part? I suppose I don't need a trackbar, but it would be nice.

  8. #8
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    Here is a tutorial on building a basic streaming mp3 player.
    http://www.sonify.org/home/feature/r...026_mp3player/
    aviarts.com - web development and flash development

  9. #9
    Member
    Join Date
    Apr 2004
    Posts
    72
    Hey, that is perfect. Thanks a lot. I'll be sure to post what I find in a few days.

  10. #10
    Member
    Join Date
    Apr 2004
    Posts
    72
    Ok, I used that tutorial and it worked like a charm. The movie plays at regular speed and doesn't seem to have an strange quirks, at least so far. Thank you so much!

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