Skip to content

Commit

Permalink
Merge pull request #51 from apivideo/add-sequence-param
Browse files Browse the repository at this point in the history
Add sequence param
  • Loading branch information
olivier-lando authored Mar 3, 2023
2 parents 3a21723 + 02386c8 commit 9a8d518
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 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.24] - 2023-03-03
- Add `sequence` option

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

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ The PlayerSdk constructor takes 2 parameters:
| 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. |
| sequence | no | {start: number, end: number} | define a sequence of the video to play. The video will start at the `start` timecode and end at the `end` timecode. The timecodes are in seconds. |


The sdk instance can be used to control the video playback, and to listen to player events.
Expand Down
8 changes: 8 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ type SdkOptions = {
privateSession?: string;
showSubtitles?: boolean;
playbackRate?: number;
sequence?: {
start: number;
end: number;
}
}

type PlayerSdkEvent = {
Expand Down Expand Up @@ -349,6 +353,10 @@ export class PlayerSdk {
url = addParameterInIframeHash("show-subtitles");
}

if(!isNaN(parseInt(""+options.sequence?.end, 10)) && !isNaN(parseInt(""+options.sequence?.start, 10))) {
url = addParameterInIframeHash(`t=${options.sequence?.start},${options.sequence?.end}`);
}

return url;
}

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.23",
"version": "1.2.24",
"description": "api.video player SDK",
"repository": {
"type": "git",
Expand Down

0 comments on commit 9a8d518

Please sign in to comment.