Results 1 to 5 of 5

Thread: Question about the Preload Image (with progress bar) Script

  1. #1
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Question about the Preload Image (with progress bar) Script

    1) Script Title: Preload Image (with progress bar) Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...eloadimage.htm

    3) Describe problem:
    I've been working on a new web site for a friend, and I needed a "page loading" script. I found yours on Dynamicdrive.com, and it works great, thanks! It's almost exactly what I needed. One question, it works great on the graphics, but can I also use it to preload the sound (.wav file)? Is there a way to edit the script and add this option so that it will work for both, sound & graphics?

    Thanks again,
    Mark
    Mark@durhambos.com

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There is no actual preloading of sound files in javascript or HTML. There may be a way with Flash, Java (not javascript), or a server side language, I don't know. You can place an embed on a page with the sound file as its src attribute and set it hidden and not to play, that will preload it - sort of. But there is no way to monitor its progress as there is with images. And, if you are preloading images, they will be taking up the bandwidth anyway, so the sound file may not load until after.

    However, if the embed 'runs' before the preload script, the script may wait for the sound file to load before starting on the images. At least a few images will probably load concurrently, so it is a bit of a crap shoot, but you might luck out.

    Example hidden non-starting embedded wav tag:

    Code:
    <embed src="mysound.wav" loop="false" autostart="false" hidden="true">
    If that happens, it may take some time (depending upon connection speed and the size of the sound file), but at least then the progress bar will not start moving until the browser starts in on the images.

    The best chance of that happening is to put the embed tag in the body of the page and to change this in the second part of the preload script:

    Code:
    	loadImages()
    to:

    Code:
    window.onload = loadImages;
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the help John,

    Is there any script, and/or HTML that would allow me to mute the sound, or turn the volume all the way down while the file is loading to the "preload" page I was making? Because I'm thinking the autostart="true or false" has to be set to "true" before the file would start to load right? I'd like to run the "embed src" as "hidden", and hear no sound until the file loads and the page links over to the next page where I want the sound to play. (the old "bait and switch" tactic.) lol

    Thanks again,
    Mark

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I used that exact tag to preload wav files before. It was some time ago, it worked then, perhaps still will. I think if you give no mime type or player info, the browser will cache the file, or at least start to. Therein lies the real issue, if somehow the images start and then finish preloading before the sound is completely cached, it won't help at all, in fact it will just add time to the preload page as the browser tries to deal with the sound file and the images.

    Some experimentation will be necessary.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks,

    I'll keep playing with it.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •