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

Get Ortb Params #12

Merged
merged 18 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
17 changes: 7 additions & 10 deletions integrationExamples/videoModule/videojsAdapter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,15 @@
<h2>VideoJS Adapter Test</h2>

<h5>Div-1 existing Player</h5>
<div id='vid-div-1'>
<video class="video-js vjs-big-play-centered" data-setup='{"controls": true, "autoplay": false, "preload": "auto"}'>
<source src="http://content.bitsontherun.com/videos/3XnJSIm4-52qL9xLP.mp4" type="video/mp4">
</video>
</div>

<video id='vid-div-1' class="video-js vjs-big-play-centered" data-setup='{"controls": true, "autoplay": false, "preload": "auto"}'>
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>

<h5>Div-2 existing player without automatic setup</h5>
<div id='vid-div-2'>
<video-js data-setup='{"controls": true}'>
<source src="http://content.bitsontherun.com/videos/3XnJSIm4-52qL9xLP.mp4" type="video/mp4">
</video-js>
</div>
<video-js id='vid-div-2' data-setup='{"controls": true}'>
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video-js>

<h5>Div-3 controlled Player</h5>
<div id='vid-div-3'></div>
Expand Down
4 changes: 2 additions & 2 deletions modules/jwplayerVideoProvider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE
PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE, AD_POSITION
} from './videoModule/constants/ortb.js';
import {
SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY,
Expand Down Expand Up @@ -103,7 +103,7 @@ export function JWPlayerProvider(config, jwplayer_, adState_, timeState_, callba
// only specify ad position when in Fullscreen since computational cost is low
// ad position options are listed in oRTB 2.5 section 5.4
// https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf
video.pos = 7; // TODO make constant in oRTB
video.pos = AD_POSITION.FULL_SCREEN; // TODO make constant in oRTB
}

const item = player.getPlaylistItem() || {}; // TODO does player call need optimization ?
Expand Down
22 changes: 22 additions & 0 deletions modules/videoModule/constants/ortb.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ export const PLACEMENT = {
INTERSTITIAL_SLIDER_FLOATING: 5
};

/*
ORTB 2.5 section 5.4 - Ad Position
*/
export const AD_POSITION = {
UNKNOWN: 0,
ABOVE_THE_FOLD: 1,
BELOW_THE_FOLD: 3,
HEADER: 4,
FOOTER: 5,
SIDEBAR: 6,
FULL_SCREEN: 7
}

/*
ORTB 2.5 section 5.11 - Playback Cessation Modes
*/
export const PLAYBACK_END = {
VIDEO_COMPLETION: 1,
VIEWPORT_LEAVE: 2,
FLOATING: 3
}

/*
ORTB 2.5 section 5.10 - Playback Methods
*/
Expand Down
96 changes: 87 additions & 9 deletions modules/videojsVideoProvider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {
PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE, AD_POSITION, PLAYBACK_END
} from './videoModule/constants/ortb.js';
import { VIDEO_JS_VENDOR } from './videoModule/constants/vendorCodes.js';
import { videoVendorDirectory } from './videoModule/vendorDirectory.js';

Expand All @@ -15,7 +18,6 @@ export function VideojsProvider(config, videojs_, adState_, timeState_, callback
// TODO: come up with code for player absent
return;
}

playerVersion = videojs.VERSION;

if (playerVersion < minimumSupportedPlayerVersion) {
Expand All @@ -25,29 +27,105 @@ export function VideojsProvider(config, videojs_, adState_, timeState_, callback

// returns the player if it exists, or attempts to instantiate a new one
player = videojs(divId, playerConfig, function() {
// callback runs in both cases
// callback runs in both cases
});
// TODO: make sure ortb gets called in integration example
// currently testing with a hacky solution by hooking it to window
// window.ortb = this.getOrtbParams
}

function getId() {
return divId;
}

function getOrtbParams() {
if (!player) {
return null;
}

let playBackMethod = PLAYBACK_METHODS.CLICK_TO_PLAY
// returns a boolean or a string with the autoplay strategy
const autoplay = player.autoplay();
const muted = player.muted() || autoplay === 'muted';
if (autoplay!==false) {
playBackMethod = isMuted ? PLAYBACK_METHODS.AUTOPLAY_MUTED : PLAYBACK_METHODS.AUTOPLAY;
}
const supportedMediaTypes = Object.values(VIDEO_MIME_TYPE).filter(
// Follows w3 spec https://www.w3.org/TR/2011/WD-html5-20110113/video.html#dom-navigator-canplaytype
type => player.canPlayType(type) !== ''
)
if(videojs.ima.vpaidMode){
supportedMediaTypes.push(VPAID_MIME_TYPE)
}

const video = {
mimes: [],
w: 0,
h: 0,
mimes: supportedMediaTypes,
// Based on the protocol support provided by the videojs-ima plugin
// https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/compatibility
// Need to check for the plugins prescence by checking videojs.ima
protocols: videojs.ima ? [
PROTOCOLS.VAST_2_0,
] : [],
api: [
API_FRAMEWORKS.VPAID_2_0
karimMourra marked this conversation as resolved.
Show resolved Hide resolved
],
// TODO: Make sure this returns dimensions in DIPS
h: player.currentHeight(),
w: player.currentWidth(),
// May not be in stream if videojs is only used to serve ad content
// placement: PLACEMENT.IN_STREAM,
AnirudhRahul marked this conversation as resolved.
Show resolved Hide resolved
// both linearity forms are supported so the param is excluded
// sequence - TODO not yet supported
// battr: adConfig.battr, TODO: Not sure where this should be coming from
Copy link
Collaborator

Choose a reason for hiding this comment

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

just FYI this would probably have to be specified by the publisher or some content metadata. No need to worry about it for now

maxextended: -1,
boxingallowed: 1,
playbackmethod: [ playBackMethod ],
playbackend: PLAYBACK_END.VIDEO_COMPLETION,
skip: 1,
pos: AD_POSITION.UNKNOWN // default value modified below
};

const content = {};
// Placement according to IQG Guidelines 4.2.8
// https://cdn2.hubspot.net/hubfs/2848641/TrustworthyAccountabilityGroup_May2017/Docs/TAG-Inventory-Quality-Guidelines-v2_2-10-18-2016.pdf?t=1509469105938
if (player.isFullscreen()) {
video.pos = AD_POSITION.FULL_SCREEN;
}
else if(videojs.dom.findPosition){
const {left, top, width, height} = videojs.dom.findPosition(player.el())
AnirudhRahul marked this conversation as resolved.
Show resolved Hide resolved
const bottom = window.innerHeight - top - height
const right = window.innerWidth - left - width
// Make sure video isn't overflowed horizontally
if(left >= 0 && right >= 0){
if(top>=0 && bottom>=0){
video.pos = AD_POSITION.ABOVE_THE_FOLD
}
else if(top>=0){
video.pos = AD_POSITION.BELOW_THE_FOLD
}
}
AnirudhRahul marked this conversation as resolved.
Show resolved Hide resolved
}

return {
video,
content
const content = {
// id:, TODO: find a suitable id for videojs sources
url: player.currentSrc()
};
// Only include length if player is ready
if (player.readyState() > 0) {
content.len = Math.round(player.duration());
}
const item = player.getMedia();
if (item) {
for (let param of ['album', 'artist', 'title']) {
AnirudhRahul marked this conversation as resolved.
Show resolved Hide resolved
if (item[param]) {
content[param] = item[param];
}
}
}

return {video, content};
}

// Plugins to integrate: https://github.com/googleads/videojs-ima
function setAdTagUrl(adTagUrl, options) {
}

Expand Down
Loading