-
Notifications
You must be signed in to change notification settings - Fork 1
Player integration for Freewheel video ad server #177
base: master
Are you sure you want to change the base?
Changes from 18 commits
cc9115f
fa3aeeb
57f4d6c
01e1e8f
67940ab
80ff21e
b5e393b
1889522
74f7633
12d2e85
54018d8
c7c7150
2d9ea9a
16c0d31
de5e7a2
197df85
b6f5c0c
b716fdd
e8acadb
aeca9b9
4f97e9b
fe7e831
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ import React, { PropTypes } from 'react'; | |
import invariant from 'invariant'; | ||
|
||
// FIXME: where should this be defined? Per-app? | ||
// Or in some better sort of settings file here? | ||
// or in some better sort of settings file here? | ||
global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'UA-223393-14'; | ||
global.BULBS_ELEMENTS_COMSCORE_ID = '6036328'; | ||
|
||
|
@@ -40,6 +40,15 @@ export default class Revealed extends React.Component { | |
'`<bulbs-video>` requires `jwplayer` to be in global scope.' | ||
); | ||
|
||
invariant( | ||
window.isMobile, | ||
'`<bulbs-video>` requires `isMobile()` to be set on window.' | ||
); | ||
|
||
invariant( | ||
window.FREEWHEEL_NETWORK_ID, | ||
'`<bulbs-video>` requires `FREEWHEEL_NETWORK_ID` to be set on window.' | ||
); | ||
let gaPrefix = makeGaPrefix(); | ||
ga('create', BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID, 'auto', { name: gaPrefix }); | ||
|
||
|
@@ -156,30 +165,97 @@ export default class Revealed extends React.Component { | |
return false; | ||
} | ||
|
||
vastUrl (videoMeta) { | ||
let baseUrl = 'http://us-theonion.videoplaza.tv/proxy/distributor/v2?rt=vast_2.0'; | ||
|
||
let vastTestId = this.vastTest(window.location.search); | ||
getProfValue () { | ||
let prof; | ||
if (window.isMobile.any) { | ||
prof = 'theonion_mobileweb_html5'; | ||
} | ||
else { | ||
prof = 'theonion_desktop_html5'; | ||
} | ||
return prof; | ||
} | ||
|
||
// AD_TYPE: one of p (preroll), m (midroll), po (postroll), o (overlay) | ||
baseUrl += '&tt=p'; | ||
videoMeta.tags.push('html5'); // Force HTML 5 | ||
// Tags | ||
baseUrl += '&t=' + videoMeta.tags; | ||
//Category | ||
let hostChannel = videoMeta.hostChannel; | ||
let channel = videoMeta.channel_slug; | ||
let series = videoMeta.series_slug; | ||
let category = `${hostChannel}/${channel}`; | ||
if (series) { | ||
category += `/${series}`; | ||
setDeviceAcronym () { | ||
let deviceAcronym; | ||
if (window.isMobile.any) { | ||
deviceAcronym = 'm'; | ||
} | ||
else { | ||
deviceAcronym = 'd'; | ||
} | ||
baseUrl += '&s=' + category; | ||
baseUrl += '&rnd=' + this.cacheBuster(); | ||
return deviceAcronym; | ||
} | ||
|
||
getSiteName () { | ||
let targetChannel = this.props.video.targeting.target_channel; | ||
return targetChannel.replace(/-/g, ''); | ||
} | ||
|
||
if (vastTestId) { | ||
baseUrl += '&xgid=' + vastTestId; | ||
getDfpSection () { | ||
let dfpSection; | ||
if (window.TARGETING.dfp_section) { | ||
dfpSection = window.TARGETING.dfp_section; | ||
} | ||
else if (window.TARGETING.dfp_specialcoverage) { | ||
let slug = window.TARGETING.dfp_specialcoverage; | ||
dfpSection = `specialcoverage_${slug}`; | ||
} | ||
else { | ||
dfpSection = 'video'; | ||
} | ||
return dfpSection; | ||
} | ||
|
||
buildCsid (hostChannel) { | ||
// Custom Site Section ID | ||
// format: <device acronym>.<site name>_<dfp section>_<host channel> | ||
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. I think we can remove this comment, because that format is clear in the interpolation below |
||
let deviceAcronym = this.setDeviceAcronym(); | ||
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. Can we make this 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. I was trying to differentiate from values we are pulling in from other places the vs values we are setting. 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. but I suppose its really 6 of one half a dozen of the other |
||
let siteName = this.getSiteName(); | ||
let siteSection = this.getDfpSection(); | ||
|
||
return `${deviceAcronym}.${siteName}_${siteSection}_${hostChannel}`; | ||
} | ||
|
||
buildCaid (videohubReferenceId) { | ||
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.
|
||
// Custom content video asset id | ||
// format: onion_<videohub reference id> | ||
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. I think we can remove this comment, because that format is clear in the interpolation below |
||
return `onion_${videohubReferenceId}`; | ||
} | ||
|
||
vastUrl (videoMeta) { | ||
let hostChannel = videoMeta.hostChannel; | ||
let videohubReferenceId = videoMeta.id; | ||
let randomVideoPlayerNumber = videoMeta.vprn; | ||
let vastTestId = this.vastTest(window.location.search); | ||
let series = videoMeta.series_slug; | ||
let campaignId = this.props.targetCampaignId; | ||
let specialCoverage = this.props.targetSpecialCoverage; | ||
|
||
let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; | ||
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. This should be the freewheel network hash |
||
|
||
// required global params | ||
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 are missing the |
||
baseUrl += 'resp=' + 'vmap1'; | ||
baseUrl += '&prof=' + this.getProfValue(); | ||
baseUrl += '&csid=' + this.buildCsid(hostChannel); | ||
baseUrl += '&caid=' + this.buildCaid(videohubReferenceId); | ||
baseUrl += '&pvrn=' + this.cacheBuster(); | ||
baseUrl += '&vprn=' + randomVideoPlayerNumber; | ||
|
||
// optional global param | ||
if (vastTestId) { baseUrl += '&cana=' + vastTestId; } | ||
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. Let's modify this line in
So we make the parameter (which is ad placement id), let's call it |
||
|
||
// Key Values | ||
baseUrl += ';&video_id=' + videohubReferenceId; | ||
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 shouldn't need the ampersand after the semi-colon, so |
||
baseUrl += '&channel_slug=' + videoMeta.channel_slug; | ||
if (series) { baseUrl += '&series_slug=' + series; } | ||
if (campaignId) { baseUrl += '&campaign_id=' + campaignId; } | ||
if (specialCoverage) { baseUrl += '&special_coverage=' + specialCoverage; } | ||
|
||
// Slot Params *Required Fields* | ||
baseUrl += ';&slid=' + 'Preroll'; | ||
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 shouldn't need the ampersand after the semi-colon, so |
||
baseUrl += '&tpcl=' + 'PREROLL'; | ||
baseUrl += '&ptgt=' + 'a'; | ||
|
||
return baseUrl; | ||
} | ||
|
@@ -205,6 +281,14 @@ export default class Revealed extends React.Component { | |
element.id = videoMeta.gaPrefix; | ||
let player = global.jwplayer(element); | ||
|
||
// random video player number ending with video id | ||
// to be used in vastUrl query string | ||
let randomVideoPlayerNumber = parseInt( | ||
`${this.cacheBuster()}${videoMeta.id}`, | ||
10 | ||
); | ||
videoMeta.vprn = randomVideoPlayerNumber; | ||
|
||
player.videoMeta = videoMeta; | ||
|
||
let playerOptions = { | ||
|
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.
buildCustomSiteSectionId