/    Sign up×
Community /Pin to ProfileBookmark

Sound delay help

Hello, Im new to jscript and I am having a hard time making a delay function work within my current script. Right now after you have clicked a sound and it has been saved in memory and then you click play the sounds play all at once, I would like for the sounds to play one at a time, if this is possible. Any help is much appreciated.

code:

========================================
<script language=”JavaScript”>
var playlist = new Array();
var x = -1;

function add(sound){
x=x+1;
playlist[x] = sound;
}//ends add()

function play_it(){
for (i = 0; i < playlist.length; i++){
document].Play();
}//ends FOR
}//ends play_it()

function reset_list(){
var playlist = new Array();
var x = -1;
}
</script>
</head>

<body>
<a href=”javascript: add(‘gong’)”>Gong Sound</a><br><br>

<a href=”javascript: add(‘foghorn’)”>Fog Horn</a><br><br>

<a href=”javascript: add(‘cuckoo’)”>Cuckoo Clock</a><br><br>

<form>
<input type=”button” value=”Play” onClick=”play_it()”>&nbsp;&nbsp;

<input type=”button” value=”Reset” onClick=”reset_list()”>
</form>

<!– Sound Embeds –>
<embed name=”gong” src=”gong.wav” autostart=”false” hidden=”true” loop=”false”></embed>

<embed name=”foghorn” src=”foghorn.wav” autostart=”false” hidden=”true” loop=”false”></embed>

<embed name=”cuckoo” src=”cuckoo.wav” autostart=”false” hidden=”true” loop=”false”></embed>

</body>

</html>
=====================================

Thanks

Code One

[b]Quick script sum up:[/b]

This script collects in order of click, different embed sounds and each sound is held in order until the user presses the play button. Once the user presses the play button all of the sounds are played at one time. I am hoping someone could add a delay function, which will allow each sound to play one at a time.

P.s. For those who may have viewed this thread prior to the edit, I have added the rest of the code, making it a working module, so maybe you will better understand what I am talking about and need done. ?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JonaJun 04.2003 — [font=arial][color=maroon]Where are you stopping the sound? You have to stop the sound from playing before starting the next one. Otherwise it will just add more to the sound playing.[/color][/font]

[b]Jona[/b]
×

Success!

Help @Code_One spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...