+ 4
[JS] Playing sound
Hey, here a small code: var playlist = new Array('audio1.mp3, 'audio2.mp3', 'audio3.mp3'); var audio = new Audio(); $('mydiv').hover(e=> { audio.src = playlist[1]; audio.play(); }); imagine we have more than one time this "mydiv". if I'm hover the first, and just after I'm hover the 2nd, etc... the sound will stop to lets play the new. I tried too with mouseenter How could I do to do not stop playing sound, while news are running ?
2 Réponses
+ 4
You mean play all together?
probably you should make separate objects for each audio. i.e.
var playlist = new Array('audio1.mp3, 'audio2.mp3', 'audio3.mp3');
$('mydiv').hover(e=> {
var audio = new Audio();
audio.src = playlist[1];
audio.play();
});
+ 3
thanks Niush sitaula