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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.