Sound with JavaScript but not Flash
Written by on January 31st, 2007 in Ajax News.
Reinier Zwitserloot wanted to see if he could add sound support without embedding a Flash bridge, and shared his research in his article on Sound in Web Browsers without Flash.
Check out his test page for a Sound Check
An example API
JAVASCRIPT:
-
-
function sound2Play() {
-
if ( !sound2Embed ) {
-
sound2Embed = document.createElement(”embed”);
-
sound2Embed.setAttribute(”src”, “machinegun.wav”);
-
sound2Embed.setAttribute(”hidden”, true);
-
sound2Embed.setAttribute(”autostart”, true);
-
} else sound2Stop();
-
sound2Embed.removed = false;
-
document.body.appendChild(sound2Embed);
-
}
-
-
function sound2Stop() {
-
if ( sound2Embed && !sound2Embed.removed ) {
-
document.body.removeChild(sound2Embed);
-
sound2Embed.removed = true;
-
}
-
}
-
Source: Ajaxian
Original Article: http://ajaxian.com/archives/sound-with-javascript-but-not-flash