I am making a Chrome extension that involves multiple audio players. I currently have play buttons that work for each individual audio, and I have also made the dummy version of a seek slider. I would like to link the audio with the slider so that I can control the progress of the audio and also see the time. Here is what I have now:
popup.js
const manageAudio = (audio) => {
const playButton = audio.nextElementSibling;
let isPlaying = false;
audio.onplaying = function () {
isPlaying = true;
};
audio.onpause = function () {
isPlaying = false;
};
playButton.addEventListener("click", function () {
if (isPlaying) {
audio.pause();
} else {
audio.play();
}
})
$(playButton).click(function () {
$(playButton).toggleClass("paused");
});
};
$(document).ready(function () {
for (const audio of $('audio')) {
manageAudio(audio);
}
});
popup.html
<audio src=".../...mp3" type="audio/mp3"></audio>
<div class="play"></div>
<div class="controls">
<input type="range" value="0" class="slider">
<p>0:00</p>
<p class="endtime">3:25</p>
</div>
The page looks like this:
Any help would be greatly appreciated!!