Course Progress
Overview
Course software marks a lesson complete when the student has played enough of it, and resumes where they stopped. Transcodely gives you three pieces for that:
- The player script,
player.v1.js: one file that turns an embedded Transcodely player into an object you can control and listen to from your page. Its method and event names follow Vimeo’s player library wherever the meaning is the same. - Completion counted from what the viewer actually played, not from seeking to the end.
- Server-side progress per viewer, when the player URL carries a playback token with a viewer id: cross-device resume, a
video.viewer.completedwebhook, and calls to read and erase progress.
Add the player script
<iframe id="lesson"
src="https://play.transcodely.com/v/vid_a1b2c3d4e5f6g7?token=ptk_eyJhbGciOi..."
allow="autoplay; fullscreen; picture-in-picture" allowfullscreen
style="width: 100%; aspect-ratio: 16 / 9; border: 0"></iframe>
<script src="https://play.transcodely.com/player.v1.js"></script>
<script>
const player = new Transcodely.Player(document.getElementById('lesson'));
player.on('completed', () => markLessonDone());
</script>As an ES module:
<script type="module">
import { Player } from 'https://play.transcodely.com/player.v1.mjs';
const player = new Player(document.getElementById('lesson'));
</script>Load the versioned URL. player.v1.js only ever gains additions within v1 and is cached for a year; a breaking change would ship as player.v2.js. https://play.transcodely.com/player.js redirects to the current version, but a versioned URL never changes under you.
The script has no dependencies. Two players on one page work independently: each only listens to its own iframe.
Constructor
new Transcodely.Player(element, options)
elementis an<iframe>whosesrcis a Transcodely player page, or a container element (or its id) in which the script creates the iframe for you, 16:9 and full width. In container mode,options.url(a player page URL) is required.- Constructing a second
Playerfor the same iframe returns the same instance.
<div id="lesson-container"></div>
<script>
const player = new Transcodely.Player('lesson-container', {
url: 'https://play.transcodely.com/v/vid_a1b2c3d4e5f6g7?token=ptk_eyJhbGciOi...',
});
</script>Methods
Every method returns a Promise. A method called before the player is ready waits for it, and every call gives up after 10 seconds with { name: "TimeoutError" }. Calls still waiting when you call destroy() reject with { name: "DestroyedError" }, and a command the player refuses rejects with { name: "PlayerError" }.
Construct the Player right after the iframe is in the page: events the player sent before the script attached, completed included, are not replayed. The script uses modern JavaScript (class private fields), so it needs Safari 14.1 or later, or any current Chrome, Firefox or Edge.
| Method | Resolves with |
|---|---|
ready() | undefined, once the player has loaded the video |
play() | undefined. Rejects with { name: "PlayRejected" } when the browser blocks playback with sound. |
pause() | undefined |
getCurrentTime() | the playhead position, in seconds |
setCurrentTime(seconds) | the position actually set, in seconds |
getDuration() | the duration, in seconds |
getPaused() | true or false |
getEnded() | true or false |
getMuted() / setMuted(muted) | true or false |
getPercentPlayed() | the share of the video actually played, 0 to 1 (see Completion) |
getVideoId() | the video id, vid_… |
on(event, callback) / off(event, callback?) | undefined, synchronously. off without a callback removes every listener for that event. |
destroy() | undefined. Removes the listeners, and the iframe too in container mode. |
Events
| Event | Payload | When |
|---|---|---|
ready | { videoId, duration } | The player can play. |
play | { seconds, duration, percent } | Playback starts or resumes. |
pause | { seconds, duration, percent } | Paused. |
ended | { seconds, duration, percent } | Reached the end. |
seeked | { seconds, duration, percent } | A seek finished. |
timeupdate | { seconds, duration, percent } | About every 250 ms while playing. |
progress | { seconds, duration, percent } | About every second while playing, and on pause, seek and end. |
completed | { percent, threshold, previously } | Once per page load, when the viewer has played enough (see Completion). |
error | { code } | Playback failed. code is expired (the playback token ran out: reload with a fresh one) or load_failed. |
seconds is always the playhead position. In timeupdate, percent is seconds / duration. In every other event, percent is the played share: how much of the video the viewer has actually played.
Completion
- The played share is the total length of the parts of the video the viewer actually played, divided by its duration. Seeking does not add to it, and playing a part twice does not count twice.
- The threshold is
0.9by default. There are two, and they can differ:- On the server (the progress record and the
video.viewer.completedwebhook), the threshold is the token’scmpclaim, from0.1to1.0. Set it when you make the token:completeAt/complete_atin the signing snippets, orcomplete_atonCreatePlaybackToken. The viewer cannot change it. - In the browser (the
completedevent), the threshold is thecomplete_atquery parameter on the player URL when present (https://play.transcodely.com/v/vid_…?token=…&complete_at=0.8,0.1to1.0), and the token’scmpotherwise. The parameter changes only the browser event, never the server record.
- On the server (the progress record and the
- Leave room below
1.0. A browser can start a stream a fraction of a second after0:00and stop a frame before the end, and those parts are never played. Completion allows 0.25 seconds for that. At0.9this never matters for a video longer than a few seconds; on a short video at0.98and above, a viewer who plays all of it can still fall short, and at1.0on some browsers they always will, whatever the length. completedfires once per page load, the moment the played share first reaches the threshold. With a viewer id in the token, parts played on earlier visits count too, and a viewer who had already completed the video getscompletedright afterreadywithpreviously: true.
<script>
player.on('completed', ({ percent, previously }) => {
if (!previously) {
showMessage(`Lesson complete (${Math.round(percent * 100)}% played)`);
}
});
</script>The browser can be lied to. A viewer can call your page’s functions or fake the player’s events from the developer tools. Use the browser event for the interface (a tick, a “next lesson” button). For anything that matters, such as unlocking paid content or issuing a certificate, prefer the webhook or GetViewerProgress on your server.
Those protect against other people and against editing the player URL, but not fully against the viewer themselves. A viewer with a valid token can hand-craft progress reports for their own viewer id. Played time can grow at most 2.5× the real time since the viewer’s last report for that video or since the page loaded, whichever is later, so a forged completion needs that much elapsed time: about 35% of the video’s length at the default 0.9 threshold, about 40% at 1.0. Idle time counts as elapsed time, and each video is bounded separately, so this bounds speed, not attention. If completion must prove attention, add your own check (a quiz, for example). Nobody can write progress for another viewer’s id. A side effect: a viewer playing at 2× on two devices at once can have progress reports refused while that lasts.
Resume
- With a viewer id in the token, the player resumes at the position stored on the server, on any device.
- Without one, it resumes from the browser’s local storage, on the same device only.
- A
tquery parameter on the player URL (?t=120, in seconds) wins over both.
Server-side progress
Progress is recorded only when the playback token has a viewer id (the sub claim, or viewer_id on CreatePlaybackToken). There is one record per app, video and viewer.
The player writes progress at most once every 10 seconds per viewer and video, plus once on pause, at the end, and when the page closes. position_seconds can therefore lag the browser by up to 10 seconds.
The viewer progress object
{
"id": "vpg_a1b2c3d4e5f6g7",
"object": "viewer_progress",
"app_id": "app_k1l2m3n4o5",
"video_id": "vid_a1b2c3d4e5f6g7",
"viewer_id": "student-8841",
"position_seconds": 412.5,
"played_seconds": 540,
"duration_seconds": 613.0,
"percent_played": 0.88,
"complete_threshold": 0.9,
"completed": false,
"created_at": "2026-12-01T09:40:02Z",
"updated_at": "2026-12-01T10:02:11Z"
}| Attribute | Description |
|---|---|
position_seconds | Where the viewer last was, as written by the player. |
played_seconds | Total length of the parts of the video the viewer has played, across every visit. |
percent_played | played_seconds divided by duration_seconds. |
complete_threshold | The share completed is measured against: the cmp claim of the token of the page that last wrote the record, or 0.9 when that token had none. |
completed | Whether percent_played has reached complete_threshold. Once true, it stays true until the record is erased with DeleteViewerData or the video is deleted. |
completed_at | When completed became true. Absent from the object until then. |
The video.viewer.completed webhook
Fires once per video and viewer record, when the record first becomes completed. After DeleteViewerData erases a record, a new one can complete and fire again. Enable it on a webhook endpoint like any other event. The envelope is the same as for every Transcodely webhook, and data is the viewer progress object:
{
"id": "evt_a1b2c3d4e5f6g7h8",
"object": "event",
"api_version": "…",
"created": "2026-12-01T10:12:45Z",
"type": "video.viewer.completed",
"data": {
"id": "vpg_a1b2c3d4e5f6g7",
"object": "viewer_progress",
"app_id": "app_k1l2m3n4o5",
"video_id": "vid_a1b2c3d4e5f6g7",
"viewer_id": "student-8841",
"position_seconds": 598.0,
"played_seconds": 553,
"duration_seconds": 613.0,
"percent_played": 0.902,
"complete_threshold": 0.9,
"completed": true,
"completed_at": "2026-12-01T10:12:44Z",
"created_at": "2026-12-01T09:40:02Z",
"updated_at": "2026-12-01T10:12:44Z"
},
"pending_webhooks": 1,
"request": { "id": null, "idempotency_key": null }
}Verify the Transcodely-Signature header with the endpoint’s whsec_ secret, as for every event. A delivery can repeat when it is retried: make your handler idempotent on data.video_id plus data.viewer_id, or on the event id.
Read and erase progress
Three VideoService calls, with an API key from your server. Each is in the Videos reference with its parameters and SDK calls:
| Call | Request | Returns |
|---|---|---|
GetViewerProgress | { "video_id": "vid_…", "viewer_id": "student-8841" } | { "progress": { … } }, or a not_found error (error code viewer_progress_not_found) when the viewer has no record for that video yet. |
ListViewerProgress | { "viewer_id": "student-8841", "page_size": 50, "page_token": "…" } | { "progress": [ … ], "next_page_token": "…" }: every video of the app this viewer has a record for, most recently updated first. page_size 1 to 100, default 20. It can also list every viewer of one video or of a course: see Course reports. |
DeleteViewerData | { "viewer_id": "student-8841" } | { "deleted_count": 7 }: deletes every progress record of the viewer in the app. |
Deleting a video deletes its progress records, and the CSV exports that hold them. After DeleteViewerData, the viewer starts from nothing: a new record can complete again and send a second video.viewer.completed. DeleteViewerData also deletes CSV exports that could contain the viewer. It cannot reach a player page that is still open: that page can keep reporting until its playback token expires (plus 15 minutes), and its next report creates the record again. To be sure, erase again once the viewer’s tokens have expired, at most 24 hours and 15 minutes after the last one was made.
Course reports
The calls above answer “how far is this student”. A course owner asks the other way round: who has played lesson 4 and how far, how a cohort is doing across twelve lessons, and for a spreadsheet. A course is a tag: put the same tag (for example course-a) on every lesson video. There are no course objects.
All of these are VideoService calls, scoped to one app. With an API key they use the key’s app. In the dashboard, listing by video_id or tag, the roll-up and exports need the member role or higher.
What the numbers mean
- Share played (
percent_playedon the record and in the CSV) is the part of the video that was played in the hosted player, divided by its length. Seeking does not add to it, and playing a part twice does not count twice. - The server limits how fast it can grow: at most 2.5 times the real time since the viewer’s last report for that video or since the page loaded, whichever is later. That stops skipping to the end and scripted forgery at speed. It cannot tell whether anybody was looking at the screen. It limits speed, not attention. If a completion must prove attention, add your own check, such as a quiz.
- Completed means the share played reached the record’s
complete_threshold(0.9 unless the playback token setcmp). Once completed, a record stays completed. - A record exists only when the video was played with a playback token that carries a viewer id. Plays without a token, or with a token without a viewer id, are not counted anywhere here.
Viewer ids are yours
A viewer id is the opaque identifier your site put in the token. Transcodely stores only the viewer id you send. Use an opaque id, not a name or an email. Reports and exports show the ids exactly as you sent them, so keep the mapping from id to person on your side.
List one video’s or one course’s viewers
ListViewerProgress takes exactly one of three selectors:
| Selector | Lists |
|---|---|
viewer_id | That viewer’s records, for every video of the app. |
video_id | Every viewer’s record for that video. The video must belong to the app. |
tag | Every viewer’s records for every video of the app that carries the tag, at most 200 videos. |
Two optional filters work with all three:
| Filter | Keeps |
|---|---|
completed | true: only completed records. false: only records not completed yet. |
updated_after | Only records updated after this moment (RFC 3339, for example 2026-12-01T00:00:00Z). |
{
"video_id": "vid_a1b2c3d4e5f6g7",
"completed": false,
"page_size": 50
}The response is the same as for a viewer: { "progress": [ … ], "next_page_token": "…" }, newest updated first, page_size 1 to 100 (default 20). Pass next_page_token back as page_token for the next page; the last page has none.
- No selector, or more than one, is refused with
invalid_argumentand a field error naming the fields. - A
video_idthat is not in the app, or was deleted, isnot_found. - A
tagon more than 200 videos is refused withinvalid_argumentontag. A tag on no video gives an empty list. - A record a viewer is still playing moves to the front when it is updated, so during one walk through the pages it can appear twice or be missed. For a consistent copy of many records, export to CSV.
Roll up a course
SummarizeViewerProgress gives one row per video and two totals. Send exactly one of tag (every video of the app carrying it, at most 200) or video_ids (1 to 200 ids, duplicates count once).
{ "tag": "course-a" }{
"summary": {
"object": "viewer_progress_summary",
"video_count": 12,
"viewer_count": 340,
"videos": [
{
"video_id": "vid_a1b2c3d4e5f6g7",
"title": "Lesson 1",
"viewers": 310,
"completed": 262,
"average_percent_played": 0.81
}
],
"viewers_completed_all": 97
}
}| Field | Meaning |
|---|---|
video_count | How many videos the summary covers. |
viewer_count | How many distinct viewer ids have a record for at least one of the videos. |
videos[].viewers | How many viewers have a record for that video. |
videos[].completed | How many of those records are completed. |
videos[].average_percent_played | The mean share played (0 to 1) over the viewers with a record. Absent when the video has no viewers. |
viewers_completed_all | How many viewers completed every one of the videos. 0 when the summary covers no videos. |
For a tag, the videos come oldest first (upload order); for video_ids, in the order you sent them. A video id that is not in the app is not_found. A tag on no video gives an empty summary.
Export to CSV
CreateProgressExport builds a CSV file in the background, of one video (video_id) or of every video carrying a tag (tag, at most 200 videos). Send exactly one of the two, and optionally updated_after.
{ "tag": "course-a" }{
"export": {
"id": "pex_a1b2c3d4e5f6g7",
"object": "progress_export",
"app_id": "app_k1l2m3n4o5",
"status": "pending",
"tag": "course-a",
"created_at": "2026-12-01T10:00:00Z"
}
}Poll GetProgressExport with { "id": "pex_…" } every few seconds until status is ready, then download the file from download_url. There is no webhook for exports. An id that is not an export of the app is not_found with error code progress_export_not_found.
status | Meaning |
|---|---|
pending | The file is being built. |
ready | Built. row_count says how many records it holds, download_url is the link, expires_at is when the file is deleted. |
failed | Not built. failure_code is export_too_large (more than 1,000,000 records, or a tag that came to cover more than 200 videos before the file was built: narrow it with updated_after, or export one video at a time), hosting_not_enabled (the app has no managed storage to hold the file) or internal_error (create a new export); failure_message explains it. |
expired | The file is no longer available: 7 days after it was built, or earlier by DeleteViewerData or when one of its videos is deleted (below). It is deleted from storage shortly after. Export again. |
- The download link is valid for one hour, until
download_url_expires_at. EveryGetProgressExportcall on a ready export makes a new one, so ask again rather than keeping an old link. Treat the link like a password: anyone holding it can download the file until it expires. - At most 5 exports per app per hour. The sixth within an hour is refused with
resource_exhaustedand error codeprogress_export_rate_limited. - The file is a snapshot: the records as they were at one moment, one row per record.
The CSV file
UTF-8 with a byte-order mark (so spreadsheet programs read titles in any script correctly). The first row is a header with exactly these 11 column names, in this fixed order:
| Column | Holds |
|---|---|
viewer_id | Your viewer id. |
video_id | The video. |
video_title | The video’s title. |
position_seconds | Where the viewer last was. |
played_seconds | The record’s played_seconds: total length of the parts played. |
duration_seconds | The video’s length. |
percent_played | The record’s percent_played: the share played, 0 to 1. |
complete_threshold | The share completed is measured against. |
completed | true or false. |
completed_at | When it became completed. |
updated_at | The last progress report. |
Times are RFC 3339 in UTC. A value that is absent is an empty cell: video_title for a video without a title, completed_at for a record not completed, and any number that is not finite.
Formulas are neutralised. viewer_id and video_title are free text, and a spreadsheet runs a cell that begins with = as a formula. So every text cell that begins with =, +, -, @, a tab, a carriage return, a line feed, or the full-width =, +, - or @ is written with a single quote (') in front. Strip that quote if you read the file with a program rather than a spreadsheet.
Retention and erasure
- An export file is deleted 7 days after it was built.
DeleteViewerDatadeletes every ready export that covers a video the viewer had a record for, or a video that has since been deleted, and an export still being built is built again without the viewer. Exports made afterwards do not contain the viewer.- Deleting a video expires every ready export that holds its rows, and an export still being built is built again without it.
- A file you already downloaded is yours: delete your copy too when a viewer asks to be forgotten.
Privacy
- A viewer id is your own opaque identifier, such as your database’s user id. Never put an email address, a name or anything else that identifies a person on its own in it. If you want the viewer’s email on screen, put it in the overlay text (
ovl), which is not stored as progress. - Token claims are readable. The token is signed, not encrypted: anyone who sees the player URL can read the viewer id and the overlay text, and full URLs can be recorded in browser history and infrastructure request logs. That is one more reason to keep the viewer id opaque, and to treat the overlay text as visible.
- Transcodely stores progress on your behalf, as your processor. Your privacy notice should say that lesson progress is recorded.
- When a student asks to be forgotten, call
DeleteViewerDatawith their viewer id. It also deletes the CSV exports that could contain them, but not copies you have already downloaded. A player page the student still has open can create the record again until its playback token expires (plus 15 minutes), so call it again once their tokens have expired: at most 24 hours and 15 minutes after the last one was made. DeleteViewerDatadoes not reach webhook events that were already sent. Avideo.viewer.completedevent carries the viewer id in itsdata: your endpoint has its copy, and Transcodely keeps the event and its deliveries in the webhook history until that history’s retention removes them.- Viewers without a token, or with a token that has no viewer id, are not tracked across visits: their resume position stays in their own browser.
Recipes
A plain website
- On your server, when a signed-in student opens a lesson, make a playback token with their user id as the viewer id (how).
- Embed the player with the token and load
player.v1.js. - In the page, listen for
completedto update the interface right away, for example tick the lesson and enable the “Next lesson” button. - On your server, handle
video.viewer.completed: look up the lesson bydata.video_idand the student bydata.viewer_id, and record the completion in your database. This is safer than the browser event: other people cannot forge it, and editing the player URL does not change it. The viewer can still forge their own progress: a forged completion needs elapsed time of about 35% of the video’s length at the default 0.9 threshold (about 40% at 1.0), and idle time counts, so this bounds speed, not attention (see Completion).
<script>
// In the page: interface only.
player.on('completed', () => {
document.querySelector('#next-lesson').disabled = false;
});
</script>WordPress learning management systems
The same pattern works in each of the WordPress course plugins: the player tells the page, and your webhook handler tells the plugin. The handler is a few lines in your own plugin or theme. The beta Transcodely Video for WordPress plugin marks Tutor LMS and LifterLMS lessons complete once the video has been played; it is installed from a zip on its GitHub releases page (it is not in the wordpress.org directory), and it is beta: it has not been run against the live Transcodely API.
For each, the webhook handler should:
- Verify the webhook signature (see Webhook Integration).
- Find the WordPress user. Use the WordPress user id as the viewer id when you make tokens, so
data.viewer_idis that id. - Find the lesson that embeds
data.video_id, for example from a post meta field where you store the lesson’s Transcodely video id. - Mark that lesson complete for that user with the plugin’s own completion routine, below.
LearnDash. Call learndash_process_mark_complete() with the user id, the lesson id and the course id. It is documented at developers.learndash.com (accessed 2026-11-28).
learndash_process_mark_complete( $user_id, $lesson_id, false, $course_id );LifterLMS. Call llms_mark_complete() with the user id, the lesson id, the object type lesson, and a string that says what triggered it. It is documented at developer.lifterlms.com (accessed 2026-11-28).
llms_mark_complete( $user_id, $lesson_id, 'lesson', 'transcodely_video_completed' );Tutor LMS. Mark the lesson complete for the user through Tutor LMS’s own lesson-completion function rather than by writing its records yourself, so its course progress stays consistent. Check the Tutor LMS developer documentation for the function to call in your version.
In every case, keep the plugin’s own “Mark as complete” button hidden or disabled until the video is complete if you want completion to require playing the video. Do that in the page with the completed event, and let the webhook do the real marking.
Moving from Vimeo’s player library
Method and event names match Vimeo’s player.js (accessed 2026-11-28) wherever the meaning is the same, so porting a course site is mostly a change of constructor and script URL.
| Vimeo player.js | Transcodely player.v1.js | Notes |
|---|---|---|
new Vimeo.Player(element, options) | new Transcodely.Player(element, options) | Pass an iframe, or a container with options.url. |
ready() | ready() | |
play() / pause() | play() / pause() | |
getCurrentTime() / setCurrentTime() | getCurrentTime() / setCurrentTime() | |
getDuration() | getDuration() | |
getPaused() / getEnded() | getPaused() / getEnded() | |
getMuted() / setMuted() | getMuted() / setMuted() | |
getVideoId() | getVideoId() | Returns a vid_… string. |
on() / off() | on() / off() | |
destroy() | destroy() | |
getVolume() / setVolume() | none in v1 | |
play, pause, ended, seeked events | same names | Our percent is the played share. |
timeupdate event | timeupdate | Same seconds, duration, percent (playhead share). |
progress event | progress | Different meaning. Vimeo’s progress reports how much of the video has been buffered. Ours reports how much the viewer has played. |
loaded, volumechange events | none in v1 | Use ready instead of loaded. |
| none | completed event, getPercentPlayed() | Completion counted from played parts. |
There is no quality or chapter API in v1.
API reference
Every call on this page is documented field by field in the Videos reference:
- Create a playback token
- The viewer progress object, Retrieve viewer progress, List viewer progress and Delete viewer data
- Summarize viewer progress
- Create a progress export and Retrieve a progress export
The official SDKs carry all of them from @transcodely/sdk 0.3.27, the Python package transcodely 0.3.26 and transcodely-go v0.3.26; the reference shows each call in all three.