What is the best way to measure "Watch Time" on a video platform?

I own a video-sharing service and try to keep track of how long videos are viewed in order to give my customers more recommendations. I’m curious about how the data is stored for analytics.
Could someone please tell me the best way to go about doing this?

You can use the playback update event which is fired by the video player and on each update you can sync that data in the backend via an API.

You will have to send more data like the user related information, video related information and a unique ID for a unique playback.

This playback id is used to aggregate the data to get the maximum playhead time for a particular playback.