A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Sound: getBytesLoaded() == getBytesTotal(), but it isn't true!

  1. #1
    Senior Member
    Join Date
    Oct 2000
    Location
    Sweden
    Posts
    102

    Sound: getBytesLoaded() == getBytesTotal(), but it isn't true!

    I'm trying to preload external mp3:s into flash (isStreamed set to false), but the getBytesLoaded() won't give me the correct values.

    some times it works correct, but sometimes it says that the file is loaded although it isn't...

    Example: snd.getBytesTotal() gives me 11034 bytes, but sometimes snd.getBytesLoaded() returns 11034 bytes as well, even though it's still loading (if I check snd.duration I'll get 0 until the sound is truly loaded).

    It seems you'll get around the problem when setting isStreamed to true snd.loadSound("001.mp3", true), but that is not an option for me.

    Have you guys heard about this before? The only link I found that mentioned it was this:
    http://livedocs.macromedia.com/flash...=00001674.html
    /Tommy Salomonsson
    www.salomonsson.se

  2. #2
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    Code:
    snd = new Sound();
    snd.loadSound("theSong.mp3", true);
    snd.stop();
    playing = false;
    onEnterFrame = function(){
        L = snd.getBytesLoaded()/1000;
        T = snd.getBytesTotal()/1000;
        P = Math.floor((L/T)*100);
        if(P==100 && !playing){
           snd.start();
           playing = true
        }
    }
    If you don't think you're going to like the answer, then don't ask the question.

  3. #3
    Senior Member
    Join Date
    Oct 2000
    Location
    Sweden
    Posts
    102
    Simple and beautiful. Working like a charm. Why didn't I think of that myself?


    Still a strange bug(?) though that I never heard of before.
    /Tommy Salomonsson
    www.salomonsson.se

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