This question answered the question of its owner with the following solution:
I managed to fix it as follows.
function toggleState(item, soundobj) { var thissound = document.getElementById(soundobj); if (item.className == "play") { thissound.play(); item.className = "pause"; } else { thissound.pause(); item.className = "play"; } }
I also managed to get the name of the current track. For example, you click on a song and it will appear after, say, "Now play the song blablabla."
I will show you a working example below.
HTML:
<option id="1" title="Now Playing." value="URL.mp3">Song name</option>
JavaScript:
audioURL = document.getElementById('mylist'); var f = audioURL.options[audioURL.selectedIndex].title; //Here is title document.getElementById("demo").innerHTML = f; //output to f at demo elem.
source share