...

View Full Version : Input button used for object sound off "sort a working"



resh
08-06-2006, 10:41 PM
Hi, First time here!
I started off with an "embed" audio clip with auto play and hidden at the site and later released some people want the option to turn off the music. When looking for a way to add a stop button I found out "embed" and for that matter "bgsound" are long ago "depreciated" by W3C and will not validate. I found a novel way to implement the object tag that doesn't require classid for a particular player and it WORKS. http://alistapart.com/articles/byebyeembed Now for the button part, I found a js function to turn on/off sound at: http://aaiddennium.online.lt/blog/2006/06/12/xhtml-sounds-well/ but the example uses mouseover/out. I thought using an input button (stop only) would go good and for the most part it works. Sometimes the button will disappear when clicked or if you click randomly on the page it will glitch the page. Validator shows two uses for id "sound" and I know thats no good but I don't know exactly how to replace one and still have that function, Im sure this is the problem. Note, I can drop the input button if need be and add another Li link but not sure how to do that either. I thank you experts for listening and any help. Site: http://daisysdiner.com/love

[ <object type="audio/x-ms-wma" id="sound" data="images/love.wma" width="0" height="0">
<param name="src" value="images/love.wma" />
<param name="autostart" value="true" />
<param name="controller" value="false" />
</object>
<div id="soundbutton"><input type="button" id="sound" value="Stop Music" onclick="stopSound()" /></div> ]

Note: div id is used only for positioning the button in css.


[ function stopSound() {
var oSound = document.getElementById('sound');
if (oSound && oSound.object) {
oSound.stop();
} else {
oSound.parentNode.removeChild(oSound);
}
}

function playSound() {
var oSound = document.getElementById('sound');
if(oSound && oSound.object) {
oSound.play();
} else {
if (oSound) {
oSound.parentNode.removeChild(oSound);
}
var SOUND_FILE = 'images/love.wma';
oSound = document.createElement('object');
oSound.setAttribute('id', 'sound');
oSound.setAttribute('width', '0');
oSound.setAttribute('height', '0');
oSound.setAttribute('data', SOUND_FILE);
oSound.setAttribute('type', 'audio/x-ms-wma');
var oParam = document.createElement('param');
oParam.setAttribute('name', 'src');
oParam.setAttribute('value', SOUND_FILE);
oSound.appendChild(oParam);

oParam = document.createElement('param');
oParam.setAttribute('name', 'ShowAudioControls');
oParam.setAttribute('value', 'false');
oSound.appendChild(oParam);

oParam = document.createElement('param');
oParam.setAttribute('name', 'ShowControls');
oParam.setAttribute('value', 'false');
oSound.appendChild(oParam);

oParam = document.createElement('param');
oParam.setAttribute('name', 'AutoStart');
oParam.setAttribute('value', 'true');
oSound.appendChild(oParam);

oParam = document.createElement('param');
oParam.setAttribute('name', 'loop');
oParam.setAttribute('value', 'true');
oSound.appendChild(oParam);
document.body.appendChild(oSound);
}
} ]

Pyth007
08-07-2006, 01:46 PM
I'm thinking this is the problem too... The removeChild(oSound) would be the cause of the button disappearing, etc. Since it is the <object> and not the button that is being addressed in these functions, just change the id of the button to something like "soundbtn".



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum