Skip to content

Instantly share code, notes, and snippets.

@M3kH

M3kH/SoundTrack Secret

Created March 3, 2014 13:09
Show Gist options
  • Save M3kH/dea521b049ed7377e377 to your computer and use it in GitHub Desktop.
Save M3kH/dea521b049ed7377e377 to your computer and use it in GitHub Desktop.
Add at your website you favorite song from You Tube with ?sound=YouTubeViedoCode
(function(){
var st = {
urlParam : function(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && unescape(result[1]) || false;
},
appendSound: function(song){
var b = document.getElementsByTagName("body")[0],
c = document.createElement('div');
c.innerHTML = '<iframe width="0" height="0" src="//www.youtube.com/embed/'+song+'?autoplay=1&loop=1" frameborder="0"></iframe>';
b.appendChild(c.firstChild);
},
init: function(){
var bgSound = st.urlParam("sound");
if(bgSound != false){
st.appendSound(bgSound);
}
}
};
return st.init;
}())();
@M3kH
Copy link
Author

M3kH commented Mar 4, 2014

Small demo: http://ideabile.com/?sound=rVqAdIMQZlk (R2D2 - Ghostwriter)

@trichome
Copy link

trichome commented Mar 4, 2014

i feel as if this fits the website better: http://ideabile.com/?sound=JGw8DWctAts

Cool idea though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment