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.
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
$ npm install --save @api.video/private-video-session
You can then use the module in your script:
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
$ npm install --save @api.video/private-video-session
You can then use the SDK in your script:
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:
<head>
...
<script
src="https://unpkg.com/@api.video/private-video-session"
defer
></script>
</head>
<script type="text/javascript">
var privateSession = new PrivateVideoSession(
...options // see below for available options
});
</script>
(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:
const privateSession = new PrivateVideoSession({
videoId: "viMgTc1KULkXrjFfDCTBtLs",
token: "aafe99ed-3d96-44a4-beac-eca06439467c",
});
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:
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..