Audio loop setting?

Yes.

(I have not tested that code I’ve given you)

Ok no worries. I’ll try and will let you know how it works out. Thanks :slight_smile:

Didn’t reset to 0:00 on iPad. Trying desktop now…

Does it need all the code

addEventListener("ended", (event) => {});

onended = (event) => {};


audio.addEventListener("ended", () => {currentTimeContainer.textContent = "0.00";});

Or just this

audio.addEventListener("ended", () => {currentTimeContainer.textContent = "0.00";});

Just:
audio.addEventListener("ended", () => {currentTimeContainer.textContent = "0.00";});

I have not checked but we may need to also reset the progress bar.

1 Like

Yeah it didn’t work out with just that. Ok we could try that too.

Where do I go for that?

There’s a lot of code there to try to work out what it’s doing, especially without being able to run it. I am therefore running out of suggestions. We could check whether the ‘ended’ event is happening by changing that inserted code to:

audio.addEventListener("ended", () => {
  currentTimeContainer.textContent = "0.00";
  alert("END");
});

Do you see an alert box pop up when the music reaches the end? If so, what is the time showing?

Ok sounds cool. I’ll try that now and will let you know on it.

By the way I did some search earlier today and found this that may help…

$('#progressbar').progressbar('option', 'value', 0);

Just need to change to the id or class that I have to work with it. If it does…

Ok I didn’t get any alert.

How about this?

audioElement.addEventListener("ended", () => {

  playButton.dataset.playing = "false"

  pauseIcon.classList.add("hidden")

  playIcon.classList.remove("hidden")

  progressFilled.style.flexBasis = "0%"

  audioElement.currentTime = 0

  audioElement.duration = audioElement.duration

})

Nope nevermind. I tried. Sigh…

Also tried this but didn’t work out either

var audio = document.getElementByTagName('audio');
audio.addEventListener("ended", function(){
    this.currentTime = 0;
    this.pause();
});

This works:

audio.addEventListener("ended", () => {
  playIconContainer.click();
  cancelAnimationFrame(raf);
  currentTimeContainer.textContent = "0.00";
  seekSlider.value = "0";
});

1 Like

Hi @Archibald . Ok looks cool. I will look at it and try it soon. Thanks.

Is there anything I can do for the mute icon that’s on the left side in the iPad? It displays correctly on desktop, but some reason it doesn’t on iPad.

It may be best to start a new topic in this forum.

1 Like

I tried that code bit out. It still didn’t reset.

I looked through the code you sent. I’m suspicious of this

seekSlider.addEventListener('input', () => {
    currentTimeContainer.textContent = calculateTime(seekSlider.value);
    if(!audio.paused) {
        cancelAnimationFrame(raf);
    }
});

I don’t have it in mine. Could this be the problem?