By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,918 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,918 IT Pros & Developers. It's quick & easy.

looping an audio file

P: n/a
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.checke d?99:1;
document.getElementById('snd').PlayCount=el.checke d?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.
--
Ivo.

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

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;
the downside is that it targets one application and operating system versus a
generic code that plays on the user's default player.

You might combine an o/s sniffer with other player options, and when the user
clicks loop/no-loop, insert code for the operating system's standard default
player (what is it, winmedia for windows and quicktime for apple?). With the
ubiquity of flash, you might also consider importing your sounds to flash and
just using flash objects.

Hope this helps,

Jim

Jul 23 '05 #2

P: n/a
Ivo
"JimMenees" wrote
<setting an embedded sound to loop or not>
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!
--
Ivo
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.