Forum Discussion
Video Played, Completed… (Custom xAPI)
A similar question came up in the community a couple of years ago, and I think the discussion could still be relevant today. I recommend reviewing that thread, as it provides useful patterns you can apply to your current project. xAPI for user pausing and playing video
In my implementation, I rely on the video element’s ontimeupdate event as the core mechanism for tracking playback. This event fires multiple times per second while the video is playing, which allows very granular control. Using this, you can decide exactly when to update Storyline variables or trigger xAPI statements. For example:
- When the video starts playing
- When it is paused
- When it reaches the end
- When playback crosses specific timestamps
- Or even how many times the learner presses Play or Pause
By combining these event triggers with xAPI, you can build detailed tracking such as:
- Counting how many times the learner paused
- Detecting whether they reached a specific point in the timeline
- Sending periodic "heartbeat" statements during playback
- Marking the video as completed once it ends
- Logging specific user interactions like seeking or skipping
This approach avoids flooding your LRS with statements and gives you precise control over when information is sent. The key idea is that ontimeupdate gives you high-resolution timing control, but you should only send xAPI at meaningful moments (e.g., play/pause events, checkpoints, or timed intervals), not on every update tick.
If you structure your script around these events, you can create a robust and efficient tracking system that captures any type of interaction you need—play counts, pauses, rewinds, timestamp milestones, or full progression tracking similar to YouTube analytics.
Very cool!
My contributions in this community tend to focus on out-of-the-box solutions for xAPI tracking of student performance, while building-in conformance to make the measurements most effective in our LRS.
The solution I gave uses the W3ID Video Profile to loosely detect and report “played” and “completed” actions, as well as total video “length”. Your solution offers more precise detection, and — as you suggest — the potential to measure many results too, including “time” or percent “progress” within the video at the instance of each action.
If you could add a routine to your JavaScript to extract a timestamp, then the followers of this thread could use it to report it using a result.extension inserted in the custom xAPI…
"result": {
"extensions": {
"https://w3id.org/xapi/video/extensions/time": %VideoTime%
}
},
Thanks for your follow-up. 😄
- Nedim2 days agoCommunity Member
Yes, we can report virtually any video interaction as long as we have JavaScript supporting it. For example, we can create a series of video events that send xAPI statements when specific actions occur in JavaScript, such as onplay, onpause, onended, onseeked, ontimeupdate, and so on.
I was particularly happy with the “seeked” event, because it allows us to track both the from and to timestamps directly in JavaScript. Similarly, the “progressed” event can be configured to fire at specific intervals, such as every 5% of video completion or at any percentage milestone, giving precise reporting on how far learners have watched the video.
Screenshots shown are taken from the Verocity LRS account, demonstrating how the events are captured and reported.
Related Content
- 4 months ago
- 4 months ago