Contents
On this page
Save Watch Progress - Plugixa Video
POST /pvx/v1/videos/{id}/progress
Save where the caller is in a video, as the player does while it plays and on pause.
Any signed-in user (signed in with an Application Password or the login cookie). Signed out, it answers 401. The caller must be allowed to watch the video. Part of the core Playback app.
Note. Writes are throttled: a second write for the same caller and video within 10 seconds is answered
200with"saved": falseand not stored. Once a video counts as completed it stays completed, even if a later write goes back to the start.
Request
POST https://your-site.example/wp-json/pvx/v1/videos/838/progress
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The video’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
position |
integer |
Yes | Seconds from the start, 0 or more. Capped at duration. |
duration |
integer |
No | The video’s length in seconds, 0 or more. Defaults to 0. |
The video counts as completed when position reaches 95% of duration. The values can also be sent as query or form parameters.
{
"position": 412,
"duration": 1460
}
Responses
200 OK, stored.
{
"success": true,
"data": {
"saved": true,
"position": 412,
"duration": 1460,
"completed": false
}
}
| Field | Type | Meaning |
|---|---|---|
data.saved |
boolean |
true: the position was stored |
data.completed |
boolean |
Reached 95% at least once |
200 OK, throttled.
{
"success": true,
"data": {
"saved": false
}
}
| Field | Type | Meaning |
|---|---|---|
data.saved |
boolean |
false: too soon after the last stored write |
Errors
| Status | Code | When |
|---|---|---|
401 |
plugixa_video_login_required |
Signed out. |
403 |
plugixa_video_forbidden |
The caller may not watch this video, it has a password, or there is no video with that id. |
400 |
rest_missing_callback_param |
position is missing. |
400 |
rest_invalid_param |
position or duration is negative or not a number. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/pvx/v1/videos/838/progress" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"position":412,"duration":1460}'
<?php
$ch = curl_init('https://your-site.example/wp-json/pvx/v1/videos/838/progress');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'position' => 412,
'duration' => 1460,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/pvx/v1/videos/838/progress', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ position: 412, duration: 1460 }),
});
const { data } = await response.json();
Quick Links
Share