Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adscript #32

Merged
merged 59 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ed958fd
types
wjoosen Jul 14, 2024
bc7e8ca
initial implementation
wjoosen Jul 14, 2024
6bf9dfb
empty changelog
wjoosen Jul 14, 2024
cd30b20
basic README
wjoosen Jul 14, 2024
54169c9
config
wjoosen Jul 14, 2024
90547a4
add test assets
wjoosen Jul 14, 2024
6d4e852
add empty VAST for testing purposes
wjoosen Jul 14, 2024
a219258
add test pages
wjoosen Jul 14, 2024
2ac977b
rename test asset
wjoosen Jul 15, 2024
0bb8cde
fix double start event for main content
wjoosen Jul 15, 2024
6caff93
fix start and progress1 reporting for google dai
wjoosen Jul 15, 2024
64e9477
poll for presence of JHMTApi
wjoosen Jul 15, 2024
3eb0ecb
invoke reportPlayerState in constructor
wjoosen Jul 15, 2024
353dd9e
add first playing listener when connector is initialized
wjoosen Jul 15, 2024
ef9781a
add i12n reporting
wjoosen Jul 15, 2024
2b82900
Add Adscript to workspace
georgechoustoulakis Jul 19, 2024
9d60150
Use changeset for initial release
georgechoustoulakis Jul 19, 2024
8a1d436
Add exclude
georgechoustoulakis Jul 19, 2024
3882911
Fixup package-lock
georgechoustoulakis Jul 19, 2024
e61ec16
Refer to official documentation instead
georgechoustoulakis Jul 19, 2024
576d610
Remove comment
georgechoustoulakis Jul 19, 2024
8878da5
Add param to JSdocs
georgechoustoulakis Jul 19, 2024
99bea78
Run prettier
georgechoustoulakis Jul 19, 2024
9520cc0
Update docs
georgechoustoulakis Jul 19, 2024
4254af4
Extract timeout to helper function
georgechoustoulakis Jul 19, 2024
6477591
Update import
georgechoustoulakis Jul 19, 2024
2bd1868
Rename
georgechoustoulakis Jul 19, 2024
78954c8
Make readonly
georgechoustoulakis Jul 19, 2024
872dbd1
Fix reporting player state in onPlay
georgechoustoulakis Jul 19, 2024
f150712
Import type only
georgechoustoulakis Jul 19, 2024
ab58256
Remove more event listeners when destroyed
georgechoustoulakis Jul 19, 2024
f24040f
Re-order events for constancy
georgechoustoulakis Jul 19, 2024
76878e1
Inline
georgechoustoulakis Jul 19, 2024
b1c3f6c
Dont create the integration if the connector was destroyed
georgechoustoulakis Jul 19, 2024
ccd807a
Run immediately
georgechoustoulakis Jul 19, 2024
e1903e3
Break loop if API is not available after timeout
georgechoustoulakis Jul 19, 2024
5b61f22
Update README
georgechoustoulakis Jul 19, 2024
20541e7
Run prettier on save
georgechoustoulakis Jul 19, 2024
d2f14bb
Fix README
georgechoustoulakis Jul 19, 2024
eb34bb2
Add docs on configuration
georgechoustoulakis Jul 19, 2024
fcd589e
Rework logger
georgechoustoulakis Jul 19, 2024
68f37f9
Improve docs
georgechoustoulakis Jul 19, 2024
9c8d27e
Add AdScript to landing page
georgechoustoulakis Jul 19, 2024
314a22c
Load AdScript intenally
georgechoustoulakis Jul 22, 2024
7b150aa
Expose option to update user data
georgechoustoulakis Jul 22, 2024
c1e60a2
Cleanup
georgechoustoulakis Jul 22, 2024
76344f9
Add readonly
georgechoustoulakis Jul 22, 2024
62513ac
Fix type
georgechoustoulakis Jul 22, 2024
34ffde1
Add and update documentation about metadata
georgechoustoulakis Jul 22, 2024
4e4736d
Format
georgechoustoulakis Jul 22, 2024
4532258
Tweak API to use metadata from configuration
georgechoustoulakis Jul 22, 2024
041ca6a
Move interfaces
georgechoustoulakis Jul 22, 2024
0707fbc
Fix loading of AdScript SDK
georgechoustoulakis Jul 23, 2024
b4fbcad
Update README
georgechoustoulakis Jul 23, 2024
2b5319c
Update sample pages
georgechoustoulakis Jul 23, 2024
5753682
don't create main content LogPoints if durationchange event with dura…
wjoosen Aug 6, 2024
81d4b05
nitpick
wjoosen Aug 6, 2024
f197bd2
rephrase
wjoosen Aug 6, 2024
55f4e35
Rephrase
wjoosen Aug 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ten-zoos-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/adscript-connector-web": minor
---

Initial release.
1 change: 1 addition & 0 deletions .idea/prettier.xml

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

1 change: 1 addition & 0 deletions .idea/web-connectors.iml

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

15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ Using the available connectors allows you to augment the features delivered thro

## Available Connectors

| Connector | npm package | Source code |
|:----------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------|
| CMCD | [![@theoplayer/cmcd-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fcmcd-connector-web?label=%40theoplayer%2Fcmcd-connector-web)](https://npmjs.com/package/@theoplayer/cmcd-connector-web) | [cmcd](https://github.com/THEOplayer/web-connectors/tree/main/cmcd) |
| Comscore | [![@theoplayer/comscore-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fcomscore-connector-web?label=%40theoplayer%2Fcomscore-connector-web)](https://npmjs.com/package/@theoplayer/comscore-connector-web) | [comscore](https://github.com/THEOplayer/web-connectors/tree/main/comscore) |
| Conviva | [![@theoplayer/conviva-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fconviva-connector-web?label=%40theoplayer%2Fconviva-connector-web)](https://npmjs.com/package/@theoplayer/conviva-connector-web) | [conviva](https://github.com/THEOplayer/web-connectors/tree/main/conviva) |
| Nielsen | [![@theoplayer/nielsen-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fnielsen-connector-web?label=%40theoplayer%2Fnielsen-connector-web)](https://npmjs.com/package/@theoplayer/nielsen-connector-web) | [nielsen](https://github.com/THEOplayer/web-connectors/tree/main/nielsen) |
| Yospace | [![@theoplayer/yospace-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fyospace-connector-web?label=%40theoplayer%2Fyospace-connector-web)](https://npmjs.com/package/@theoplayer/yospace-connector-web) | [yospace](https://github.com/THEOplayer/web-connectors/tree/main/yospace) |
| Connector | npm package | Source code |
|:----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------|
| AdScript | [![@theoplayer/adscript-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fadscript-connector-web?label=%40theoplayer%2Fadscript-connector-web)](https://npmjs.com/package/@theoplayer/adscript-connector-web) | [adscript](https://github.com/THEOplayer/web-connectors/tree/main/adscript) |
| CMCD | [![@theoplayer/cmcd-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fcmcd-connector-web?label=%40theoplayer%2Fcmcd-connector-web)](https://npmjs.com/package/@theoplayer/cmcd-connector-web) | [cmcd](https://github.com/THEOplayer/web-connectors/tree/main/cmcd) |
| Comscore | [![@theoplayer/comscore-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fcomscore-connector-web?label=%40theoplayer%2Fcomscore-connector-web)](https://npmjs.com/package/@theoplayer/comscore-connector-web) | [comscore](https://github.com/THEOplayer/web-connectors/tree/main/comscore) |
| Conviva | [![@theoplayer/conviva-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fconviva-connector-web?label=%40theoplayer%2Fconviva-connector-web)](https://npmjs.com/package/@theoplayer/conviva-connector-web) | [conviva](https://github.com/THEOplayer/web-connectors/tree/main/conviva) |
| Nielsen | [![@theoplayer/nielsen-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fnielsen-connector-web?label=%40theoplayer%2Fnielsen-connector-web)](https://npmjs.com/package/@theoplayer/nielsen-connector-web) | [nielsen](https://github.com/THEOplayer/web-connectors/tree/main/nielsen) |
| Yospace | [![@theoplayer/yospace-connector-web](https://img.shields.io/npm/v/%40theoplayer%2Fyospace-connector-web?label=%40theoplayer%2Fyospace-connector-web)](https://npmjs.com/package/@theoplayer/yospace-connector-web) | [yospace](https://github.com/THEOplayer/web-connectors/tree/main/yospace) |

## License

Expand Down
10 changes: 10 additions & 0 deletions adscript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Node artifact files
node_modules/
lib/
dist/

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db
100 changes: 100 additions & 0 deletions adscript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# adscript-connector-web

The AdScript connector provides an AdScript integration for THEOplayer.

## Installation

Install using your favorite package manager for Node (such as `npm` or `yarn`):

### npm

```bash
npm install @theoplayer/adscript-connector-web
```

### yarn

```bash
yarn add @theoplayer/adscript-connector-web
```

## Usage

First you need to add the AdScript connector to your app :

* Add as a regular script

```html

<script type="text/javascript" src="path/to/adscript-connector.umd.js"></script>
<script type="text/javascript">
const player = new THEOplayer.Player(element, configuration);

// Define your configuration for the connector:
const adScriptConfig = {
implementationId: 'your-implementation-id', // Replace this!
metadata: {
"assetid": "v0000001",
"type": "content",
"program": "Big Buck Bunny",
"title": "Sample Video - Extended",
"length": "635",
"crossId": "000 111 22222",
"livestream": "0",
"channelId": "",
"attribute": "1"
},
debug: false
}

// Create the AdScriptConnector:
const adScriptConnector = new THEOplayerAdScriptConnector.AdScriptConnector(player, adScriptConfig);
</script>
```

* Add as an ES2015 module

```html

<script type="module">
import {AdScriptConnector} from "@theoplayer/adscript-connector-web";

const player = new THEOplayer.Player(element, configuration);

// Define your configuration for the connector:
const adScriptConfig = {
implementationId: 'your-implementation-id', // Replace this!
metadata: {
"assetid": "v0000001",
"type": "content",
"program": "Big Buck Bunny",
"title": "Sample Video - Extended",
"length": "635",
"crossId": "000 111 22222",
"livestream": "0",
"channelId": "",
"attribute": "1"
},
debug: false
}

// Create the AdScriptConnector:
const adScriptConnector = new AdScriptConnector(player, adScriptConfig);
</script>
```

## Updating metadata

If the metadata has changed during playback, you can update it with:

```javascript
adScriptConnector.updateMetadata(newMetadata);
```

## Updating userInfo

If the user info has changed during playback, you can update it with:

```javascript
adScriptConnector.updateUser(i12n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i12n is a bit of a vague parameter name for a method called updateUser right? Can we make it more sensible or is this just weird AdScript naming?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming comes directly from the AdScript docs

```
47 changes: 47 additions & 0 deletions adscript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@theoplayer/adscript-connector-web",
"version": "0.0.1",
"description": "A connector implementing AdScript with THEOplayer",
"main": "dist/adscript-connector.umd.js",
"module": "dist/adscript-connector.esm.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/adscript-connector.esm.js",
"require": "./dist/adscript-connector.umd.js"
},
"./dist/*": "./dist/*",
"./package": "./package.json",
"./package.json": "./package.json"
},
"scripts": {
"clean": "rimraf lib dist",
"bundle": "rollup -c rollup.config.mjs",
"watch": "npm run bundle -- --watch",
"build": "npm run clean && npm run bundle",
"serve": "http-server ./.. -o /adscript/test/pages/main_esm.html",
"test": "echo \"No tests yet\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/THEOplayer/web-connectors.git",
"directory": "adscript"
},
"author": "THEO Technologies NV",
"license": "MIT",
"bugs": {
"url": "https://github.com/THEOplayer/web-connectors/issues"
},
"homepage": "https://github.com/THEOplayer/web-connectors/tree/main/adscript#readme",
"files": [
"dist/",
"CHANGELOG.md",
"README.md",
"LICENSE.md",
"package.json"
],
"peerDependencies": {
"theoplayer": "^7.0.0"
}
}
15 changes: 15 additions & 0 deletions adscript/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import fs from "node:fs";
import {getSharedBuildConfiguration} from "../tools/build.mjs";


const {version} = JSON.parse(fs.readFileSync("./package.json", "utf8"));

const fileName = "adscript-connector";
const globalName = "THEOplayerAdScriptConnector";

const banner = `
/**
* THEOplayer AdScript Web Connector v${version}
*/`.trim();

export default getSharedBuildConfiguration({fileName, globalName, banner});
57 changes: 57 additions & 0 deletions adscript/src/adscript/AdScript.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export type JHMTApiProtocol = 'https:' | 'http:' | 'file:';

interface I12n {
i1: string;
i2: string;
i3: string;
i4: string;
i5: string;
}

export type MainVideoContentType = 'content';
export type EmbeddedContentType = 'preroll' | 'midroll' | 'postroll';
export type StaticContentType = 'static';

interface StaticContentMetadata {
assetid: string;
type: StaticContentType;
sec1: string;
sec2: string;
sec3: string;
sec4: string;
ref: string;
}

export interface PlayerState {
muted: number;
volume: number;
triggeredByUser: number;
normalSpeed: number;
fullscreen: number;
visibility: number;
width: number;
height: number;
}

interface JHMTArray extends Array<any> {
i12n: I12n;
contentMetadata: ContentMetadata;
playerState: PlayerState;
push: (item: any) => number; // Type of the push function
}

declare global {
interface Window {
JHMT: JHMTArray;
JHMTApi: typeof JHMTApi;
JHMTApiProtocol: JHMTApiProtocol;
}
}

export interface JHMTApi {
setI12n(i12n: I12n);

setContentMetadata(contentMetadata: ContentMetadata);

setPlayerState(playerState: PlayerState);
}
2 changes: 2 additions & 0 deletions adscript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { AdScriptConnector } from './integration/AdScriptConnector';
export * from './integration/AdScriptConfiguration';
62 changes: 62 additions & 0 deletions adscript/src/integration/AdScriptConfiguration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import type { Ad } from 'theoplayer';

/**
* The main content information settings.
* For more information, see the [main content information settings](https://adscript.admosphere.cz/en_adScript_browser.html) section in the AdScript documentation.
*/
export interface MainVideoContentMetadata {
assetid: string;
type: 'content';
program: string;
title: string;
length: string;
crossId: string;
livestream: string;
channelId: string;
attributes: string;
}

/**
* The embedded content metadata, about the currently playing ad.
*/
export interface EmbeddedContentMetadata {
assetid: string;
type: 'preroll' | 'midroll' | 'postroll';
length: string;
title: string;
asmea: string;
attributes: string;
}

/**
* The configuration for the AdScript Connector.
*/
export interface AdScriptConfiguration {
/**
* Integration ID you received from your Nielsen representative.
*/
implementationId: string;

/**
* The initial main content information settings.
* Metadata of the main video content needs to be set before the first measured event occurs.
* For more information, see the [main content information settings](https://adscript.admosphere.cz/en_adScript_browser.html) section in the AdScript documentation.
*/
metadata: MainVideoContentMetadata;

/**
* Additional information about the logged-in user (customerID, deviceID, profileID) from the client´s database.
* For more information, see the [Additional Information Settings](https://adscript.admosphere.cz/en_adScript_browser.html) section.
*/
i12n?: { [key: string]: string };

/**
* An optional advertisement processor to receive metadata about the Ad.
*/
adProcessor?: (ad: Ad) => EmbeddedContentMetadata;

/**
* Whether the connector should log all actions.
*/
debug?: boolean;
}
Loading