Wait for sound to load or preload before continuing action - SOLVED?

  • I have several audio-narrated tours of my pano. When the user selects one, I would like to first load the audio file, and then begin the series of LookTo() actions, so that the movements and audio are synced.

    I am looking for a command to wait for the audio to load before continuing (similar to the wait(load); for the panorama). Ideally I would display a message that says "audio loading..." while this loop is running.

    I've tried a few set of solutions without success. seeksound() seems to be unreliable for some reason. preloadsound() doesn't wait for load before continuing.

    Right now, I simply preload all of the sounds when the website first loads, which works, but it's a heavy delay of several mb right at the beginning:

    https://1871.Chicago00.org (the audio tours are under 'STORIES' in the left menu)

    Any suggestions?

    Much thanks.


    I have an answer to my own question. Though I'm not sure it's a very efficient way to do it.

    This seems to work:

    createsound(mySound, audioFile);

    set(layer[soundLoadingText_text].visible, true);

    txtadd(layer[soundLoadingText_text].html, 'Loading sound', '...');

    set(soundDuration, get(sound[mySound].duration));
    asyncloop(soundDuration LE 0,
    set(soundDuration, get(sound[mySound].duration));,

    set(layer[soundLoadingText_text].visible, false);

    Edited once, last by garhodes (August 9, 2021 at 5:21 AM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!