Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2003, 04:05 AM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sound on demand

Hi
I am trying to create a function the enables the user to rotate through a series of sounds by clicking on a single image and am having real trouble because of my stupidity (I think)
This the code I am using
var number = 0;

function playSound() {
number++;
document.soundMain.play(); }


//-->
</script>
</head>

<body>
<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" name="soundMain" width="1" height="1">
<param name="Filename" value="Assets/sound1.wav">
<param name="PlayCount" value="1">
<param name="ShowControls" value="true">
<param name="Autostart" value="false">
<param name="Volume" value="100">
<param name="ShowDisplay" value="true">
<embed width="1" height="1" filename="Assets/sound1.wav" playcount="1" showcontrols="true" volume="100" showdisplay="true" name="soundMain"></embed>
</object>
<img src="Assets/grnbut.gif" width="50" height="50" onClick='playSound()'"><br>


</body>

How can I set up the function so that it cycles through four sound clips by changing the value of the sound source ... something like
"Assets/sound" +number =".wav"

Thanks
Bill

 
Old June 9th, 2003, 10:47 AM
Authorized User
 
Join Date: Jun 2003
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can't say I've ever worked with an active-x control in script before, but here's a shot:

function playSound(){
number++;
document.soundMain.param("Filename").value="Assets/Sound"+number+".wav";
document.soundMain.play(); }

This assumes the object has a param[] collection that can be indexed by name.


-Van
(Old dog learning new tricks...)
 
Old June 10th, 2003, 01:34 AM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help
i'll let you know if it works
Bill





Similar Threads
Thread Thread Starter Forum Replies Last Post
sound mohand Visual Basic 2005 Basics 1 November 27th, 2007 05:03 PM
Most "in demand" language? meverha1 Intro Programming 3 December 26th, 2005 02:41 PM
Creating on-demand validation in DataGrid sankar General .NET 0 June 22nd, 2004 05:02 AM
About Video on demand nw61 C# 6 May 22nd, 2004 02:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.