473,548 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Playing an audio file without spawning a new window ...

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>Dictiona ry: homeostasis</title>
<link href="liveink.c ss" type="text/css" rel="stylesheet "/>
</head>
<body>
<div class="dictiona ry-area">
<span class="dictiona ry-word">homeostas is</span>
(<span class="dictiona ry-pos">Noun</span>)
<br/>
<div class="dictiona ry-defn">The maintenance of a constant internal
state in a changing environment that is maintained by continually
making adjustments to the internal and external environment.</div>
<a href="homeostas is.mp3" target="new"><i mg src="audio.gif"
border="0"></a>
<div class="dictiona ry-close-window"><a
href="javascrip t:window.close( )">Close Window</a></div>
</div>
</body>
</html>

The inconvenience is right now a new window is spawned to play the
audio., which contains the controller for playing the audio (complete
with pause, stop, and play buttons). All my audio clips are less than
3 seconds in length.. How can I play the audio file without launching
the controller? I don't care if there's no way to stop/pause the audio
once it's started.

Thanks for your help, - Dave

Jul 23 '05 #1
1 2676
la***********@z ipmail.com wrote:
How can I play the audio file without launching
the controller? I don't care if there's no way to stop/pause the audio
once it's started.


Try this:

<html>
<head>
<title>Make some noize</title>

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

var Sound = new Object();
Sound.play = function Sound_play(src) {
if (!src) return false;
this.stop();
var elm;
if (typeof document.all != "undefined" ) {
elm = document.create Element("bgsoun d");
elm.src = src;
}
else {
elm = document.create Element("object ");
elm.setAttribut e("data",src) ;
elm.setAttribut e("type","aud io/x-wav");
elm.setAttribut e("controller", "true");
}
document.body.a ppendChild(elm) ;
this.elm = elm;
return true;
};

Sound.stop = function Sound_stop() {
if (this.elm) {
this.elm.parent Node.removeChil d(this.elm);
this.elm = null;
}
};

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

<body>
<div
onmouseover="So und.play('klats chn.wav')"
onmouseout="Sou nd.stop()">Come over me</div>
</body>
</html>
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2831
by: Peter Schmitz | last post by:
Hi, I'm just trying to play a *.wav file, making use of the unmanaged function "sndPlaySoundA" in winmm.dll, but I still got one question: How can I avoid, that the sound file itself has to be seperate file in a specific directory, but instead 'integrate' it in my application? Thanks peter
7
6437
by: Lee Moody | last post by:
I just want quick and easy way to play a .wav file out the standard sound device. It could even be as simple as activating a sound assigned to an existing windows sound event. Any suggestions? Thanks in advance. -Lee
3
4779
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...
4
4594
by: fAnSKyer/C# newbie | last post by:
I am using winmm.dll and I found that I can't just suspend it and resume it? What should I do? Any better idea? Should I use thread? and thread.suspend will work? Thanks
2
2175
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called BatmoAudiopop.js which opens a pop-up browser window with an audio player when a link is clicked. Basically, it sets the right mime-type depending on the...
0
923
by: Sobin Thomas | last post by:
Hi,All... I found in one of the articles on the net that an audio file can be played in asp.net by setting the Hyperlink's Navigate Url as the audio file name. ie, Hyperlink1.NavigateUrl="~\\songs\\mysong.wav"; And it works pretty well for me.Is there any disadvantage in using this method.If so, what is the preferred method of playing an...
0
1099
by: Sobin Thomas | last post by:
Hi,All... I found in one of the articles on the net that an audio file can be played in asp.net by setting the Hyperlink's Navigate Url as the audio file name. ie, Hyperlink1.NavigateUrl="~\\songs\\mysong.wav"; And it works pretty well for me.Is there any disadvantage in using this method.If so, what is the preferred method of playing an...
1
1266
by: Sobin Thomas | last post by:
Hi,All... I found in one of the articles on the net that an audio file can be played in asp.net by setting the Hyperlink's Navigate Url as the audio file name. ie, Hyperlink1.NavigateUrl="~\\songs\\mysong.wav"; And it works pretty well for me.Is there any disadvantage in using this method.If so, what is the preferred method of playing an...
1
3387
by: Sobin Thomas | last post by:
Hi All, I want to play an audio file (wav)in my web page.I used the embed tag method.But it does'n work well in firefox.Is there any .NET class to play audio files?I already tried soundpalyer class .It works.But I want a user interface to control the playing of the file(pause,play ,volume etc). Hope you 'll have the solution. Thanks in...
0
7711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
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...
0
7805
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...
0
5085
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...
0
3497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1932
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
0
755
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...

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.