How to play a sound in Firefox?

D

Dobedani

Dear All,

I found the code added below at:
http://simplythebest.net/sounds/sound_guide.html

Unfortunately, the code doesn't seem to work in Firefox. These are the
error messages I can see in my Javascript Console:
Error: self.document.guitar.IsReady is not a function
Error: self.document.guitar.stop is not a function

Are there other functions we have to invoke for FireFox? Any help will
be appreciated!

Kind regards,
Dobedani

<BGSOUND id=BGSOUND_ID src="">
<bgsound id="bgsound_id" loop=1 src="jsilence.mid">
<embed name="guitar" src="malaguena.mid" loop=false autostart=false
hidden=true mastersound>

<script language="JavaScript">
<!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0

function playSound() {
if (ie4) document.all['BGSOUND_ID'].src='malaguena.mid';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes['audio/x-midi']
&& self.document.guitar.IsReady()
)
{
self.document.guitar.play()
}
}

function stopSound() {
if (ie4) document.all['BGSOUND_ID'].src='jsilence.mid';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes['audio/x-midi']
)
{
self.document.guitar.stop()
}
}
//-->
</script>

<form name=myform>
<input type=button value="Play Sound" onClick="playSound()">
<input type=button value="Stop Sound" onClick="stopSound()">
</form>
 
R

Randy Webb

Dobedani said the following on 5/26/2006 5:57 AM:
Dear All,

I found the code added below at:
http://simplythebest.net/sounds/sound_guide.html

Unfortunately, the code doesn't seem to work in Firefox. These are the
error messages I can see in my Javascript Console:
Error: self.document.guitar.IsReady is not a function
Error: self.document.guitar.stop is not a function

Are there other functions we have to invoke for FireFox? Any help will
be appreciated!

Best help with regards to that code:

Find another script. When hunting, if you see one that says anything
about navigator.appName, skip it and keep hunting.
 
C

cwdjrxyz

Dobedani said:
Dear All,

I found the code added below at:
http://simplythebest.net/sounds/sound_guide.html

Unfortunately, the code doesn't seem to work in Firefox. These are the
error messages I can see in my Javascript Console:
Error: self.document.guitar.IsReady is not a function
Error: self.document.guitar.stop is not a function

Are there other functions we have to invoke for FireFox? Any help will
be appreciated!

Kind regards,
Dobedani

<BGSOUND id=BGSOUND_ID src="">
<bgsound id="bgsound_id" loop=1 src="jsilence.mid">
<embed name="guitar" src="malaguena.mid" loop=false autostart=false
hidden=true mastersound>

<script language="JavaScript">
<!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0

function playSound() {
if (ie4) document.all['BGSOUND_ID'].src='malaguena.mid';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes['audio/x-midi']
&& self.document.guitar.IsReady()
)
{
self.document.guitar.play()
}
}

function stopSound() {
if (ie4) document.all['BGSOUND_ID'].src='jsilence.mid';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes['audio/x-midi']
)
{
self.document.guitar.stop()
}
}
//-->
</script>

<form name=myform>
<input type=button value="Play Sound" onClick="playSound()">
<input type=button value="Stop Sound" onClick="stopSound()">
</form>

The above code should have been retired several years ago. It only
tests for old style Netscape browsers and not modern Mozilla family
browsers such as recent Netscape, Mozilla, and Firefox. Hence Firefox
is locked out. In the early days of the browser wars, Netscape would
support embed for sound and IE would support bgsound. However IE soon
supported embed for bgsound, but Netscape and modern Mozilla family
browsers never supported bgsound. You can usually just use an embed
code these days without testing for browser type, as IE browsers
earlier than 4 now are all but gone, which is a good thing because many
modern browsers are set to spoof other browsers to avoid lockouts
resulting from faulty browser type detection. However embed never has
been an official part of html, and there are more modern methods for
including sound on a page.

Javascript has been around a long time now, as time goes for computing.
There are many sites around with examples of script that have not been
updated for perhaps 10 years. Some of these scripts do not work
properly on modern browsers. Since there is no official quality control
for web pages, anyone can put up just about anything and keep it there
without updates, so long as they pay their host for server space. This
is especially true for collections of script submitted by many people,
often in the distant past.
 
C

cwdjrxyz

Stephen said:
Try this demo and use the code if you think it's OK. It's not widely
tested so I'm not guaranteeing anything:

http://www.hotspot.freeserve.co.uk/ttdemo/

Your page works properly on the most recent versions of IE6, Firefox,
Opera, Mozilla, and Netscape. There is no sound and the page layout is
not correct on the old Netscape 4.8(no problem, in my opinion, for this
old relic).

You mention that this is just a demo, but validation at W3C indicates
that it probably would be fairly easy to get the page to validate
completely. Since there was no Doctype or encoding given, I put in the
Doctype for html 4.01 transitional and the encoding of iso-8859-1
(Western Europe) to get the W3C validator to work. The script tag needs
a type added. There are a few errors that look minor and that should be
easy for you to correct.
 
S

Stephen Chalmers

cwdjrxyz said:
Your page works properly on the most recent versions of IE6, Firefox,
Opera, Mozilla, and Netscape. There is no sound and the page layout is
not correct on the old Netscape 4.8(no problem, in my opinion, for this
old relic).

It's a DOM script so NN4 is well out of it and users see a message to
that effect. As for layout, that browser loses the plot as soon as it
sees a CSS margin specifier, so no surprise.
You mention that this is just a demo, but validation at W3C indicates
that it probably would be fairly easy to get the page to validate
completely. Since there was no Doctype or encoding given, I put in the
Doctype for html 4.01 transitional and the encoding of iso-8859-1
(Western Europe) to get the W3C validator to work. The script tag needs
a type added. There are a few errors that look minor and that should be
easy for you to correct.

I've corrected that now, but it wouldn't affect operation. I think the
best one can hope is that it doesn't cause errors anywhere.
 
C

cwdjrxyz

Stephen said:
I've corrected that now, but it wouldn't affect operation. I think the
best one can hope is that it doesn't cause errors anywhere.

Yes, the page now validates at W3C.

My computer is somewhat like my closets, and is stuffed with many old
things that really should be cleaned out. I happen to have an old MSNTV
Viewer, a program to simulate how a page viewed on the old MSNTV set
top box with the 2.8 upgrade. This is absolutely of no current
practical importance, since users of the old boxes were forced to
upgrade versions long ago. This unit does not use a cursor. Rather the
first clickable area at the top left is outlined in a yellow box and
one moves from one clickable area to another by using arrow buttons
that point up,down, left, right on the remote control for the box. Of
course there can be no cursor effect activated by moving a cursor.
However your page viewed correctly on this very old relic, and you were
able to click to go to a link such as Google. Interesting, but
completely useless at this late date. So far as I know, the
MSNTV(former WebTV) boxes are only used in the US, although there was
some usage in Canada at one time. Their old boxes have been replaced by
a new one that uses a watered down IE6 and is completely different from
the old boxes. A small number, likely well under one million, of the
old boxes still are in use. The MSNTV service also was built into a few
small dish satellite TV receivers at one time. Most users of the MSNTV
boxes these days appear to be older people, most of whom have never
used a computer before. Although the old boxes are now a very small
target, someone in the US who is selling health products, prune juice,
etc may need to consider how their pages view on this old relic.
Javascript and CSS support for these old boxes is best described as
strange.
 
T

Thomas 'PointedEars' Lahn

Stephen said:
cwdjrxyz said:
Your page works properly on the most recent versions of IE6, Firefox,
Opera, Mozilla, and Netscape. There is no sound and the page layout is
not correct on the old Netscape 4.8(no problem, in my opinion, for this
old relic).

It's a DOM script so NN4 is well out of it [...]

Not true.

1. DOM is a concept that exists since NN3/IE3. You are confusing this
with "W3C DOM".

<URL:http://www.w3.org/TR/DOM-Level-2-HTML/glossary.html>

2. NN 4.8 (released 2002 CE), which is the latest of the Netscape browsers
using the old Mozilla codebase (and which I therefore do not consider a
relic), supports the proprietary `embed' element and has means to access
the corresponding DOM object, through the `document.embeds' collection,
provided a handling plugin is installed.


PointedEars
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 5/29/2006 12:07 PM:
Stephen said:
cwdjrxyz said:
Stephen Chalmers wrote:
Try this demo and use the code if you think it's OK. It's not widely
tested so I'm not guaranteeing anything:

http://www.hotspot.freeserve.co.uk/ttdemo/
Your page works properly on the most recent versions of IE6, Firefox,
Opera, Mozilla, and Netscape. There is no sound and the page layout is
not correct on the old Netscape 4.8(no problem, in my opinion, for this
old relic).
It's a DOM script so NN4 is well out of it [...]

Not true.

1. DOM is a concept that exists since NN3/IE3. You are confusing this
with "W3C DOM".

<URL:http://www.w3.org/TR/DOM-Level-2-HTML/glossary.html>

In 2006 those two terms are synonymous, even if the W3C says they aren't.
2. NN 4.8 (released 2002 CE), which is the latest of the Netscape browsers
using the old Mozilla codebase (and which I therefore do not consider a
relic),

A 4 year old browser based on almost 10 year old code isn't a relic?
 
S

Stephen Chalmers

Thomas said:
2. NN 4.8 (released 2002 CE), which is the latest of the Netscape browsers
using the old Mozilla codebase (and which I therefore do not consider a
relic),

It never can deserve to called a relic, in the sense that such a
description cannot be applied to anything unfinished. The continued
distribution of any item does not prevent it from being obsolete.
supports the proprietary `embed' element and has means to access

I think you'll find it's not the only one that does, which is just as
well.
the corresponding DOM object, through the `document.embeds' collection,
provided a handling plugin is installed.

Use of that plugin is well documented, but I saw little point in
cluttering the code with a branch whose probability of execution rivals
that of the client rendering the containing document intelligibly,
without rupturing itself or insisting that one or more layers don't
exist.
 
T

Thomas 'PointedEars' Lahn

Stephen said:
It never can deserve to called a relic, in the sense that such a
description cannot be applied to anything unfinished.

Pardon? It was a /release/. One that corrected several errors of previous
releases. Not all errors, yes. But that does not mean it is unfinished.
The continued distribution of any item does not prevent it from being
obsolete.

But its continued use does.
I think you'll find it's not the only one that does,

But it is the only one that only supports this approach for multimedia
objects. (Although I have the idée fixe of having seen it working with
a single `object' element once. Maybe that was on Windows then.)
which is just as well.

Sorry, I am not familiar with this idiom in that context. Please explain.
Use of that plugin is well documented, but I saw little point in
cluttering the code with a branch whose probability of execution rivals
that of the client rendering the containing document intelligibly,
without rupturing itself or insisting that one or more layers don't
exist.

Not understood. Anyway, there are Valid workarounds to have NS4 ignore
stylesheet rules that have harmful effects on it (because of its bugs).


PointedEars
 
T

Thomas 'PointedEars' Lahn

Stephen said:
What would be the comparative bandwidth requirement of such a solution?

Probably less than serving it as is. Flash compresses audio content well.


PointedEars
 
C

cwdjrxyz

Stephen said:
What would be the comparative bandwidth requirement of such a solution?

You appear to be using all wav sound files, which are uncompressed. I
see no problem with this for such short sound files, but then I am on
SBC/Yahoo DSL Professional which gives me an over 2.5 mbps download
rate. Just about any other sound format will compress the wav sound
files considerably, and you can adjust compression to as much as you
can stand the quality of the sound. I like .wma for the web. I like a
..rm Real file just as well, but fewer viewers are likely to have a
player that can handle this. The WMP, Real, QT, and Winamp players, to
name a few, all support .wma files, and many also support .wmv video
files if you want to include video as well as audio. Then there are
many other audio options that will compress including ogg vorbis, mp3,
mp4 etc. There is really a glut of available audio and video formats
that compress. I like flash only for banners, cartoons, and such, but
not for serious audio or video. Part of the reason is that much of the
flash code is far from standards complient, and it is more difficult to
get around this and use proper modern code than for some of the other
media. Of course the other media formats also are often used in a non
standards compliant way. I usually capture sound completely
uncompressed as PCM (high resolution wav). I use up to 24 bit, 96 khz
when the source merits this. Then I use any of many available programs
to edit the sound if needed and to convert it to a format for use on
the web. Microsoft has a free encoder for wma and wmv formats, and Real
has a free encoder for their formats. Despite all I have said, I likely
would stick to the wav files for your case unless you expect many
viewers on exceptionally slow dialup connections.
 
G

gmgj

I am doing dictionary type pronunciations. I use 8khz 8 bit mono to
record . I get files around 400k for most words. I like Steve's
approach. With some simple DHTML and a dynamic embed, you can create
some pretty spiffy navigation, without having to learn or buy anything
else
 

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top