@api.video/private-video-session
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

badge   badge   badge

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

This library aims to simplify the assets links retrieval of api.video private videos.

Getting started

Installation

Method #1: requirejs

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
});

Method #2: typescript

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
});

Method #3: imple include in a javascript project

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>

Code sample

(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);
)();

Documentation

Instanciation options

The private video session can be instanciated with either a videoId & a private token, or directly with a private asset url:

Instanciation with videoId & token

const privateSession = new PrivateVideoSession({
  videoId: "viMgTc1KULkXrjFfDCTBtLs",
  token: "aafe99ed-3d96-44a4-beac-eca06439467c",
});

Instanciation with private asset url

const privateSession = new PrivateVideoSession({
  assetUrl:
    "https://embed.api.video/vod/viMgTc1KULkXrjFfDCTBtLs?token=aafe99ed-3d96-44a4-beac-eca06439467c",
});

Custom domains

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",
  },
});

Methods

getSession(): Promise<string>

Get the private video session token

getThumbnailUrl(): Promise<string>

Get the thumbnail url of the private video

getPlayerUrl(): Promise<string>

Get the player url of the private video

getMp4Url(): Promise<string>

Get the mp4 url of the private video

getHlsUrl(): Promise<string>

Get the hls url of the private video

Sample application

See the sample page for a working example.

FAQ

If you have any questions, ask us in the community. Or use issues..

Readme

Keywords

Package Sidebar

Install

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

Weekly Downloads

31

Version

0.1.0

License

MIT

Unpacked Size

99.3 kB

Total Files

13

Last publish

Collaborators

  • yvan_apivideo
  • apivideo-ecosystem
  • olivierapivideo