Jump to content

JQuery sound plugin not playing sound...


yanjchan

Recommended Posts

I'm trying to get this JQuery sound plugin to play a sound. I have managed to make it work in onClick and onLoad events... but no luck in actualy javascript code. I don't get at all why it won't work, it just seems to skip paste.

 

function insertNewContent(liTime,liName,liText) {	
insertO = document.getElementById("outputList");
oLi = document.createElement('li');
oSpan = document.createElement('span');
oSpan.setAttribute('className','name'); //for IE's sake
oSpan.setAttribute('class','name');
oName = document.createTextNode('At '+liTime+', '+liName);
oText = document.createTextNode(liText);
oSpan.appendChild(oName);
oLi.appendChild(oSpan);
oLi.appendChild(oText);
insertO.insertBefore(oLi, insertO.firstChild);
document.title = liName+" says...";
$.sound.play('/sounds/pop.wav');</script>
}

 

The library I am using is here:

http://www.google.com/url?sa=D&q=http://dev.jquery.com/view/trunk/plugins/sound/&usg=AFQjCNGFOlQdzQaPRwqMSuIVCUFPIFGhCQ

 

By the way, this is part of an AJAX chat thing. You can ignore the beginning part, just know that this is being executed at the end of the insertion. (or, rather, it should be.)

Link to comment
https://forums.phpfreaks.com/topic/185680-jquery-sound-plugin-not-playing-sound/
Share on other sites

Sorry for the ugly code, but I've gotten this... strangely, it isn't working.

 

//inserts the new content into the page
function insertNewContent(liTime,liName,liText) {
insertO = document.getElementById("outputList");
oDiv = document.createElement('div');
oScript = document.createElement('script');
oLi = document.createElement('li');
oSpan = document.createElement('span');
oSpan.setAttribute('className','name'); //for IE's sake
oSpan.setAttribute('class','name');
oName = document.createTextNode('at '+liTime+', '+liName+' said');
oText = document.createTextNode(liText);
if (stristr(liText, document.forms['chatForm'].elements['name'].value)) {
		oDiv.setAttribute('style','font-size:200%;');
  	}
oScript.setAttribute('type','text/javascript');
oScriptText = document.createTextNode('$.sound.play(sounds/pop.mp3)');
oLi.appendChild(oScript);
oScript.appendChild(oScriptText);
oLi.appendChild(oSpan);
oSpan.appendChild(oName);
oLi.appendChild(oDiv);
oDiv.appendChild(oText);
insertO.insertBefore(oLi, insertO.firstChild);

}

 

I'm new to AJAX, so pardon my messiness.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.