Skip to content

AD 1640 #9

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

Merged
merged 5 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!--
-<!--

-->

<html>

<head>
<script async src="../../build/dev/prebid.js"></script>
<script async src="../../../build/dev/prebid.js"></script>
<script>
var adUnits = [{
code: 'div-gpt-ad-51545-0',
Expand Down Expand Up @@ -42,17 +42,16 @@

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>
<script>

pbjs.que.push(function () {
pbjs.onEvent('adImpression', event => {
console.log('adImpression: ', event);
});
pbjs.addAdUnits(adUnits);
pbjs.setConfig({
video: {
providers: [{
divId: 'vid-div-1',
// vendorCode for jwplayer
vendorCode: 1,
playerConfig: {
licenseKey: "INSERT LICENSE KEY HERE",
Expand Down Expand Up @@ -96,6 +95,7 @@
}]
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids();
});
</script>
Expand All @@ -109,5 +109,4 @@ <h5>Div-2</h5>
<div id='vid-div-2'></div>
</body>

</html>

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

<head>
<script async src="../../../build/dev/prebid.js"></script>
<link href="https://vjs.zencdn.net/7.17.0/video-js.css" rel="stylesheet" />
<!-- Setup ad units -->
<script>
var adUnits = [{
code: 'div-gpt-ad-51545-0',
sizes: [[600, 500]],
mediaTypes: {
video: {
sizes: [[600, 500]]
}
},
video: {
divId: 'vid-div-1',
adServer: {
vendorCode: "gam",
params: {
iu: '/19968336/prebid_cache_video_adunit',
cust_params: {
section: 'blog',
anotherKey: 'anotherValue'
},
output: 'vast'
}
},
},

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

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

pbjs.que.push(function () {
pbjs.onEvent('adImpression', event => {
console.log('adImpression: ', event);
});
pbjs.setConfig({
video: {
providers: [{
divId: 'vid-div-1',
// vendorCode for videojs
vendorCode: 2,
playerConfig: {
params: {
vendorConfig: {
mediaid: 'd9J2zcaA',
advertising: {
adscheduleid: "00000000",
client: 'vast',
offset: "10",
tag: [
"http://playertest.longtailvideo.com/pre-bad.xml",
"http://playertest.longtailvideo.com/mid.xml"
],
}
}
}
}
},]
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids();
});
</script>
</head>

<body>
<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>

<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>

<h5>Div-3 controlled Player</h5>
<div id='vid-div-3'></div>


<script src="https://vjs.zencdn.net/7.17.0/video.min.js"></script>
<script>
</script>
</body>

</html>

3 changes: 2 additions & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
],
"videoModule": [
"coreVideo",
"jwplayerVideoProvider"
"jwplayerVideoProvider",
"videojsVideoProvider"
]
}
2 changes: 2 additions & 0 deletions modules/videoModule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,5 @@ export function pbVideoFactory() {
pbVideo.init();
return pbVideo;
}

pbVideoFactory();
132 changes: 132 additions & 0 deletions modules/videojsVideoProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import {
PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE
} from './videoModule/constants/ortb.js';
import {
SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY,
AD_TIME, AD_PAUSE, AD_CLICK, AD_SKIPPED, AD_ERROR, AD_COMPLETE, AD_BREAK_END, PLAYLIST, PLAYBACK_REQUEST,
AUTOSTART_BLOCKED, PLAY_ATTEMPT_FAILED, CONTENT_LOADED, PLAY, PAUSE, BUFFER, TIME, SEEK_START, SEEK_END, MUTE, VOLUME,
RENDITION_UPDATE, ERROR, COMPLETE, PLAYLIST_COMPLETE, FULLSCREEN, PLAYER_RESIZE, VIEWABLE, CAST, PLAYBACK_MODE
} from './videoModule/constants/events.js';
import stateFactory from './videoModule/shared/state.js';
import { adStateFactory, timeStateFactory, callbackStorageFactory} from './jwplayerVideoProvider.js';
import { VIDEO_JS_VENDOR } from './videoModule/constants/vendorCodes.js';
import { videoVendorDirectory } from './videoModule/vendorDirectory.js';

export function VideojsProvider(config, videojs_, adState_, timeState_, callbackStorage_, utils) {
let videojs = videojs_;
let player = null;
let playerVersion = null;
const {playerConfig, divId} = config;

let adState = adState_;
let timeState = timeState_;
let callbackStorage = callbackStorage_;
let minimumSupportedPlayerVersion = 'v7.17.0';


function init() {
console.log("Initialized videojs provider")

if (!videojs) {
triggerSetupFailure(-1); // TODO: come up with code for player absent
return;
}

// playerVersion = videojs.version;

// if (playerVersion < minimumSupportedPlayerVersion) {
// triggerSetupFailure(-2); // TODO: come up with code for version not supported
// return;
// }

// player = videojs(divId);
// if (player.getState() === undefined) {
// setupPlayer(playerConfig);
// } else {
// setupCompleteCallback && setupCompleteCallback(SETUP_COMPLETE, getSetupCompletePayload());
// }
}

function getId() {
return divId;
}

function getOrtbParams() {
console.log("Requested ortb params")
// if (!player) {
// return;
// }
// const config = player.getConfig();
// const adConfig = config.advertising || {};
supportedMediaTypes = supportedMediaTypes || utils.getSupportedMediaTypes(MEDIA_TYPES);

const video = {
mimes: [],
w: 0,
h: 0,
};

const content = {
id: item.mediaid,
url: item.file,
title: item.title,
cat: item.iabCategories,
keywords: item.tags,
len: duration,
};

return {
video,
content
}
}

function setAdTagUrl(adTagUrl, options) {
console.log("Set ad tag url:", adTagUrl)
// if (!player) {
// return;
// }
// player.playAd(adTagUrl || options.adXml, options);
}

function onEvents(events, callback) {
console.log("Added callback for", events)
}

function offEvents(events, callback) {
console.log("Removed callback for", events)

}

function destroy() {
console.log("Destroying player")
if (!player) {
return;
}
player.remove();
player = null;
}

return {
init,
getId,
getOrtbParams,
setAdTagUrl,
onEvents,
offEvents,
destroy
};
}



const videojsSubmoduleFactory = function (config) {
const adState = adStateFactory();
const timeState = timeStateFactory();
const callbackStorage = callbackStorageFactory();
return VideojsProvider(config, null, adState, timeState, callbackStorage, {});
}
videojsSubmoduleFactory.vendorCode = VIDEO_JS_VENDOR;

videoVendorDirectory[VIDEO_JS_VENDOR] = videojsSubmoduleFactory;
export default videojsSubmoduleFactory;