Skip to content

Commit 0ea53d7

Browse files
Merge pull request #53 from apivideo/add-ads-support
Add ads support
2 parents 9a8d518 + bfdbb9e commit 0ea53d7

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [1.2.25] - 2023-06-02
5+
- Add ads support
46
## [1.2.24] - 2023-03-03
57
- Add `sequence` option
68

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [Method #2: simple include in a javascript project](#method-2-simple-include-in-a-javascript-project)
1717
- [Documentation](#documentation)
1818
- [Instanciation](#instanciation)
19+
- [Ads](#ads)
1920
- [Methods](#methods)
2021
- [`loadConfig(options: SdkOptions)`](#loadconfigoptions-sdkoptions)
2122
- [`play()`](#play)
@@ -152,10 +153,16 @@ The PlayerSdk constructor takes 2 parameters:
152153
| loop | no (default: false) | boolean | once the video is finished it automatically starts again |
153154
| playbackRate | no (default: 1) | number | the playback rate of the video: 1 for normal, 2 for x2, etc. |
154155
| 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. |
156+
| ads | no | {adTagUrl: string} | see below [ads](#ads) |
155157

156158

157159
The sdk instance can be used to control the video playback, and to listen to player events.
158160

161+
### Ads
162+
Ads can be displayed in the player. To do so, you need to pass the `ads` option to the sdk constructor. In the `ads` object, pass the `adTagUrl` property with the url of the ad tag. The ad tag must be a VAST 2.0 or 3.0 url. For more information about VAST, check the [IAB documentation](https://www.iab.com/guidelines/vast/).
163+
164+
Note: ads are displayed using the [Google IMA SDK](https://developers.google.com/interactive-media-ads/docs/sdks/html5/quickstart).
165+
159166
## Methods
160167

161168
The sdk instance has the following methods:

index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export type PlayerTheme = {
2121
linkActive?: string;
2222
}
2323

24+
type AdsOptions = {
25+
adTagUrl: string;
26+
}
27+
2428
type SdkOptions = {
2529
id: string;
2630
live?: boolean;
@@ -38,6 +42,7 @@ type SdkOptions = {
3842
token?: string;
3943
privateSession?: string;
4044
showSubtitles?: boolean;
45+
ads?: AdsOptions;
4146
playbackRate?: number;
4247
sequence?: {
4348
start: number;
@@ -353,6 +358,10 @@ export class PlayerSdk {
353358
url = addParameterInIframeHash("show-subtitles");
354359
}
355360

361+
if(options.ads?.adTagUrl) {
362+
url = addParameterInIframeHash(`adTagUrl:${encodeURIComponent(options.ads?.adTagUrl)}`);
363+
}
364+
356365
if(!isNaN(parseInt(""+options.sequence?.end, 10)) && !isNaN(parseInt(""+options.sequence?.start, 10))) {
357366
url = addParameterInIframeHash(`t=${options.sequence?.start},${options.sequence?.end}`);
358367
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@api.video/player-sdk",
3-
"version": "1.2.24",
3+
"version": "1.2.25",
44
"description": "api.video player SDK",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)