JavaScript30 icon indicating copy to clipboard operation
JavaScript30 copied to clipboard

save video currenttime to local storage and get the time back when the page is reloaded also set video currenttime when you scrub the video.

Open akinsikuoluwafemi opened this issue 3 years ago • 0 comments

What I did

1: I created a variable using let called currentVideoTime like so Screenshot 2022-06-22 at 14 37 55

2: I am setting the video current time to local storage every time the togglePlay function is being clicked, so local storage always has the correct current time after a pause and a play is triggered, like so

Screenshot 2022-06-22 at 14 38 50

3: I created a DOMContentLoaded event listener so when the page is reloaded, it saves and gets the current time and passes it to the video player, so with this the currentTime state is tracked on the fly, like so Screenshot 2022-06-22 at 14 41 32

4: I also set the video.current time when the video is also scrubbed, the scrub time will now be the new current time, like so

Screenshot 2022-06-22 at 14 45 41

akinsikuoluwafemi avatar Jun 22 '22 13:06 akinsikuoluwafemi