Preload Audio

When timing is critical, you may want to pre-load your audio.

In this example we pre-load an audio, then play it at a later time with minimal latency. Note: this optimization is not typically needed.


To pre-load an audio track in order to achieve a faster effect when calling the sayAudio() command do the following:
  1. Call the loadAudio() command: loadAudio('audioLoaded')

  2. Use the event callback function vh_audioLoaded(args) if you need to know when audio pre-loading is completed. This function returns the name of the pre-loaded audio, which can be useful in cases where multiple pre-loading calls are made.
    In this example, a JS alert is displayed when pre-loading is done.

  3. Call the sayAudio() function normally to play the audio at any time. If the audio was previously pre-loaded, it will play without delay. Try it now: sayAudio('audioLoaded')


© 2003 Oddcast Inc. All Right Reserved