Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 368
Kwan Him Lam Avatar asked Nov 25 '11 17:11

Kwan Him Lam


1 Answers

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();
});
like image 96
Keith V Avatar answered Nov 15 '22 04:11

Keith V