Player
Playback is owned by the <praxis-video> element; its attributes, methods and events follow the browser’s own <video>. The element needs two things: the content to play, and a viewer identity.
Load the element
<script type="module"> import { configure } from "https://cdn.deepraxis.com/v1/praxis-session.js"; import "https://cdn.deepraxis.com/v1/praxis-video.js"; // grantCode is minted by your backend for the signed-in viewer; never hard-code it. configure({ api: { url: "https://api.deepraxis.com", grantCode: "cgc_REPLACE_ME" } });</script>
<praxis-video content="cnt_REPLACE_ME" style="display:block;width:100%;aspect-ratio:16/9"></praxis-video>Importing praxis-video.js registers the element; praxis-session.js provides the page session.
Attributes
| Attribute | What it does |
|---|---|
content | The content id to play (starts with cnt_) |
api | The API address this element calls; without it, the page session or https://api.deepraxis.com |
poster | A poster address; overrides the content’s own poster |
autoplay | Start playing by itself |
muted | Start muted |
loop | Play on repeat |
playsinline | Play inline on iOS instead of going fullscreen |
start-time | The starting second |
quality | auto, 480, 720 or 1080 |
controls | true for the browser’s native controls; otherwise the player’s own |
Properties and methods
Same as the native <video>: content, currentTime, duration, paused, ended, volume, muted, playbackRate, buffered, readyState; play(), pause(). One more method, setOptions({ api }), tells this element how to obtain a token.
The element turns one token into a playback credential: hand the token in explicitly (setOptions({ api: { accessToken } }), or api.getAccessToken to fetch one each time), or configure the page session and let the element use it.
Events
| Event | When | detail |
|---|---|---|
praxis.ready | The player is ready | renditions, title, version, expire_time |
praxis.error | Opening or renewing failed | code, message, status, recoverable |
praxis.quality.change | The quality switched | height |
praxis.capability.refresh | The playback credential was renewed | expireTime |
praxis.token.refresh | The page session refreshed the viewer token | the session’s token details |
Native <video> events (play, pause, timeupdate, seeking, ended, volumechange and the rest) bubble from the element too. A praxis.error code is the platform’s own code when the answer carried one (RESOURCE_NOT_GRANTED, ORIGIN_NOT_ALLOWED, SOURCE_NOT_READY); otherwise it is the browser script’s own code (PLAYER_ERROR, PLAYBACK_UNSUPPORTED, PLAYBACK_NETWORK_ERROR, NETWORK_ERROR, HTTP_ERROR). When recoverable is true the element offers a retry.
The page session
Call configure({ api: { url, grantCode } }) or configure({ api: { url, publishableKey } }) once — exactly one of the two. A page keeps one session per API address; a different credential signs the old session out first.
The session raises three events of its own: praxis.token.refresh (a new access token), praxis.session.error (code, recoverable) and praxis.session.end (code). The session object returned by configure has customer (id, type, present once the first exchange succeeds), getAccessToken(), signOut() and listener add/remove methods.
Your app’s own player
To build your own player UI, open a play from the page with the viewer’s token and hand the address to your player:
curl -s -X POST "$PRAXIS_API_BASE/content/v1/playback/sessions" \ -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \ -H "Origin: https://learn.example.com" \ -d "{\"content_id\":\"$CONTENT_ID\"}" | jq '{manifest_url,expire_time,renditions}'The response’s manifest_url is an HLS address under content.praxisusercontent.com; hand it to hls.js or a native HLS player. It is valid until expire_time (set by the content’s capability_seconds); open a new play with the same token before then. manifest_url is a bearer credential — give it only to the current viewer, and never store or share it.
Next steps
- Access and publishing: control who can watch, which version is live and when to take it down.
- Customer directory: where viewer tokens come from, and how blocks and revocation work.
- Limits and errors: troubleshoot a failed play by its error code.