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

2

7

<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?

Isoagglutinin answered 25/11, 2011 at 17:25 Comment(0)
D
23

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();
});
Dissimilar answered 15/5, 2013 at 17:53 Comment(0)
W
-1
<video loop>

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

Weatherbound answered 6/10, 2023 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.