Hey I have the following function which works great in JQuery, but for many reasons I require it in plain JS.
$('audio').on("play pause ended", function () {
document.title = document.title.replace("\u25B6", "")
$("audio").each(function (index) {
if (!this.paused) {
document.title = "\u25B6 " + document.title.replace("\u25B6 ", "")
return false;
}
})
});
I've attempted to convert it to plain JS (see below) however it's just coming up with the following error: TypeError: undefined is not a function (evaluating 'sound.addEventListener')
var sound = document.getElementsByTagName('audio');
sound.addEventListener('play pause ended', function () {
document.title = document.title.replace('\u25B6', '')
sound.each(function (index) {
if (!this.paused) {
document.title = '\u25B6 ' + document.title.replace('\u25B6 ', '')
return false;
}
})
});