SoundCloud audio in your vBulletin forums using UBBC
April 28th, 2009
Here’s something quick I wrote up for a friend. It allows you to embed SoundCloud audio files into forum posts. Just put the code into the header or footer of your forum. This was tested on ProBoards.com which appears to be a hack-up of vBulletin but it should work for the newer versions as well.
<script type="text/Javascript"> // SoundCloud UBBC for Posts by Ian McLean var perPage = 20; var ubbcURL = "http://a1.soundcloud.com/images/soundcloud-logo-simple.png"; // No need to edit var aTD = document.getElementsByTagName("TD"); var curr = 0; if(location.href.match(/action=display/i)){ for(a=0;a<aTD.length && curr < perPage;a++){ if(aTD[a].colSpan == 3 && aTD[a].vAlign == "top" && aTD[a].firstChild.nodeName.match(/^(#text|hr)$/i) && aTD[a].innerHTML.match(/\[sc\](.+?)\[\/sc\]/gi)){ curr = curr+parseInt(aTD[a].innerHTML.match(/\[sc\](.+?)\[\/sc\]/gi).length); aTD[a].innerHTML = aTD[a].innerHTML.replace(/\[sc\](.+?)\[\/sc\]/gi,'<div style="font-size: 11px;"><object height="81" width="100%"> <param name="movie" value="http://player.soundcloud.com/player.swf?track=$1"></param> <param name="allowscriptaccess" value="always"></param> <param name="wmode" value="transparent"></param> <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?track=$1" type="application/x-shockwave-flash" width="100%" wmode="transparent"> </embed> </object> <div style="padding-top: 5px;">'); } } } else if(document.postForm){ if(location.href.match(/quote=/i)){ var m = document.postForm.message; m.value = m.value.replace(/\[sc\].+?\[\/sc\]/gi,""); } if(document.postForm.color){ var h = document.createElement("span"); h.innerHTML = "<a href='javascript:add(\"[sc]\",\"[/sc]\");'><img src='"+ubbcURL+"' border='0' alt='SoundCloud' /></a>"; document.postForm.color.parentNode.appendChild(h); } } </script>
Now use [sc]my track name[sc] in your forum post to include a SoundCloud file.