api.video private video session
npm install @api.video/private-video-session



api.video is the video infrastructure for product builders. Lightning fast
video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in
your app.
- Table of contents
- Project description
- Getting started
- Installation
- Method #1: requirejs
- Method #2: typescript
- Method #3: imple include in a javascript project
- Code sample
- Documentation
- Instanciation options
- Instanciation with videoId \& token
- Instanciation with private asset url
- Custom domains
- Methods
- getSession(): Promise
- getThumbnailUrl(): Promise
- getPlayerUrl(): Promise
- getMp4Url(): Promise
- getHlsUrl(): Promise
- Sample application
- FAQ
This library aims to simplify the assets links retrieval of api.video private videos.
If you use requirejs you can add the module as a dependency to your project with
``sh`
$ npm install --save @api.video/private-video-session
You can then use the module in your script:
`javascript
var { PrivateVideoSession } = require("@api.video/private-video-session");
var privateSession = new PrivateVideoSession({
...options, // see below for available options
});
`
If you use Typescript you can add the SDK as a dependency to your project with
`sh`
$ npm install --save @api.video/private-video-session
You can then use the SDK in your script:
`typescript
import { PrivateVideoSession } from "@api.video/private-video-session";
const privateSession = new PrivateVideoSession({
...options, // see below for available options
});
`
Include the SDK in your HTML file like so:
`html
...
src="https://unpkg.com/@api.video/private-video-session"
defer
>
`
`javascript
(async () => {
const privateSession = new PrivateVideoSession({
videoId: 'viMgTc1KULkXrjFfDCTBtLs',
token: 'aafe99ed-3d96-44a4-beac-eca06439467c'
});
const thumbnailUrl = await privateSession.getThumbnailUrl();
console.log(thumbnailUrl);
const playerUrl = await privateSession.getPlayerUrl();
console.log(playerUrl);
)();
`
The private video session can be instanciated with either a videoId & a private token, or directly with a private asset url:
`javascript`
const privateSession = new PrivateVideoSession({
videoId: "viMgTc1KULkXrjFfDCTBtLs",
token: "aafe99ed-3d96-44a4-beac-eca06439467c",
});
`javascript`
const privateSession = new PrivateVideoSession({
assetUrl:
"https://embed.api.video/vod/viMgTc1KULkXrjFfDCTBtLs?token=aafe99ed-3d96-44a4-beac-eca06439467c",
});
If you've configured custom domains for your account, it's necessary to use the domains parameter when instantiating.
Here's a quick example on how to do it:
`javascript``
const privateSession = new PrivateVideoSession({
assetUrl:
"https://embed.mydomain.com/vod/viMgTc1KULkXrjFfDCTBtLs?token=aafe99ed-3d96-44a4-beac-eca06439467c",
domains: {
embed: "embed.mydomain.com",
vod: "vod.mydomain.com",
live: "live.mydomain.com",
},
});
> Get the private video session token
> Get the thumbnail url of the private video
> Get the player url of the private video
> Get the mp4 url of the private video
> Get the hls url of the private video
See the sample page for a working example.
If you have any questions, ask us in the community. Or
use issues..