Kwan Him Lam
Kwan Him Lam

Reputation: 71

HTML5 Video How can I replay a video by click a test which make by onended?

<video onended="prtlog('play again?');">

When the video ends, "play again" will show under the video.

How can I change/add code to my program that then when user clicks "play again", the video will play again?

Upvotes: 7

Views: 17644

Answers (2)

emillio5
emillio5

Reputation: 193

<video loop>

The html attribute "loop" will replay your video automatically.

Upvotes: -1

Keith V
Keith V

Reputation: 730

If you want to add a replay button to your video just check when curVid.currentTime == curVid.duration and have the button display. The code for the button is below. You can display your button whenever you'd like and it will always restart your video.

var curVid = getElementById('videoClip');

$(document).on('click','#replayBtn',function(){
    curVid.pause();
    curVid.currentTime = '0';
    curVid.play();
});

Upvotes: 24

Related Questions