arabhishek's avatar

How to store playback time of video?

I want to store playback time of video in mysql database, so that when a user pause or close the connection, the video will be played from the same time where he left off. I need the data type of playback time which is required to store it, and how it is implemeted in real time?

0 likes
1 reply
martinbean's avatar

@arabhishek Create a bookmarks table with foreign keys pointing to a user and a video. In your video player, periodically make an AJAX request to write a bookmark whilst the video is being watched, that stores the current time of the video:

axios.post('/bookmarks', {
    'video_id': videoId,
    'current_time': videoElement.currentTime, 
});

When a user opens a video page, you can check if they have a bookmark for the current video and if so, automatically set the video’s currentTime property to the current_time in the bookmark.

1 like

Please or to participate in this conversation.