-
Notifications
You must be signed in to change notification settings - Fork 3
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
Adscript #32
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
ed958fd
types
wjoosen bc7e8ca
initial implementation
wjoosen 6bf9dfb
empty changelog
wjoosen cd30b20
basic README
wjoosen 54169c9
config
wjoosen 90547a4
add test assets
wjoosen 6d4e852
add empty VAST for testing purposes
wjoosen a219258
add test pages
wjoosen 2ac977b
rename test asset
wjoosen 0bb8cde
fix double start event for main content
wjoosen 6caff93
fix start and progress1 reporting for google dai
wjoosen 64e9477
poll for presence of JHMTApi
wjoosen 3eb0ecb
invoke reportPlayerState in constructor
wjoosen 353dd9e
add first playing listener when connector is initialized
wjoosen ef9781a
add i12n reporting
wjoosen 2b82900
Add Adscript to workspace
georgechoustoulakis 9d60150
Use changeset for initial release
georgechoustoulakis 8a1d436
Add exclude
georgechoustoulakis 3882911
Fixup package-lock
georgechoustoulakis e61ec16
Refer to official documentation instead
georgechoustoulakis 576d610
Remove comment
georgechoustoulakis 8878da5
Add param to JSdocs
georgechoustoulakis 99bea78
Run prettier
georgechoustoulakis 9520cc0
Update docs
georgechoustoulakis 4254af4
Extract timeout to helper function
georgechoustoulakis 6477591
Update import
georgechoustoulakis 2bd1868
Rename
georgechoustoulakis 78954c8
Make readonly
georgechoustoulakis 872dbd1
Fix reporting player state in onPlay
georgechoustoulakis f150712
Import type only
georgechoustoulakis ab58256
Remove more event listeners when destroyed
georgechoustoulakis f24040f
Re-order events for constancy
georgechoustoulakis 76878e1
Inline
georgechoustoulakis b1c3f6c
Dont create the integration if the connector was destroyed
georgechoustoulakis ccd807a
Run immediately
georgechoustoulakis e1903e3
Break loop if API is not available after timeout
georgechoustoulakis 5b61f22
Update README
georgechoustoulakis 20541e7
Run prettier on save
georgechoustoulakis d2f14bb
Fix README
georgechoustoulakis eb34bb2
Add docs on configuration
georgechoustoulakis fcd589e
Rework logger
georgechoustoulakis 68f37f9
Improve docs
georgechoustoulakis 9c8d27e
Add AdScript to landing page
georgechoustoulakis 314a22c
Load AdScript intenally
georgechoustoulakis 7b150aa
Expose option to update user data
georgechoustoulakis c1e60a2
Cleanup
georgechoustoulakis 76344f9
Add readonly
georgechoustoulakis 62513ac
Fix type
georgechoustoulakis 34ffde1
Add and update documentation about metadata
georgechoustoulakis 4e4736d
Format
georgechoustoulakis 4532258
Tweak API to use metadata from configuration
georgechoustoulakis 041ca6a
Move interfaces
georgechoustoulakis 0707fbc
Fix loading of AdScript SDK
georgechoustoulakis b4fbcad
Update README
georgechoustoulakis 2b5319c
Update sample pages
georgechoustoulakis 5753682
don't create main content LogPoints if durationchange event with dura…
wjoosen 81d4b05
nitpick
wjoosen f197bd2
rephrase
wjoosen 55f4e35
Rephrase
wjoosen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 calledupdateUser
right? Can we make it more sensible or is this just weird AdScript naming?There was a problem hiding this comment.
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