looping an audio file

I

Ivo

Hi,
I have an audio file (.mid or .wav or .mp3) in an object element:

<object id="snd" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.
cab#Version=5,1,52,701" type="application/x-oleobject" width="282"
height="53">
<param name="FileName" value="Tjaikovsky_-_The_sorcerers_apprentice.mid" />
<param name="loop" value="true" />
<... more presentational params ...>
<embed name="embsnd" src="Tjaikovsky_-_The_sorcerers_apprentice.mid"
width="280" height="53" controls="smallconsole" autostart="true"
loop="true"></embed>
</object>

and a checkbox with which I would like to toggle the looping behaviour of
said object:

<label for="chloop">Loop:</label><input type="checkbox" id="chloop"
onclick="toggleloop(this);" class="zm" checked>

However, the sound keeps looping whatever I put in the toggle function:

function toggleloop(el){
document.getElementById('snd').PlayCount=el.checked?99:1;
document.getElementById('snd').PlayCount=el.checked?0:1;
document.getElementById('snd').loop=el.checked?99:1;
document.getElementById('snd').loop=el.checked?0:1;
document.embeds.embsnd.loop=el.checked?99:1;
document.embeds.embsnd.loop=el.checked;
...??
}

Resources on the web speak of embedding sounds into webpages in many ways,
but none I have found that discuss this particular issue. I hope someone
easily
spots my error.
 
I

Ivo

I'd recommend inserting the object mid/wav etc. code dynamically into a div on
the web page, depending on the user's initial choice of "to loop" or "not to
loop".

If the user clicks "loop" then write the code to include the param loop="true"
or just the opposite.

Thanks for your thoughts. The 'solution' I now have does that more or less:
there are two of those objects, one set to loop and visible, the other
non-looping and invisible. I toggle which sound is visible and hearable with
the checkbox.

But it 's not a solution at all: the whole idea behind this application is
that users can toggle the looping behaviour *while the sound is playing*,
and that it *keeps playing* at least till the end of the current round!
Obviously, with your suggestion and my solution, the moment the checkbox is
clicked, the current sound stops and the other one starts playing. And
detecting with javascript when a sound file reaches the end also seems
impossible...
It looks like your code utilizes msoft active-x technology for use of windows
media; i know there are a ton of other ways to do this using that
technology;

I was hoping the same thing, I started with just an embed tag, then added
the object hoping it would listen to my script, but alas!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top