I have a simple video html5 tag, bound to an "ended" event:
$('#video').show().trigger("play").bind('ended', function () {
//code
}
Since I'm "showing" and "hiding" this through a button click, I wanted to make it return to the first frame on that last function, so it would start from the beginning the next time it appears (right now it starts from the ending, and it causes a nasty flicker when it goes from the last to the first frame).
Is that possible with jQuery?
Thanks in advance!
解决方案
You can use something like
$('#video').show().trigger("play").bind('ended', function () {
this.currentTime = 0;
}
You can only set the currentTime if the loadedmetadata event has passed.