Skip to content

Commit

Permalink
Video Module: Initial Release (#8858)
Browse files Browse the repository at this point in the history
* registers as module

* adds vendor consts

* registers jwplayer submodule

* renames render ad

* checks config autostart

* moves private functions to a util obj

* introduces ad optimization

* tests state.js

* introduces submodule tests

* populates utils tests

* tests callback storage

* tests ad and time states

* introduces provider tests:

* tests init

* tests get ortb

* tests event listeners

* supports removing all event handlers when explicit

* splits clear all event listeners from early return

* removes hook

* shares directory

* prevents registering a same provider twice

* adds pb video

* adds video module to submodules list

* adds integration example

* implements ad unit enrichment

* moves submodule to parent dir

* removes comment

* implements event listener

* adds unit tests

* tests updating video config

* tests events surfacing

* nests the event trigger tests

* restores factory

* adds adServer

* shares base parent module logic

* register gam submodule

* tests submodule builder

* instantiates ad server

* tests parent module

* updates core video tests

* adds ad server tests

* obtains vast ad to render

* passes options

* tests ad tag obtention

* tests settings tags without ad server

* adds vast xml builder

* tests node makers

* implments vast xml build fn

* renames wrapper builder

* adds vast xml editor

* modifies vast xml

* moves logic to helper

* appends doc element

* copies node when required multiple times

* improves copy check

* adds tests for error node

* adds tests cases for different config

* pulls vast wrapper builders from xml editor

* adds tracking tests

* tests arguments

* removes obsolete path

* polls for duration when absent

* sets up video module

* prevents ad load if bidding is used

* triggers event before loading ad

* adds inline docs to shared modules

* adds inline docs

* documents providers

* adds inline docs for ortb

* adds missing ortb params

* obtains language code

* makes placement more precise

* adds notes

* updates todo

* early exit if not video media type

* loads ad server config

* filters for highest bids before rendering

* emits event even on loss

* registers video auction events

* updates events

* includes ad unit code in loss

* uses config fallback

* tracks bids sent for rendering

* adds video impression verification

* shares code

* triggers bid video events

* matches ad event to bid

* adds inline documentation

* allows URL import

* updates vast xml editor tests

* tests ad event processsing

* includes ad wrapper ids

* updates ad tag injection tests

* tests impression tracking

* updates for new find

* removes unused var

* uses find polyfill

* updates event import

* exposes addEvents

* checks for bid identifiers bfore accessing properties

* checks for bid identifiers bfore accessing properties

* exposes video bid events

* converts ortb params to insternal fields

* reads from video

* removes typo

* sets ortb video to media type video

* sets ortb2 obj

* gets impression url from fn

* tmg uses mediatype video

* configures provider to properly render ads

* sets up player in demo

* triggers load abort

* uses appnexys

* uses getGlobal

* protects against missing params

* breaks out shared and adserver from videoModule

* updates import

* resolves lgtm errors

* uses submodule pattern

* uses uuid generator util

* removes adServer module

* moves shared to video folder

* prefix events with video_

* adds auction end listener when no bids back handler

* fixes tests

* refactors render

* exposes rendering

* uses mergeDeep

* shares constants

* populates ortb content.data

* register events as prefixed

* adds test bidders

* moves videoModule to library

* Added draft for videojs  integration example

* Moved jwplayer integration example, added draft for videojs example

* Created integration example for a mocked videojs adapter

* Fixed call order for integration examples, moved imports up

* Finished init for videojs provider

* Setup videojs init unit tests

* Formatting to pass linter

* Removed comments/redundant tests, clarified some sections of code

* Added semicolon

* Videojs ortb params, added ortb constants

* Fixed integration examples, ortb adjustments

* Cleaned up code added comments

* Renamed test file

* Removed videojs mock in favor of videojs

* Changed video source, finished tests for ortb

* Cleaned up spacing added some comments

* Added ad position to ortb

* Cleaned up playback methods code

* Omitted skip variable per ortb spec

* Added unit tests for ima integration

* Added util function, and corresponding tests

* Added code for placement

* Linter pass through

* Added videojs-ima to integration example

* Removed duplicate tests

* Removed non bidding module tests

* Added clarifying comments

* Updated name mapping for videojs events

* Added callback factory, and presetup listeners

* Filled in initialization events

* Importing event constants

* Fixing setup failed event handler

* Fixed init behavior to work with setupCompleteCallback

* Added pre setup callback tests

* Setup presetupListeners/moved away from callbackStorage

* Added missing case for setup failure

* Basic event handling

* adds ortb constants

* removes trailing file

* uses hook.js

* marks winning bid as used

* gets adWrapper regardless of property name

* rename vars

* fixes init and loadAdTag

* renames videojs var

* supports media events

* addresses size events

* registers ad events

* implements get ad info

* generates ad pauload

* includes wrapper ids

* supports ad config

* populates ad config

* adds event listener at every manager change

* handles setupfailure

* renames video js example

* updates time

* supports loadstart

* supports multiple setup callbacks

* removes global ima for test

* removes obsolete IMA checks

* requests ad unit

* uses vendor config to setup

* listens for playlist events

* restors src tag

* resolves build fail

* splits library from module

* allows obtaining ortb obj

* uses safe getConfig

* adds metadata demo

* improves metadata util

* triggers playlist event at first load

* adds bid request scheduling demo

* obtains bid adId

* sets proper context

* combines all possible adServer configs

* configures ad tag

* adds demos

* adServerConfig getter is nullable

* adds demos

* triggers setup fail when ima is missing

* checks for player existence

* updates tests

* adds tests

* tests media parsers

* returns empty object when no config gound

* adds integrity

* removes library map

* prioritizes bidder params

* uses camel casing for event names

* support multiple setup successful callbacks

* supports multiple setup fail ballbacks

* moves early return to core

* registers one event at a time

* uses event handler builder

* uses name conversion util

* refactors event handling

* refactors ima listeners

* simplifies event logic

* checks for existence

* offevent singular

* adds fn desc

* splits ortb video from content

* checks for player existence

* enrichment rules

* only sets main content div when enabled

* sets ortb2 in the bidRequest

* tests re ortb

* refactor tests

* resolves instability

* removes auction end event listener

* rebuilds dependencies

* sets ortb site.content

* renames auctionRequest

* renames optimizeAds

* adds module docs

* adds event doc

Co-authored-by: karimJWP <[email protected]>
Co-authored-by: AnirudhRahul <[email protected]>
  • Loading branch information
3 people committed Oct 21, 2022
1 parent 6c63c6f commit 0c69238
Show file tree
Hide file tree
Showing 49 changed files with 18,938 additions and 808 deletions.
98 changes: 98 additions & 0 deletions integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<html>

<head>
<script src="https://cdn.jwplayer.com/libraries/l5MchIxB.js"></script>
<script async src="../../../build/dev/prebid.js"></script>

<title>JW Player with Bid Marked As Used</title>

<!--This demo listens to the Video events that are fired when an ad impression or ad error came from a bid. -->

<script>
// Setup ad units
var adUnits = [{
code: 'div-gpt-ad-51545-0',
mediaTypes: {
video: {}
},
video: {
divId: 'player', // required to indicate which player is being used to render this ad unit.
},

bids: [{
bidder: 'ix',
params: {
siteId: '300',
}
}]
}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function () {
pbjs.setConfig({
video: {
providers: [{
divId: 'player',
vendorCode: 1, // jwplayer vendorCode
playerConfig: {
licenseKey: 'IAjLREYRLylTWsfLN3FoN/O3iQLbs+AfgZLlkAoyH8gSf7TnNtmOLcR8CUY=',
params: {
vendorConfig: {
file: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/SubaruOutbackOnStreetAndDirt.mp4',
advertising: { client: 'vast' }
}
}
},
},]
},
debugging: {
enabled: true,
intercept: [
{
when: {
adUnitCode: 'div-gpt-ad-51545-0',
},
then: {
cpm: 25,
mediaType: "video",
vastUrl: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",
// vastXml: "<VAST version=\"3.0\"> <Ad id=\"123\"> <InLine> <AdSystem>PubMatic</AdSystem> <AdTitle>VAST 2.0 Instream Test</AdTitle> <Description>VAST 2.0 Instream Test</Description> <Error> <![CDATA[https://aktrack.pubmatic.com/er=[ERRORCODE]]]> </Error> <Impression> <![CDATA[https://aktrack.pubmatic.com?e=impression]]> </Impression> <Creatives> <Creative AdID=\"123\"> <Linear> <Duration>00:00:30</Duration> <TrackingEvents> <Tracking event=\"creativeView\"> <![CDATA[https://aktrack.pubmatic.com?e=creativeView]]> </Tracking> <Tracking event=\"start\"> <![CDATA[https://aktrack.pubmatic.com?e=start]]> </Tracking> <Tracking event=\"midpoint\"> <![CDATA[https://aktrack.pubmatic.com?e=midpoint]]> </Tracking> <Tracking event=\"firstQuartile\"> <![CDATA[https://aktrack.pubmatic.com?e=firstQuartile]]> </Tracking> <Tracking event=\"thirdQuartile\"> <![CDATA[https://aktrack.pubmatic.com?e=thirdQuartile]]> </Tracking> <Tracking event=\"complete\"> <![CDATA[https://aktrack.pubmatic.com?e=complete]]> </Tracking> </TrackingEvents> <VideoClicks> <ClickThrough> <![CDATA[https://www.pubmatic.com]]> </ClickThrough> </VideoClicks> <MediaFiles> <MediaFile delivery=\"progressive\" type=\"video/mp4\" bitrate=\"500\" width=\"480\" height=\"460\" scalable=\"true\" maintainAspectRatio=\"true\"> <![CDATA[https://staging.pubmatic.com:8443/test/spinning-logo-480x360_video.mp4]]> </MediaFile> <MediaFile delivery=\"progressive\" type=\"video/ogg\" bitrate=\"500\" width=\"480\" height=\"460\" scalable=\"true\" maintainAspectRatio=\"true\"> <![CDATA[https://staging.pubmatic.com:8443/test/spinning-logo-480x360_video.ogg]]> </MediaFile> <MediaFile delivery=\"progressive\" type=\"video/x-flv\" bitrate=\"500\" width=\"400\" height=\"300\" scalable=\"true\" maintainAspectRatio=\"true\"> <![CDATA[https://staging.pubmatic.com:8443/test/PubMatic_test_video.flv]]> </MediaFile> </MediaFiles> </Linear> </Creative> <Creative AdID=\"123\"> <NonLinearAds> <TrackingEvents></TrackingEvents> <NonLinear height=\"50\" width=\"300\" minSuggestedDuration=\"00:00:05\"> <StaticResource creativeType=\"image/jpeg\"> <![CDATA[https://staging.pubmatic.com:8443/test/PubMatic_LetsBeClear_300x50.jpeg]]> </StaticResource> <NonLinearClickThrough> <![CDATA[https://www.pubmatic.com]]> </NonLinearClickThrough> </NonLinear> </NonLinearAds> </Creative> <Creative AdID=\"123\"> <CompanionAds> <Companion width=\"300\" height=\"250\"> <StaticResource creativeType=\"image/jpeg\"> <![CDATA[https://staging.pubmatic.com:8443/test/PubMatic_LetsBeClear_320x250.jpg]]> </StaticResource> <CompanionClickThrough> <![CDATA[https://www.pubmatic.com]]> </CompanionClickThrough> </Companion> </CompanionAds> </Creative> </Creatives> </InLine> </Ad> </VAST>",
ad: "<VAST version=\"3.0\"> <Ad id=\"123\"> <InLine> <AdSystem>PubMatic</AdSystem> <AdTitle>VAST 2.0 Instream Test</AdTitle> <Description>VAST 2.0 Instream Test</Description> <Error> <![CDATA[https://aktrack.pubmatic.com/er=[ERRORCODE]]]> </Error> <Impression> <![CDATA[https://aktrack.pubmatic.com?e=impression]]> </Impression> <Creatives> <Creative AdID=\"123\"> <Linear> <Duration>00:00:30</Duration> <TrackingEvents> <Tracking event=\"creativeView\"> <![CDATA[https://aktrack.pubmatic.com?e=creativeView]]> </Tracking> <Tracking event=\"start\"> <![CDATA[https://aktrack.pubmatic.com?e=start]]> </Tracking> <Tracking event=\"midpoint\"> <![CDATA[https://aktrack.pubmatic.com?e=midpoint]]> </Tracking> <Tracking event=\"firstQuartile\"> <![CDATA[https://aktrack.pubmatic.com?e=firstQuartile]]> </Tracking> <Tracking event=\"thirdQuartile\"> <![CDATA[https://aktrack.pubmatic.com?e=thirdQuartile]]> </Tracking> <Tracking event=\"complete\"> <![CDATA[https://aktrack.pubmatic.com?e=complete]]> </Tracking> </TrackingEvents> <VideoClicks> <ClickThrough> <![CDATA[https://www.pubmatic.com]]> </ClickThrough> </VideoClicks> <MediaFiles> <MediaFile delivery=\"progressive\" type=\"video/mp4\" bitrate=\"500\" width=\"480\" height=\"460\" scalable=\"true\" maintainAspectRatio=\"true\"> <![CDATA[https://staging.pubmatic.com:8443/test/spinning-logo-480x360_video.mp4]]> </MediaFile> <MediaFile delivery=\"progressive\" type=\"video/ogg\" bitrate=\"500\" width=\"480\" height=\"460\" scalable=\"true\" maintainAspectRatio=\"true\"> <![CDATA[https://staging.pubmatic.com:8443/test/spinning-logo-480x360_video.ogg]]> </MediaFile> <MediaFile delivery=\"progressive\" type=\"video/x-flv\" bitrate=\"500\" width=\"400\" height=\"300\" scalable=\"true\" maintainAspectRatio=\"true\"> <![CDATA[https://staging.pubmatic.com:8443/test/PubMatic_test_video.flv]]> </MediaFile> </MediaFiles> </Linear> </Creative> <Creative AdID=\"123\"> <NonLinearAds> <TrackingEvents></TrackingEvents> <NonLinear height=\"50\" width=\"300\" minSuggestedDuration=\"00:00:05\"> <StaticResource creativeType=\"image/jpeg\"> <![CDATA[https://staging.pubmatic.com:8443/test/PubMatic_LetsBeClear_300x50.jpeg]]> </StaticResource> <NonLinearClickThrough> <![CDATA[https://www.pubmatic.com]]> </NonLinearClickThrough> </NonLinear> </NonLinearAds> </Creative> <Creative AdID=\"123\"> <CompanionAds> <Companion width=\"300\" height=\"250\"> <StaticResource creativeType=\"image/jpeg\"> <![CDATA[https://staging.pubmatic.com:8443/test/PubMatic_LetsBeClear_320x250.jpg]]> </StaticResource> <CompanionClickThrough> <![CDATA[https://www.pubmatic.com]]> </CompanionClickThrough> </Companion> </CompanionAds> </Creative> </Creatives> </InLine> </Ad> </VAST>"
}
},
]
}
});

pbjs.addAdUnits(adUnits);

pbjs.onEvent('videoSetupComplete', (e) => {
console.log('player setup complete: ', e);
});

pbjs.onEvent('videoSetupFailed', e => {
console.log('player setup failed: ', e);
});

pbjs.onEvent('videoPlaybackRequest', (e) => {
pbjs.requestBids(adUnits);
});

pbjs.onEvent('videoBidError', e => {
console.log('An Ad Error came from a Bid: ', e);
});

pbjs.onEvent('videoBidImpression', e => {
console.log('An Ad Impression came from a Bid: ', e);
});
});
</script>
</head>

<body>
<div id ="player"></div>
</body>

</html>
89 changes: 89 additions & 0 deletions integrationExamples/videoModule/jwplayer/bidRequestScheduling.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<html>

<head>
<script src="https://cdn.jwplayer.com/libraries/l5MchIxB.js"></script>
<script async src="../../../build/dev/prebid.js"></script>

<title>JW Player with Bid Request Scheduling</title>

<!--This demo configures JW Player's Player Bidding product to handle ad scheduling-->

<script>

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

pbjs.que.push(function () {
pbjs.setConfig({
video: {
providers: [{
divId: 'player',
vendorCode: 1, // JW Player vendorCode
playerConfig: {
licenseKey: 'IAjLREYRLylTWsfLN3FoN/O3iQLbs+AfgZLlkAoyH8gSf7TnNtmOLcR8CUY=',
params: {
vendorConfig: {
file: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/SubaruOutbackOnStreetAndDirt.mp4',
advertising: {
client: "googima",
schedule: {
adBreak1: {
tag: "//pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/137679306/HB_Dev_Center_Example&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&correlator=",
offset: "pre"
},
adBreak2: {
tag: "//pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/137679306/HB_Dev_Center_Example&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&correlator=",
offset: "10"
},
adBreak3: {
tag: "//pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/137679306/HB_Dev_Center_Example&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&correlator=",
offset: "20"
},
adBreak4: {
tag: "//pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/137679306/HB_Dev_Center_Example&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&correlator=",
offset: "post"
}
},
bids: {
client: "bidding",
settings: {
mediationLayerAdServer: "dfp",
bidTimeout: 2000
},
bidders: [
{
name: "ix",
siteId: "300"
}
]
}
}
}
}
}
},]
},
});

pbjs.onEvent('videoSetupComplete', e => {
console.log('player setup complete: ', e);
});

pbjs.onEvent('videoSetupFailed', e => {
console.log('player setup failed: ', e);
});

pbjs.onEvent('videoAdError', e => {
console.log('adError: ', e);
});
});
</script>
</head>

<body>
<h2>JW Player with Bid Request Scheduling</h2>
<h5>Div-1: Player placeholder div</h5>
<div id='player'></div>
</body>

</html>
Loading

0 comments on commit 0c69238

Please sign in to comment.