[JS] Playing sound | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 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 ?

15th Oct 2018, 6:58 PM
NoxFly
NoxFly - avatar
2 ответов
+ 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(); });
15th Oct 2018, 7:26 PM
Niush
Niush - avatar
+ 3
15th Oct 2018, 8:28 PM
NoxFly
NoxFly - avatar