I have the following as part of my html (once for each of several songs):
<audio
name="aMedia"
id="aMedia"
controls
preload="auto">
<source src="audio/mysong.m4a">
</audio>
I want to determine if the above standard play button was pressed to play the song. If so, I need to first stop all other songs that can be played, for example,
function stopAllSongs()
{
var allMedia = document.getElementsByName(theMedia), thisMedia;
for (m=0; m < allMedia.length; m++)
{
thisMedia = allMedia[m];
if (thisMedia.isPlaying())
thisMedia.pause();
}
}
I have seen successful use <input ...>to do what I desire; but I would like to avoid this if possible.
Any ideas?
source
share