How to play a mp3 using Javascript?

aF. picture aF. · Jul 4, 2012 · Viewed 93.3k times · Source

I have a directory on my website with several mp3's. I dynamically create a list of them in the website using php.

I also have a drag and drop function associated to them and I can select a list of those mp3 to play.

Now, giving that list, how can I click on a button (Play) and make the website play the first mp3 of the list? (I also know where the music is on the website)

Answer

Ties picture Ties · Jul 4, 2012

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