Skip to content

Commit

Permalink
Merge pull request #50 from apivideo/private-session
Browse files Browse the repository at this point in the history
Add privateSession option
  • Loading branch information
olivier-lando authored Feb 15, 2023
2 parents 7ddf9fb + 627b482 commit 3a21723
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to this project will be documented in this file.

## [1.2.23] - 2023-02-15
- Add `privateSession` option

## [1.2.22] - 2022-11-04
- Add `getPlaying()` method

Expand Down
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,28 @@ Then, once the `window.onload` event has been triggered, create your player usin
# Documentation

## Instanciation

The PlayerSdk constructor takes 2 parameters:
- `targetSelector: string | Element` a CSS selector targeting the DOM element in which you want to create the player (eg. "#target"), or the DOM element itself
- `options: SdkOptions` an object containing the player options. The available options are the following:


| Option name | Mandatory | Type | Description |
| ------------: | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| id | **yes** | string | the id of the video (videoId or liveStreamId) |
| token | yes for private video | string | the [private video](https://api.video/blog/tutorials/tutorial-private-videos) url token |
| live | no (default: false) | boolean | indicate that the video is a live one |
| autoplay | no (default: false) | boolean | start playing the video as soon as it is loaded |
| muted | no (default: false) | boolean | the video is muted |
| metadata | no (default: empty) | object | object containing [metadata](https://api.video/blog/tutorials/dynamic-metadata) (see **Full example** below) |
| hideControls | no (default: false) | boolean | the controls are hidden (except unmute button if the video starts muted) |
| chromeless | no (default: false) | boolean | chromeless mode: all controls are hidden |
| hideTitle | no (default: false) | boolean | the video title is hidden |
| hidePoster | no (default: false) | boolean | the poster image isn't displayed |
| showSubtitles | no (default: false) | boolean | the video subtitles are shown by default |
| loop | no (default: false) | boolean | once the video is finished it automatically starts again |
| playbackRate | no (default: 1) | number | the playback rate of the video: 1 for normal, 2 for x2, etc. |
| Option name | Mandatory | Type | Description |
| -------------: | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| id | **yes** | string | the id of the video (videoId or liveStreamId) |
| token | yes for private video | string | the [private video](https://api.video/blog/tutorials/tutorial-private-videos) url token |
| privateSession | no | string | the [private video](https://api.video/blog/tutorials/tutorial-private-videos) session id if needed |
| live | no (default: false) | boolean | indicate that the video is a live one |
| autoplay | no (default: false) | boolean | start playing the video as soon as it is loaded |
| muted | no (default: false) | boolean | the video is muted |
| metadata | no (default: empty) | object | object containing [metadata](https://api.video/blog/tutorials/dynamic-metadata) (see **Full example** below) |
| hideControls | no (default: false) | boolean | the controls are hidden (except unmute button if the video starts muted) |
| chromeless | no (default: false) | boolean | chromeless mode: all controls are hidden |
| hideTitle | no (default: false) | boolean | the video title is hidden |
| hidePoster | no (default: false) | boolean | the poster image isn't displayed |
| showSubtitles | no (default: false) | boolean | the video subtitles are shown by default |
| loop | no (default: false) | boolean | once the video is finished it automatically starts again |
| playbackRate | no (default: 1) | number | the playback rate of the video: 1 for normal, 2 for x2, etc. |


The sdk instance can be used to control the video playback, and to listen to player events.
Expand Down
8 changes: 7 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type SdkOptions = {
hideTitle?: boolean;
iframeUrl?: string;
token?: string;
privateSession?: string;
showSubtitles?: boolean;
playbackRate?: number;
}
Expand Down Expand Up @@ -353,10 +354,15 @@ export class PlayerSdk {

private urlParametersFromOptions(options: SdkOptions) {
const allowedKeys = ["id", "live", "autoplay", "muted", "metadata", "hideControls", "hidePoster",
"chromeless", "loop", "hideTitle", "iframeUrl", "token", "showSubtitles", "ts"];
"chromeless", "loop", "hideTitle", "iframeUrl", "token", "showSubtitles", "ts","avh"];

const optionsAsAny = options as any;
optionsAsAny.ts = new Date().getTime();

if(options.privateSession) {
optionsAsAny.avh = options.privateSession;
}

return Object.keys(options).map((key: string) => {
if(allowedKeys.indexOf(key) === -1) {
return;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@api.video/player-sdk",
"version": "1.2.22",
"version": "1.2.23",
"description": "api.video player SDK",
"repository": {
"type": "git",
Expand Down

0 comments on commit 3a21723

Please sign in to comment.