Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using readyState to indicate sound is loaded?

Status
Not open for further replies.

callhandler

Programmer
Oct 25, 2002
11
US
I have a page that needs to pre-load several sounds before enabling some controls.

I add the sounds as such:
<EMBED NAME='sound1' SRC='sound1.wav' AUSTOSTART='FALSE' HIDDEN='TRUE'>

Then I use the boolean test

(document.all[&quot;sound1&quot;].readyState=='complete')

to see if the sound is loaded.

Unfortunately, all the boolean test returns 'complete' even if the sound file is NOT loaded.

Any ideas how to fix this problem?
 
readyState has 3 different properties (0, 1, 4),

0 Contol un-initialized and not ready for use

1 Control is loading

4 Contol loaded and is ready for use

You could try something like this

if (myControl.readyState == 0)
{
//some code here
}


Hope this helps you out.

Brian
 
Unfortunately, the problem is not so simple...

myControl.readyState actually returns 'complete' when the sound has not loaded. THis is because the <EMBED> tag does not support readyState in the same way <IMG> does (found this on Microsoft's developers reference site).

I am investigating using something like this to handle the job --- I don't understand it entirely .....

<HTML XMLNS:MSIE >
<MSIE:DOWNLOAD ID=&quot;oDownload&quot; STYLE=&quot;behavior:url#default#download)&quot; />

<SCRIPT>
function onDownloadDone() { alert ('Downloaded'); }
oDownload.startDownload('Quickbooks_2002.exe', onDownloadDone);
</script>

... but it looks like it will work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top