Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #8961 > unrolled thread
| Started by | "Fokke Nauta" <fnautaNO@SPAMiae.nl> |
|---|---|
| First post | 2011-12-07 12:46 +0100 |
| Last post | 2011-12-10 13:40 +0100 |
| Articles | 12 — 4 participants |
Back to article view | Back to comp.lang.javascript
Sound on/off button does not work "Fokke Nauta" <fnautaNO@SPAMiae.nl> - 2011-12-07 12:46 +0100
Re: Sound on/off button does not work Denis McMahon <denismfmcmahon@gmail.com> - 2011-12-07 16:42 +0000
Re: Sound on/off button does not work "Fokke Nauta" <fnautaNO@SPAMiae.nl> - 2011-12-07 19:48 +0100
Re: Sound on/off button does not work "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-12-08 00:09 +0200
Re: Sound on/off button does not work David Mark <dmark.cinsoft@gmail.com> - 2011-12-07 16:03 -0800
Re: Sound on/off button does not work "Fokke Nauta" <fnautaNO@SPAMiae.nl> - 2011-12-08 20:23 +0100
Re: Sound on/off button does not work Denis McMahon <denismfmcmahon@gmail.com> - 2011-12-09 00:10 +0000
Re: Sound on/off button does not work David Mark <dmark.cinsoft@gmail.com> - 2011-12-08 16:40 -0800
Re: Sound on/off button does not work David Mark <dmark.cinsoft@gmail.com> - 2011-12-08 16:46 -0800
Re: Sound on/off button does not work David Mark <dmark.cinsoft@gmail.com> - 2011-12-07 15:55 -0800
Re: Sound on/off button does not work Denis McMahon <denismfmcmahon@gmail.com> - 2011-12-09 00:41 +0000
Re: Sound on/off button does not work "Fokke Nauta" <fnautaNO@SPAMiae.nl> - 2011-12-10 13:40 +0100
| From | "Fokke Nauta" <fnautaNO@SPAMiae.nl> |
|---|---|
| Date | 2011-12-07 12:46 +0100 |
| Subject | Sound on/off button does not work |
| Message-ID | <9k9208FoloU1@mid.individual.net> |
Hi all,
I searched for a sound on/off button for web pages. The script I found I
placed in an HTML document. I adapted it only to suit a different sound file
and to change the text on the button.
It does not work though. The original version didn't work either.
The button changes allright but the sound stays on.
Can any one help me out?
The script is underneath this post. The web page is on www.pc3.nl/test and
is called test.htm.
Many thanks in advance for your help.
With best regards,
Fokke Nauta
Script:
In header:
----------
<script language="JavaScript">
<!--
function musicOff() {
document.midi.stop()
}
function musicOn() {
document.midi.play()
}
function changeButton() {
if (document.onoff.B1.value=='Sound off') {
document.onoff.B1.value='Sound on';
musicOff()
}
else {
document.onoff.B1.value='Sound off';
musicOn()
}
}
//-->
</script>
In body:
--------
<embed name="midi" src="Lauquette.mp3" loop="true" width=0 height=0
hidden="true">
<form name="onoff">
<input type="button" value="Sound off" name="B1" onClick="changeButton()">
</form>
[toc] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2011-12-07 16:42 +0000 |
| Message-ID | <4edf9765$0$29307$a8266bb1@newsreader.readnews.com> |
| In reply to | #8961 |
On Wed, 07 Dec 2011 12:46:13 +0100, Fokke Nauta wrote: > I searched for a sound on/off button for web pages. The script I found I > placed in an HTML document. I adapted it only to suit a different sound > file and to change the text on the button. It does not work though. The > original version didn't work either. The button changes allright but the > sound stays on. Can any one help me out? Have you tried the following: http://validator.w3.org/unicorn/check?ucn_uri=www.pc3.nl%2Ftest% 2Ftest.htm&ucn_task=conformance# which suggests to me that (a) your script element is incorrectly defined and (b) the embed element isn't supported in the defined doctype. Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | "Fokke Nauta" <fnautaNO@SPAMiae.nl> |
|---|---|
| Date | 2011-12-07 19:48 +0100 |
| Message-ID | <9k9qopFudlU1@mid.individual.net> |
| In reply to | #8968 |
"Denis McMahon" <denismfmcmahon@gmail.com> wrote in message news:4edf9765$0$29307$a8266bb1@newsreader.readnews.com... > On Wed, 07 Dec 2011 12:46:13 +0100, Fokke Nauta wrote: > >> I searched for a sound on/off button for web pages. The script I found I >> placed in an HTML document. I adapted it only to suit a different sound >> file and to change the text on the button. It does not work though. The >> original version didn't work either. The button changes allright but the >> sound stays on. Can any one help me out? > > Have you tried the following: > > http://validator.w3.org/unicorn/check?ucn_uri=www.pc3.nl%2Ftest% > 2Ftest.htm&ucn_task=conformance# Hi Dennis, I just did and was surpised with the amount of errors. > which suggests to me that (a) your script element is incorrectly defined > and (b) the embed element isn't supported in the defined doctype. Well, I used the embed element on other webpages with the same doctype and it works perfectly. But which doctype should I choose, to start with? Regards, Fokke
[toc] | [prev] | [next] | [standalone]
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Date | 2011-12-08 00:09 +0200 |
| Message-ID | <jboo7i$l9e$1@dont-email.me> |
| In reply to | #8973 |
2011-12-07 20:48, Fokke Nauta wrote: > Well, I used the embed element on other webpages with the same doctype and > it works perfectly. Forget the doctype and validation issues for the moment. They do not affect the problem at hand. The question is: can you expect the <embed> element to have play() and stop() methods? You might consider using the HTML5 <audio> element, with its play() and pause() methods, but then you would need to deal with the varying support to this element (well, you could use <embed> as fallback content) and varying support to different audio media types with it. Does it really pay off, as opposite to using <embed> with its own visible controls? I'd expect most users to prefer those controls (which they have encountered on other pages) to your site- or page-specific special controls. -- Yucca, http://www.cs.tut.fi/~jkorpela/
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2011-12-07 16:03 -0800 |
| Message-ID | <08f53b94-6773-40d6-a249-b658890ad4a6@20g2000yqa.googlegroups.com> |
| In reply to | #8974 |
On Dec 7, 5:09 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote: > 2011-12-07 20:48, Fokke Nauta wrote: > > > Well, I used the embed element on other webpages with the same doctype and > > it works perfectly. > > Forget the doctype and validation issues for the moment. They do not > affect the problem at hand. Right. > > The question is: can you expect the <embed> element to have play() and > stop() methods? Nope. > > You might consider using the HTML5 <audio> element, with its play() and > pause() methods, but then you would need to deal with the varying > support to this element (well, you could use <embed> as fallback > content) and varying support to different audio media types with it. Could use the My Library audio module (or the like if can find one) as the fallback. The book on EMBED/OBJECT-based audio was written ten years ago. Quick review: it stinks; plug-ins are unreliable. And if you need to support IE, you should use BGSOUND elements, which is also taken care of by this module. You might also consider using an HTML5-based solution and then falling straight back to the BGSOUND shenanigans. Could even put the latter in conditional comments. After all, who cares if audio features are available in old versions of Firefox, Safari, Opera, etc.? Best to leave the EMBED/OBJECT crap out of it at this point. > > Does it really pay off, as opposite to using <embed> with its own > visible controls? I'd expect most users to prefer those controls (which > they have encountered on other pages) to your site- or page-specific > special controls. > Pays off for control-freak designers, but stiffs the users. ;)
[toc] | [prev] | [next] | [standalone]
| From | "Fokke Nauta" <fnautaNO@SPAMiae.nl> |
|---|---|
| Date | 2011-12-08 20:23 +0100 |
| Message-ID | <9kch67Fo6U1@mid.individual.net> |
| In reply to | #8977 |
"David Mark" <dmark.cinsoft@gmail.com> wrote in message news:08f53b94-6773-40d6-a249-b658890ad4a6@20g2000yqa.googlegroups.com... On Dec 7, 5:09 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote: > 2011-12-07 20:48, Fokke Nauta wrote: > > > Well, I used the embed element on other webpages with the same doctype > > and > > it works perfectly. > > Forget the doctype and validation issues for the moment. They do not > affect the problem at hand. Right. OK, this makes sense. > > The question is: can you expect the <embed> element to have play() and > stop() methods? Nope. And this makes sense as well. So, the script I found was crap. > > You might consider using the HTML5 <audio> element, with its play() and > pause() methods, but then you would need to deal with the varying > support to this element (well, you could use <embed> as fallback > content) and varying support to different audio media types with it. Could use the My Library audio module (or the like if can find one) as the fallback. The book on EMBED/OBJECT-based audio was written ten years ago. Quick review: it stinks; plug-ins are unreliable. And if you need to support IE, you should use BGSOUND elements, which is also taken care of by this module. You might also consider using an HTML5-based solution and then falling straight back to the BGSOUND shenanigans. Could even put the latter in conditional comments. After all, who cares if audio features are available in old versions of Firefox, Safari, Opera, etc.? Best to leave the EMBED/OBJECT crap out of it at this point. OK. Can you give me an example of how to code this? > > Does it really pay off, as opposite to using <embed> with its own > visible controls? I'd expect most users to prefer those controls (which > they have encountered on other pages) to your site- or page-specific > special controls. > Pays off for control-freak designers, but stiffs the users. ;) OK, HTML5 then. With a fall back to the old BGSOUND element. If you could give me an example ... Fokke
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2011-12-09 00:10 +0000 |
| Message-ID | <4ee151ee$0$29311$a8266bb1@newsreader.readnews.com> |
| In reply to | #8993 |
On Thu, 08 Dec 2011 20:23:51 +0100, Fokke Nauta wrote: > OK, HTML5 then. With a fall back to the old BGSOUND element. If you > could give me an example ... http://www.lmgtfy.com/?q=html5+embed+audio Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2011-12-08 16:40 -0800 |
| Message-ID | <e53789f5-5573-4369-9df6-af0fc90a07ed@s26g2000yqd.googlegroups.com> |
| In reply to | #9005 |
On Dec 8, 7:10 pm, Denis McMahon <denismfmcma...@gmail.com> wrote: > On Thu, 08 Dec 2011 20:23:51 +0100, Fokke Nauta wrote: > > OK, HTML5 then. With a fall back to the old BGSOUND element. If you > > could give me an example ... > > http://www.lmgtfy.com/?q=html5+embed+audio > What a completely worthless response. Trying to appear clever? It requires actual cleverness. ;) You already know where to find the BGSOUND fallback (if you read the thread before posting). And why would you include "embed" in the query (again, assuming you actually read the previous posts?)
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2011-12-08 16:46 -0800 |
| Message-ID | <c1bafe19-c882-43ba-81d6-89a4ed89f83b@4g2000yqu.googlegroups.com> |
| In reply to | #8993 |
On Dec 8, 2:23 pm, "Fokke Nauta" <fnaut...@SPAMiae.nl> wrote: > "David Mark" <dmark.cins...@gmail.com> wrote in message > > news:08f53b94-6773-40d6-a249-b658890ad4a6@20g2000yqa.googlegroups.com... > On Dec 7, 5:09 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote: > > > 2011-12-07 20:48, Fokke Nauta wrote: > > > > Well, I used the embed element on other webpages with the same doctype > > > and > > > it works perfectly. > > > Forget the doctype and validation issues for the moment. They do not > > affect the problem at hand. > > Right. > > OK, this makes sense. > > > > > The question is: can you expect the <embed> element to have play() and > > stop() methods? > > Nope. > > And this makes sense as well. So, the script I found was crap. > > > > > You might consider using the HTML5 <audio> element, with its play() and > > pause() methods, but then you would need to deal with the varying > > support to this element (well, you could use <embed> as fallback > > content) and varying support to different audio media types with it. > > Could use the My Library audio module (or the like if can find one) as > the fallback. The book on EMBED/OBJECT-based audio was written ten > years ago. Quick review: it stinks; plug-ins are unreliable. And if > you need to support IE, you should use BGSOUND elements, which is also > taken care of by this module. > > You might also consider using an HTML5-based solution and then falling > straight back to the BGSOUND shenanigans. Could even put the latter > in conditional comments. After all, who cares if audio features are > available in old versions of Firefox, Safari, Opera, etc.? Best to > leave the EMBED/OBJECT crap out of it at this point. > > OK. > Can you give me an example of how to code this? > > > > > Does it really pay off, as opposite to using <embed> with its own > > visible controls? I'd expect most users to prefer those controls (which > > they have encountered on other pages) to your site- or page-specific > > special controls. > > Pays off for control-freak designers, but stiffs the users. ;) > > OK, HTML5 then. With a fall back to the old BGSOUND element. > If you could give me an example ... > Of what? How to use the HTML5 AUDIO element? Or how to detect whether your chosen audio format(s) are likely to work? If the detection fails, you have to replace the AUDIO element with an alternative (or simply remove it in the case of a BGSOUND-based fallback script). And appending/removing a BGSOUND element is trivial. They go in the HEAD. No format detection needed. WAV for effects or MP3 for music.
[toc] | [prev] | [next] | [standalone]
| From | David Mark <dmark.cinsoft@gmail.com> |
|---|---|
| Date | 2011-12-07 15:55 -0800 |
| Message-ID | <c803cbd4-9af4-4535-ad0b-db4f6e1e882a@k23g2000yqa.googlegroups.com> |
| In reply to | #8968 |
On Dec 7, 11:42 am, Denis McMahon <denismfmcma...@gmail.com> wrote: > On Wed, 07 Dec 2011 12:46:13 +0100, Fokke Nauta wrote: > > I searched for a sound on/off button for web pages. The script I found I > > placed in an HTML document. I adapted it only to suit a different sound > > file and to change the text on the button. It does not work though. The > > original version didn't work either. The button changes allright but the > > sound stays on. Can any one help me out? > > Have you tried the following: > > http://validator.w3.org/unicorn/check?ucn_uri=www.pc3.nl%2Ftest% > 2Ftest.htm&ucn_task=conformance# > > which suggests to me that (a) your script element is incorrectly defined > and (b) the embed element isn't supported in the defined doctype. > (a) Did you really need the validator to tell you that? :) (b) It's not supported in any doctype.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2011-12-09 00:41 +0000 |
| Message-ID | <4ee15945$0$29435$a8266bb1@newsreader.readnews.com> |
| In reply to | #8961 |
On Wed, 07 Dec 2011 12:46:13 +0100, Fokke Nauta wrote: > I searched for a sound on/off button for web pages. I tend to provide links to any multi media files that are related to web pages that I write, rather than try and force users to view / listen to them. It goes along with my gross distaste for websites written in flash / silverlight / etc. OK they can look very glossy, but they start getting painfully slow on some machines and hogging resources, and I often end up navigating away from the website and looking elsewhere. So, is the audio file actually essential to the enable the user to understand the website content, or is it an aesthetic add-on that could be safely dumped? Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | "Fokke Nauta" <fnautaNO@SPAMiae.nl> |
|---|---|
| Date | 2011-12-10 13:40 +0100 |
| Message-ID | <9kh2asF4omU1@mid.individual.net> |
| In reply to | #9007 |
"Denis McMahon" <denismfmcmahon@gmail.com> wrote in message news:4ee15945$0$29435$a8266bb1@newsreader.readnews.com... > On Wed, 07 Dec 2011 12:46:13 +0100, Fokke Nauta wrote: > >> I searched for a sound on/off button for web pages. > > I tend to provide links to any multi media files that are related to web > pages that I write, rather than try and force users to view / listen to > them. I fully agree. > It goes along with my gross distaste for websites written in flash / > silverlight / etc. > > OK they can look very glossy, but they start getting painfully slow on > some machines and hogging resources, and I often end up navigating away > from the website and looking elsewhere. Fully agree as well. > So, is the audio file actually essential to the enable the user to > understand the website content, or is it an aesthetic add-on that could > be safely dumped? > Well, if it was up to me, I would dump it straight away. And whether the add-on is aesthetic or not is discussable. But the owner of a website wanted this sound as a background sound on multiple pages. Happily he came up with the idea that visitors would have been able to turn of this sound. Regards, Fokke
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web