UserIsCorrupt
UserIsCorrupt

Reputation: 5025

Trouble with audio tag, jQuery, and currentTime

<audio src="file.ogg" type="audio/ogg" controls="controls"></audio>​

Why is it that this jQuery/JavaScript works:

var audio = $('audio').get(0);
audio.play();

But this doesn't?:

var audio = $('audio').get(0);
audio.currentTime = 20;
audio.play();

​jsFiddle

Upvotes: 3

Views: 3882

Answers (1)

Andy Ecca
Andy Ecca

Reputation: 1969

Try

var audio = $('audio');
audio.bind('canplay', function() {
        this.currentTime = 20;
});
audio.get(0).play();

Upvotes: 4

Related Questions