Skip to content
中文

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

AttributeWhat it does
contentThe content id to play (starts with cnt_)
apiThe API address this element calls; without it, the page session or https://api.deepraxis.com
posterA poster address; overrides the content’s own poster
autoplayStart playing by itself
mutedStart muted
loopPlay on repeat
playsinlinePlay inline on iOS instead of going fullscreen
start-timeThe starting second
qualityauto, 480, 720 or 1080
controlstrue 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

EventWhendetail
praxis.readyThe player is readyrenditions, title, version, expire_time
praxis.errorOpening or renewing failedcode, message, status, recoverable
praxis.quality.changeThe quality switchedheight
praxis.capability.refreshThe playback credential was renewedexpireTime
praxis.token.refreshThe page session refreshed the viewer tokenthe 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