I'm using HTML <embed> to play music in the background on a site, and I have a list of songs I'd like it to play. Is there some way to detect the end of the song and start the next?

soundEmbed = document.createElement("embed")
soundEmbed.setAttribute("src", "Music/"+Song)
soundEmbed.setAttribute("hidden", true)
soundEmbed.setAttribute("autostart", true)

This allows me to change songs (Bound to a button press) but I'd like it to run automatically. Any help would be appreciated.

Thanks Ryan, that was rather informative, though quite a bit more digging through than I expected. Over all I had to switch from using <embed> to using <audio> to get it to work.

soundEmbed = document.createElement("audio")

function RandomSong(){
Song = SongList[Math.random()*SongList.length]
soundEmbed.setAttribute("src", "Music/"+Song+".mp3")

Thanks for the help!