Skip to content

Commit

Permalink
Add beachfront bidder params to set outstream player settings (prebid…
Browse files Browse the repository at this point in the history
…#3868)

* Add beachfront bidder params to set outstream player settings

* Add example for outstream player params

* Run ci again
  • Loading branch information
jsalis authored and Alex committed Aug 1, 2019
1 parent fe6d891 commit cde1873
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 14 deletions.
32 changes: 18 additions & 14 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { VIDEO, BANNER } from '../src/mediaTypes';
import find from 'core-js/library/fn/array/find';
import includes from 'core-js/library/fn/array/includes';

const ADAPTER_VERSION = '1.4';
const ADAPTER_VERSION = '1.5';
const ADAPTER_NAME = 'BFIO_PREBID';
const OUTSTREAM = 'outstream';

Expand Down Expand Up @@ -143,21 +143,20 @@ function createRenderer(bidRequest) {
loaded: false
});

renderer.setRender(outstreamRender);

return renderer;
}

function outstreamRender(bid) {
bid.renderer.push(() => {
window.Beachfront.Player(bid.adUnitCode, {
ad_tag_url: bid.vastUrl,
width: bid.width,
height: bid.height,
expand_in_view: false,
collapse_on_complete: true
renderer.setRender(bid => {
bid.renderer.push(() => {
window.Beachfront.Player(bid.adUnitCode, {
adTagUrl: bid.vastUrl,
width: bid.width,
height: bid.height,
expandInView: getPlayerBidParam(bidRequest, 'expandInView', false),
collapseOnComplete: getPlayerBidParam(bidRequest, 'collapseOnComplete', true),
progressColor: getPlayerBidParam(bidRequest, 'progressColor')
});
});
});

return renderer;
}

function getFirstSize(sizes) {
Expand Down Expand Up @@ -231,6 +230,11 @@ function getBannerBidParam(bid, key) {
return utils.deepAccess(bid, 'params.banner.' + key) || utils.deepAccess(bid, 'params.' + key);
}

function getPlayerBidParam(bid, key, defaultValue) {
let param = utils.deepAccess(bid, 'params.player.' + key);
return param === undefined ? defaultValue : param;
}

function isVideoBidValid(bid) {
return isVideoBid(bid) && getVideoBidParam(bid, 'appId') && getVideoBidParam(bid, 'bidfloor');
}
Expand Down
32 changes: 32 additions & 0 deletions modules/beachfrontBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,35 @@ Module that connects to Beachfront's demand sources
}
];
```

# Outstream Player Params Example
```javascript
var adUnits = [
{
code: 'test-video-outstream',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [ 640, 360 ]
}
},
bids: [
{
bidder: 'beachfront',
params: {
video: {
bidfloor: 0.01,
appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76',
mimes: [ 'video/mp4', 'application/javascript' ]
},
player: {
progressColor: '#50A8FA',
expandInView: false,
collapseOnComplete: true
}
}
}
]
}
];
```
58 changes: 58 additions & 0 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from 'chai';
import sinon from 'sinon';
import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter';
import { parse as parseUrl } from 'src/url';

Expand Down Expand Up @@ -531,6 +532,63 @@ describe('BeachfrontAdapter', function () {
url: OUTSTREAM_SRC
});
});

it('should initialize a player for outstream bids', () => {
const width = 640;
const height = 480;
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = {
video: {
context: 'outstream',
playerSize: [ width, height ]
}
};
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
window.Beachfront = { Player: sinon.spy() };
bidResponse.adUnitCode = bidRequest.adUnitCode;
bidResponse.renderer.render(bidResponse);
sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match({
adTagUrl: bidResponse.vastUrl,
width: bidResponse.width,
height: bidResponse.height,
expandInView: false,
collapseOnComplete: true
}));
delete window.Beachfront;
});

it('should configure outstream player settings from the bidder params', () => {
const width = 640;
const height = 480;
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = {
video: {
context: 'outstream',
playerSize: [ width, height ]
}
};
bidRequest.params.player = {
expandInView: true,
collapseOnComplete: false,
progressColor: 'green'
};
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
cmpId: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
window.Beachfront = { Player: sinon.spy() };
bidResponse.adUnitCode = bidRequest.adUnitCode;
bidResponse.renderer.render(bidResponse);
sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match(bidRequest.params.player));
delete window.Beachfront;
});
});

describe('for banner bids', function () {
Expand Down

0 comments on commit cde1873

Please sign in to comment.