आप एक संस्करण है कि पुराने ब्राउज़र के लिए काम करता है चाहते हैं, मैं इस पुस्तकालय बना दिया है:
function Sound(source,volume,loop)
{
this.source=source;
this.volume=volume;
this.loop=loop;
var son;
this.son=son;
this.finish=false;
this.stop=function()
{
document.body.removeChild(this.son);
}
this.start=function()
{
if(this.finish)return false;
this.son=document.createElement("embed");
this.son.setAttribute("src",this.source);
this.son.setAttribute("hidden","true");
this.son.setAttribute("volume",this.volume);
this.son.setAttribute("autostart","true");
this.son.setAttribute("loop",this.loop);
document.body.appendChild(this.son);
}
this.remove=function()
{
document.body.removeChild(this.son);
this.finish=true;
}
this.init=function(volume,loop)
{
this.finish=false;
this.volume=volume;
this.loop=loop;
}
}
प्रलेखन:
Sound
तीन तर्क लेता है। ध्वनि का यूआरएल, वॉल्यूम (0 से 100 तक), और लूप (लूप के लिए सच, गलत नहीं लूप)।
stop
start
के बाद (remove
के विपरीत) की अनुमति दें।
init
तर्क मात्रा और लूप को दोबारा सेट करें।
उदाहरण:
var foo=new Sound("url",100,true);
foo.start();
foo.stop();
foo.start();
foo.init(100,false);
foo.remove();
//Here you you cannot start foo any more
आधुनिक ब्राउज़रों में, आप इस्तेमाल कर सकते हैं [एचटीएमएल 5 का '