-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from THEOplayer/feature/adscript
AdScript Connector
- Loading branch information
Showing
23 changed files
with
1,250 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@theoplayer/adscript-connector-web": minor | ||
--- | ||
|
||
Initial release. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { AdScriptConnector } from './integration/AdScriptConnector'; | ||
export * from './integration/AdScriptConfiguration'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.