-
Notifications
You must be signed in to change notification settings - Fork 1
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
Get Ortb Params #12
Changes from 7 commits
883bb64
ac85e74
6f4fb24
612f037
b4e4d55
4a4c6fe
c835dfe
6e312d5
575f9d6
06b96ad
dc2b6d1
d5127da
5e7e904
d39fb80
bb7777a
961ccce
c4cec43
876536e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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'; | ||
|
||
|
@@ -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) { | ||
|
@@ -25,29 +27,82 @@ 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 | ||
const isMuted = player.muted() || player.autoplay() === 'muted'; // todo autoplayAdsMuted only applies to preRoll | ||
if (player.autoplay()) { | ||
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. prefer vars over multiple function calls:
it minifies better because method calls don't get minified. |
||
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) !== '' | ||
).concat([VPAID_MIME_TYPE]) | ||
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. we might have to check that the ad providers can render VPAIDs. VPAIDs are ads that contain javascript. In a way it's more an embedded application than a video creative |
||
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(), | ||
placement: PLACEMENT.IN_STREAM, | ||
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. could video.js ever be used only as an ads player ? If so it would be |
||
// both linearity forms are supported | ||
AnirudhRahul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// sequence - TODO not yet supported | ||
// battr: adConfig.battr, TODO: Not sure where this should be coming from | ||
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. 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 | ||
AnirudhRahul marked this conversation as resolved.
Show resolved
Hide resolved
AnirudhRahul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
const content = {}; | ||
if (player.isFullscreen()) { | ||
// only specify ad position when in Fullscreen since computational cost is low | ||
video.pos = AD_POSITION.FULL_SCREEN; | ||
} | ||
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) { | ||
} | ||
|
||
|
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.
what does
autoplay()
return ? In the line above you compare it to a string. In this line you use it as a conditionI like truthy conditions, as long as it can be falsy.