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. #521
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
1: I created a variable using let called
currentVideoTime
like so
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
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
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