embed sound, but keep page valid

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
siteresources
Forum Newbie
Posts: 12
Joined: Wed Nov 12, 2003 6:38 am
Location: Sidman, Pennsylvania

embed sound, but keep page valid

Post by siteresources »

hi,

This is driving me crazy. the validator is complaining of the embed tag. I'm using xhtml 1.0 strict, by the way. but is there any way to put sound into a page and still keep it valid? and not like background sound, but almost like sound effects. like if there is an error, one sound occurs, if something happened successfully, another occurs, etc. basically dealing with sounds no larger than 3 kb.

Brandon
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

I believe you can use Javascript to write out the EMBED tag for sound, and it'll validate.
siteresources
Forum Newbie
Posts: 12
Joined: Wed Nov 12, 2003 6:38 am
Location: Sidman, Pennsylvania

Post by siteresources »

you mean using document.write? ok, but anothe rproblem I seem to have is that, smaller sounds don't seem to want to play? I mean if it is larger than a few kb it will be fine but it seems that if the sound is only a few kb it is silent...I"ll have to try this out though

also, is it valid in javascript to dynamically give the src of the embed? like I have:

Code: Select all

<embed id="sound"></embed>
and then farther down, when an error happens:

Code: Select all

document.getElementById('sound').src="sounds/error.mp3";
?



Brandon
microthick wrote:I believe you can use Javascript to write out the EMBED tag for sound, and it'll validate.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Yes, use document.write.

I don't know the answer to your other questions though.
maniac9
Forum Commoner
Posts: 55
Joined: Fri Aug 01, 2003 12:27 am
Location: Arkansas, USA
Contact:

Post by maniac9 »

Code: Select all

<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
    <param name="FileName" value="sound.wav" />
</object>
Maybe that will work as well? It uses the object tag which validates with XHTML Strict
siteresources
Forum Newbie
Posts: 12
Joined: Wed Nov 12, 2003 6:38 am
Location: Sidman, Pennsylvania

Post by siteresources »

hi,

yeah, but...I didn't hear anything when I ran it. does that support mp3 also? what is all that...stuff...in the classid for?

Brandon
maniac9 wrote:

Code: Select all

<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
    <param name="FileName" value="sound.wav" />
</object>
Maybe that will work as well? It uses the object tag which validates with XHTML Strict
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

The <embed> tag CAN NOT be used with XHTML.

Check out the following page for info about the <object> tag....
http://www.w3schools.com/tags/tag_object.asp

Also check out this page to see what <tags> can be used with each XHTML version....
http://www.w3schools.com/xhtml/xhtml_reference.asp

You need to do a bit of learning my friend, don't just stamp your feet and scream when something isn't working. Strict XHTML pages take some time to get right so don't rush it. You'll need to rethink the way you write your code.


EDIT: Why don't you just use a Flash file to store your sounds and then trigger them off with a bit of JavaScript?
siteresources
Forum Newbie
Posts: 12
Joined: Wed Nov 12, 2003 6:38 am
Location: Sidman, Pennsylvania

Post by siteresources »

hi,

yeah I looked at that. I'm not quite sure what the classid attribute is for? or what that value means. I'll keep working with this.

I wish I could ignore this, but I can't. What, exactly, is the need for that rude part at the end there? I mean, no offense, but you could have said that a little bit more tactfully. I've seen quite a few comments similar to that around the forum and I just don't get it. sure, I know I need to learn and I'm not asking anyone to do a thing for me, but please, please just point out tactfully that I should do some research on the matter, instead of shaming the person your talking to. I don't care how much knowledge a person has, what in the world is the need for that? excuse my bluntness.

anyway, thanks for the help.

Brandon
Gen-ik wrote:The <embed> tag CAN NOT be used with XHTML.

Check out the following page for info about the <object> tag....
http://www.w3schools.com/tags/tag_object.asp

Also check out this page to see what <tags> can be used with each XHTML version....
http://www.w3schools.com/xhtml/xhtml_reference.asp

You need to do a bit of learning my friend, don't just stamp your feet and scream when something isn't working. Strict XHTML pages take some time to get right so don't rush it. You'll need to rethink the way you write your code.


EDIT: Why don't you just use a Flash file to store your sounds and then trigger them off with a bit of JavaScript?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

siteresources wrote:What, exactly, is the need for that rude part at the end there?
What 'rude' part? I was simply saying that you can't just write a Strict XHTML page in the same way you write normal HTML. The comment about the need to learn was as it sounds, you need to learn, as we all do, and attempting to use an <embed> tag in an XHTML page was evidence of this.

The classid bit of <objects> is simply used to tell the browser what it needs to use in order to use the object properly. Everything from Flash to Quicktime has it's own classid.

I still feel you would be better off using a Flash movie for the sound effects though... and without looking into it any futher I think it may be the only way you will be able to do it in XHTML... but don't quote me on that.
siteresources
Forum Newbie
Posts: 12
Joined: Wed Nov 12, 2003 6:38 am
Location: Sidman, Pennsylvania

Post by siteresources »

I must've mistook it then, sorry about that.

all right. that classid part looks cryptic to me :)

I'll go looka bout flash, then. I've never really looked into flash before so that should be interesting.

thanks
Gen-ik wrote:
siteresources wrote:What, exactly, is the need for that rude part at the end there?
What 'rude' part? I was simply saying that you can't just write a Strict XHTML page in the same way you write normal HTML. The comment about the need to learn was as it sounds, you need to learn, as we all do, and attempting to use an <embed> tag in an XHTML page was evidence of this.

The classid bit of <objects> is simply used to tell the browser what it needs to use in order to use the object properly. Everything from Flash to Quicktime has it's own classid.

I still feel you would be better off using a Flash movie for the sound effects though... and without looking into it any futher I think it may be the only way you will be able to do it in XHTML... but don't quote me on that.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Don't quote me on this, but I don't believe all browsers interpret the OBJECT tag. If you're looking for true cross-browser support, you might need to still use EMBED.

I'm referring to older NS mostly.
Post Reply