/    Sign up×
Community /Pin to ProfileBookmark

controlling sound

Hey, I am looking for a script that will allow me to control an audio file. Essentially allowing me to define a link to pause the audio file when I click a button or image, and then play it upon clicking that image/button again.

I am also looking for a way to auto loop the sound.
The sound is located at [url]http://www.thedarkbrotherhood.com/index/web5.mp3[/url]
Thanks.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@Rossario123Sep 11.2006 — [code=html]
<html>
<head>
<style type="text/css">
a.a1, a.a1:visited{display:block;}
embed{height:20px;width:300px;display:block;}
</style>

<script type="text/javascript">
<!--

function playSound() {
document.firstSound.play(false);
}

function pauseSound() {
document.firstSound.pause();
}

function stopSound() {
document.firstSound.stop();
}

function volup() {
currentVolume = document.firstSound.GetVolume();
newVolume = (currentVolume + 10);

if (document.firstSound.GetVolume() == 100) {
alert("Volume is already at maximum");
}

if (newVolume < 90) {
document.firstSound.setvol(newVolume);
}
else
{
if ((newVolume <= 100) && (newVolume > 90)) {
document.firstSound.setvol(100);
}
}
}

function voldown() {
currentVolume = document.firstSound.GetVolume();
newVolume = (currentVolume - 10);

if (document.firstSound.GetVolume() == 0) {
alert("Volume is already at minimum");
}

if (newVolume > 10) {
document.firstSound.setvol(newVolume);
}
else {
if ((newVolume >= 0) && (newVolume < 10)) {
document.firstSound.setvol(0);
}
}
}

// -->
</script>
<body>

<embed src="sound1.wav" hidden="true" autostart="false" name="firstSound"></embed>

<a href="javascript:playSound()" class="a1">Play the sound now!</a>
<a href="javascript:pauseSound()" class="a1">Pause the sound now!</a>
<a href="javascript:stopSound()" class="a1">Stop the sound now!</a>
<a href="javascript:volup()" class="a1">Increment the Volume!</a>
<a href="javascript:voldown()" class="a1">Decrement the Volume!</a>

</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@bmassauthorSep 11.2006 — Actually, I am not using the embed tag (I can't). I am using a frame and importing the sound file directly.
Copy linkTweet thisAlerts:
@Rossario123Sep 11.2006 — can i ask why you cannot use a embed tag?
Copy linkTweet thisAlerts:
@bmassauthorSep 12.2006 — Well, I need to have it set up in a frameset so that the music continues when I open a new page (without restarting), but if I embed it with IE and make the rows any smaller than 2%, it won't load the frame at all; i.e., it will not play the sound. If you could help fix that instead, it would be greatly appreciated. The sound works fine however in all other browsers using the embed tag in a frameset.
Copy linkTweet thisAlerts:
@bmassauthorSep 14.2006 — Any ideas?
Copy linkTweet thisAlerts:
@bmassauthorSep 17.2006 — Forget about that, I was able to get it working. However, the script that you gave me doesn't work.
Copy linkTweet thisAlerts:
@bmassauthorSep 24.2006 — I gave it a try on a page, but it doesn't work at all. Here is the page I tried it with: http://www.thedarkbrotherhood.com/index/music.html
×

Success!

Help @bmass 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...