dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Sound not playing in loaded swf!

  1. #1

    Sound not playing in loaded swf!

    I am making a preloader that determines when enough video is loaded to start playing (and continue loading) without the "playing progress" catching up to the "loading progress". I guess you could call it "simulated streaming".

    This is what I got so far:

    code:

    containerMC.loadMovie("http://www.musicbay.se/qmail/sf/themissing/themissing_trailer2.swf");
    this.onEnterFrame = function() {
    percent = (containerMC.getBytesLoaded()/containerMC.getBytesTotal())*100;
    if (!isNan(percent)) {
    if (percent == 0) {
    percent_display = "";
    } else {
    percent_display = "BUFFERING...";
    }
    loadbar._visible = true;
    loadbar._xscale = percent;
    containerMC.stop();
    }
    if (percent > 1) {
    //CALCULATE WHEN TO START PLAYING
    loading_speed = (containerMC.getBytesLoaded()/(getTimer()/1000))/1000;
    percent_display = "BUFFERING:" + Math.ceil(loading_speed) + "KBIT/S";
    playtime_loaded = (containerMC.getBytesLoaded()/(containerMC.getBytesTotal()/containerMC._totalframes))/25;
    loadtime_remaining = (containerMC.getBytesTotal()-containerMC.getBytesLoaded())/(containerMC.getBytesLoaded()/(getTimer()/1000));
    // START TRAILER
    if (playtime_loaded > (loadtime_remaining + 2)) {
    containerMC.play();
    video_playing = "yes";
    percent_display = "PLAYING, " + Math.ceil(loading_speed) + "KBIT/S";
    }
    }
    //STOP PRELOADER <-- PROBLEM RIGHT HERE
    if (percent == 100 && video_playing == "yes") {
    delete this.onEnterFrame;
    percent_display = "PLAYING";
    }
    };
    stop();





    This works well except for:

    The sound for the video doesn't play until the video is fully loaded and the:

    delete this.onEnterFrame;

    command is executed...
    The video file is a swf with one layer *.FLV video and one layer *.WAV sound.


    I'me very confused
    Thanks for any help!

  2. #2
    here is the fla. Please help!

  3. #3
    anybody?

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Frankly, I don't think that would work.
    Is the sound's Sync set to stream?

  5. #5
    Thanks for reply oldnewbie! Yes, the sound's sync is set to stream.

    Why don't you think it would work? The strange thing is that until the loading function is terminated, the pause/play/ff buttons controlling the mc don't work either.

    I saw this site yesterday, that streams movies exactly the way I want to, so it must be possible to get it to work (unless he's using communication server or some other technique that I'me unaware of).

    As you might have noticed, this is one of your preloaders posted on a thread somewhere around here, that has been modified.

    Any Ideas? Thanks! /Erik

  6. #6
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Seen that you made some progress in getting a playbar displayed...

    Check these...

    Although, they work fine on a fast connection (they could even be streamed from the beginning!), they will fail miserably on an average slow connection (checked them on my old 56k dial-up!), if you don't preload 80% and even more, before you have them start playing.

    http://blake.prohosting.com/~tektips/flvpreload1.html

    http://blake.prohosting.com/~tektips/flvpreload2.html

    You'll see that I'm using my preloader code to load 50 percent of the file, but then switch to another control clip to display the rest of the preloading. The container.stop(); bit is what is preventing your sound from playing until the whole thing as downloaded.

  7. #7
    Thanks for taking the time to help me Oldnewbie! Is it possible to get the *.FLA, just in case? Thanks!

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    In case?

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