Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Re: sounds IE tested worikng!
- From: trojani2000 at hotmail.com (Troy III Ajnej)
- Subject: [Javascript] Re: sounds IE tested worikng!
- Date: Thu Jun 22 20:13:35 2006
All right, this is not exactly how I proposed this, but here is a solution that can make it work with "all" (Thinking out of my "Old Box") script //-----place this higher posible------ var j=0;loc="http://www.xn--ovg.com/snd/snd/" var sound=new Array( loc+'ding.au', loc+'one.au', loc+'eight.au', loc+'two.au' ) function preloadAudios() { for (; i <= 3; i++) { sound[i] = new Sound() sound[i].src = sound[i] } } preloadAudios function playnow(){ if(j <= 3){ plays.src = sound[j]; playz.src = sound[j]; j++; runtime = setTimeout('playnow()', 1000) } else { plays.src=''; playz.src=''; clearTimeout(runtime); /*never forget to destroy the timer *for it will run infinitely while interfering with other scripts of pages *sometimes causing the brower not to respond or even freeze. */ }}/script ***use single playback tags*** <BGSOUND ID='plays' SRC=''> <EMBED ID='playz' SRC='' HIDDEN='TRUE' HEIGHT='0' WIDTH='0'> Using more than one will stress the browser and each will be able to play independently in asynchronous manner and shall interfere with previous instance. Even though onLoad event never gave me the reliable true 'complete' in the past, in this case the fault is on the player, it will always take some noticeable time before actually outputting already playing sound from the file. But this can only happen during the first initialization of the player. Here is the rest of the code: //------place it as low as you can------------ script if(document.getElementById) { var plays=document.getElementById('plays') var playz=document.getElementById('playz') } function checkreadystate(){ if(document.readyState != "complete"){ checkreadystate() } else { playnow() }}onload=checkreadystate/script(Im double-checking for the readyState "complete" but you may skip it) While the method you've chosen is more universal, it lacks the accuracy of controlling its behavior. Yet in other hand, using a player will give you more control and behavior reliability but will require that users not having installed the certain player to download and install several MB just to hear your page talk some numbers. But it's a good trade-off, simplicity & universality against robust complicated & system dependant solution, -id go for it. P.S.: This code is tested on IE only! But should work the same in most of the major browsers~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _________________________________________________________________ Express yourself: design your homepage the way you want it with Live.com. http://www.live.com/getstarted -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.LaTech.edu/pipermail/javascript/attachments/20060623/658d0b13/attachment.html
- Follow-Ups:
- [Javascript] Re: sounds IE tested worikng!
- From: tedd
- [Javascript] Re: sounds IE tested worikng!
- Prev by Date: [Javascript] Re: sounds
- Next by Date: [Javascript] Fjax - Ajax - eliminate need for browser-specific code
- Previous by thread: [Javascript] Re: sounds
- Next by thread: [Javascript] Re: sounds IE tested worikng!
- Index(es):