P粉6829875772023-08-14 12:28:59
Using JavaScript and the HTML5 Audio API, you can do something like this:
var snd1 = new Audio(); var src1 = document.createElement("source"); src1.type = "audio/mpeg"; src1.src = "audio/Dombra.mp3"; snd1.appendChild(src1); var snd2 = new Audio(); var src2 = document.createElement("source"); src2.type = "audio/mpeg"; src2.src = "audio/(TESBIHAT).mp3"; snd2.appendChild(src2); snd1.play(); snd2.play(); // 现在两者将同时播放
I tested in Chrome v. 20 and it seems to work :)
The<source>
tag is used to specify different formats of the same file - this way the browser can choose another format as a fallback if the first format is not supported. That's why your own proposed solution doesn't work.