اذهب إلى المحتوى
  • 0

كيف أشغّل ملف صوتي باستخدام Javascript؟

PhpMan

السؤال

Recommended Posts

  • 0
new Audio('<url>').play()

إذا كنت تريد نسخة تعمل مع المتصفحات القديمة فجرب هذه:

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; } }

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

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

×   جرى استعادة المحتوى السابق..   امسح المحرر

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

  • إعلانات

  • تابعنا على



×
×
  • أضف...