473,887 Members | 2,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

looping an audio file

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.microso ft.com/activex/controls/mplayer/en/nsmp2inf.
cab#Version=5,1 ,52,701" type="applicati on/x-oleobject" width="282"
height="53">
<param name="FileName" value="Tjaikovs ky_-_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="small console" 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">Lo op:</label><input type="checkbox" id="chloop"
onclick="toggle loop(this);" class="zm" checked>

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

function toggleloop(el){
document.getEle mentById('snd') .PlayCount=el.c hecked?99:1;
document.getEle mentById('snd') .PlayCount=el.c hecked?0:1;
document.getEle mentById('snd') .loop=el.checke d?99:1;
document.getEle mentById('snd') .loop=el.checke d?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
2 2580
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2502
by: Bruce Bon | last post by:
The class below is intended to play a Sun audio file (.au) in the background while the main thread, which is servicing a GUI, continues without impact. It doesn't work. For a sound file that takes 3-5 seconds to play, the main thread hangs for that long. I have run this many times, with changes in printouts and insertion of strategic sleeps to try to make sure that the player thread gives up control, but apparently the call to...
1
2702
by: laredotornado | last post by:
Hello, I want to play an audio file embedded on my page by clicking on an audio image and the page change to a new page. Is there a cross-browser Javascript way to do this? Right now the code I have is ... <html> <head> <title>Dictionary: homeostasis</title> <link href="liveink.css" type="text/css" rel="stylesheet"/> </head>
0
2354
by: laredotornado | last post by:
Hello, I want to play an audio file by clicking on an audio icon and not having the page switch out underneath. Right now the code I have is ... <html> <head> <title>Dictionary: homeostasis</title> <link href="liveink.css" type="text/css" rel="stylesheet"/> </head> <body>
5
2598
by: Shelly | last post by:
I had a problem with uploading images in that some files did not have a type of "image/something" from the $_FILES which I used for my verification. Someone (THANK YOU) suggested using getimagesize() which has the third element in the returned array being a number representing the image type. That worked perfectly for me, enabling me to check that it was, indeed, an image file that I had uploaded. Now I ask if there is a similar...
4
6062
by: Gary Morrison | last post by:
I need to create a lot of fairly-short audio files from the concatenation of a lot of even shorter audio files. I'd like to control that from a Perl script. The audio files would presumably be AIFF or WAV files, preferable AIFF. Do any of you know of Perl commands to accomplish this? Specifically, * A call to create and open a new, empty AIFF or WAV file, * A call to append onto the end of that open audio file the audio content of...
3
4820
by: abrtlt | last post by:
I would like to have a web page in which, when the user clicks on any of several specific elements, a specific audio file is played, without reloading the page. The specific audio file name is obtained from a PHP script (accessing a MySQL database) that could be called using XMLHttpRequest and JavaScript would write in a "div" tag an "embed and play" HTML tag containing the audio file name. I am not sure this would work, as the embed tag...
6
2006
by: Quentin | last post by:
Hi, I want to save an audio stream into a circular file so that I only keep say the last hour's audio. Can anybody help? Cheers, Quentin
13
4916
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives, suggestions or improvements? if( wmv file) document.write("<OBJECT id=Player classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 height="354" width="479">
1
1752
by: =?Utf-8?B?Qm9iQWNoZ2lsbA==?= | last post by:
I am using Windows Media Player to play my half second audio files one after the other using the code below... My problem comes when I play a second audio file immediately after the first one stops sometimes on slower computers the audio on the second file gets truncated on the beginning of playing the second file. What can I do to minimize this truncation of audio? Right now I am having to add 1 second of blank audio to the beginning...
0
9957
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10875
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10432
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9593
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7141
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.