forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 1
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
AD 1640 #9
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c8cd174
Added draft for videojs integration example
AnirudhRahul e75c310
Moved jwplayer integration example, added draft for videojs example
AnirudhRahul c2d94a4
Added call to video adapter
AnirudhRahul 3fcdc7c
Created integration example for a mocked videojs adapter
AnirudhRahul 0ea1795
Fixed call order for integration examples, moved imports up
AnirudhRahul 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 hidden or 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
105 changes: 105 additions & 0 deletions
105
integrationExamples/videoModule/videojsAdapter/index.html
This file contains hidden or 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,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.addAdUnits(adUnits); | ||
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.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> | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -55,6 +55,7 @@ | |
], | ||
"videoModule": [ | ||
"coreVideo", | ||
"jwplayerVideoProvider" | ||
"jwplayerVideoProvider", | ||
"videojsVideoProvider" | ||
] | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -139,3 +139,5 @@ export function pbVideoFactory() { | |
pbVideo.init(); | ||
return pbVideo; | ||
} | ||
|
||
pbVideoFactory(); |
This file contains hidden or 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,131 @@ | ||
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'; | ||
|
||
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 | ||
}; | ||
} | ||
|
||
import { VIDEO_JS_VENDOR } from './videoModule/constants/vendorCodes.js'; | ||
import { videoVendorDirectory } from './videoModule/vendorDirectory.js'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Import statements always go on top in JS. I don't think it affects functionality in any way, but it's the industry norm. |
||
|
||
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; |
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.
WeI think in general it's best to call
setConfig
beforeaddAdUnits
since a lot of module setup happens insetConfig
. If it's the same in the jwplayer demo then we'll want to update it as well.Functionality wise it might not matter but since developers will use these pages as documentation, we don't want to confuse them