Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Player integration for Freewheel video ad server #177

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 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
126 changes: 105 additions & 21 deletions elements/bulbs-video/components/revealed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 });

Expand Down Expand Up @@ -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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

buildCustomSiteSectionId

// Custom Site Section ID
// format: <device acronym>.<site name>_<dfp section>_<host channel>
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we make this getDeviceAcronym to stay consistent with those other accessor functions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

The 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

buildCustomContentVideoAssetId

// Custom content video asset id
// format: onion_<videohub reference id>
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be the freewheel network hash


// required global params
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are missing the nw param, which should be window.FREEWHEEL_NETWORK_ID

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; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's modify this line in vastTest:

let vastId = this.parseParam('xgid', searchString);

So we make the parameter (which is ad placement id), let's call it apid


// Key Values
baseUrl += ';&video_id=' + videohubReferenceId;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't need the ampersand after the semi-colon, so ;&video_id becomes ;video_id

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';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't need the ampersand after the semi-colon, so ;&slid becomes ;slid

baseUrl += '&tpcl=' + 'PREROLL';
baseUrl += '&ptgt=' + 'a';

return baseUrl;
}
Expand All @@ -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 = {
Expand Down
Loading