0

I use Jquery to play audio on my website.

var url = 'path-to-audio';
song = new Audio(url);
song.play();

It works very well. Then I create a button to set the position

<button onclick="setCurrentTime()">Set now!</button>

And its callback

function setCurrentTime()
{
    song.currentTime = 100;
}

But everytime I click on the button, the audio start from beginning ( currentTime back to 0 !?). I don't know why this happened. I appreciate your help.

MCN
  • 123
  • 1
  • 11
  • Does the server that's serving the audio file support streaming? – Cue Aug 03 '19 at 23:10
  • I'm not sure. It's on my local – MCN Aug 04 '19 at 04:55
  • Check out [this post](https://stackoverflow.com/questions/37044064/html-audio-cant-set-currenttime) there are some additional answers that may steer you in the right direction. – Cue Aug 04 '19 at 04:58
  • Used something like song.addEventListener('canplaythrough', function() { this.currentTime = 12; this.play(); }); but it still not working. It just keeps returning to 0 – MCN Aug 04 '19 at 06:07

0 Answers0