Tracks per-profile video playback position and completion status across the platform. Registered as the JS service videoManager, it is used by video players to record how far a profile has watched a video and to resume playback from that point later. Position updates are queued in memory and written to the database asynchronously by a background daemon thread, so a burst of position updates from a player does not block the request that reported them. Only the most recently queued update for a given profile and video is kept, so intermediate positions can be dropped if updates arrive faster than they are persisted.
Group: Managers
Implements: StartableService
Properties
| Property | Returns | Description |
|---|---|---|
| lastException | Throwable | The most recent error raised by the background thread that persists queued video position updates, if any. |
| localQueueSize | int | Number of queued video position updates that have not yet been persisted by the background updater thread. |
Methods
getLocalQueueSize()
Returns: int
Number of queued video position updates that have not yet been persisted by the background updater thread.
getLastException()
Returns: Throwable
The most recent error raised by the background thread that persists queued video position updates, if any.
updateVideoPosition(Profile curUser, String videoHash, String videoName, int currentSec, int percPlayed)
Returns: void
Records a profile's current playback position for a video. The update is enqueued for asynchronous persistence by the background updater thread rather than being written immediately, so this call is cheap and returns without doing any database work. Does nothing if curUser is null.
| Parameter | Description |
|---|---|
curUser | the profile whose playback position is being recorded, ignored if null |
videoHash | the content hash identifying the video |
videoName | the display name of the video, stored for reference |
currentSec | the current playback position, in seconds |
percPlayed | the percentage of the video played so far, from 0 to 100 |
findVideoStatus(Profile curUser, String videoHash)
Returns: VideoPlayStatus
Looks up the persisted playback status for a profile and video. Reads directly from the database rather than the in-memory queue, so a very recently queued but not yet persisted update may not be reflected.
| Parameter | Description |
|---|---|
curUser | the profile whose playback status is being looked up |
videoHash | the content hash identifying the video |
findByProfile(Profile curUser)
Returns: List<VideoPlayStatus>
Finds every playback status recorded for a profile, across all videos and all time.
| Parameter | Description |
|---|---|
curUser | the profile to find playback status records for |
findByProfile(Profile curUser, Date from, Date to)
Returns: List<VideoPlayStatus>
Finds the playback status records recorded for a profile, optionally restricted to a date range.
| Parameter | Description |
|---|---|
curUser | the profile to find playback status records for |
from | the earliest creation date to include (exclusive), or null for no lower bound |
to | the latest creation date to include (inclusive), or null for no upper bound |