Skip to content
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

Support of outstream renderer in oneVideo Adaptor #3959

Merged
merged 11 commits into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 20 additions & 2 deletions modules/oneVideoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,22 @@ export const spec = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: bid.price,
creativeId: bid.id,
adId: bid.adid,
creativeId: bid.crid,
width: size.width,
height: size.height,
mediaType: 'video',
currency: response.cur,
ttl: 100,
netRevenue: true
netRevenue: true,
adUnitCode: bidRequest.adUnitCode
};
if (bid.nurl) {
bidResponse.vastUrl = bid.nurl;
} else if (bid.adm) {
bidResponse.vastXml = bid.adm;
}
bidResponse.renderer = (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined;
return bidResponse;
},
/**
Expand Down Expand Up @@ -216,5 +219,20 @@ function getRequestData(bid, consentData) {
function isSecure() {
return document.location.protocol === 'https:';
}
/**
* Create oneVideo renderer
* @returns {*}
*/
function newRenderer(bidRequest, bid) {
if (!bidRequest.renderer) {
bidRequest.renderer = {};
bidRequest.renderer.url = 'https://cdn.vidible.tv/prod/hb-outstream-renderer/renderer.js';
bidRequest.renderer.render = function(bid) {
setTimeout(function () {
o2PlayerRender(bid);
}, 700)
};
}
}

registerBidder(spec);
2 changes: 1 addition & 1 deletion test/pages/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ <h2>Prebid Video -- video.js</h2>

</script>
</body>
</html>
</html>
16 changes: 13 additions & 3 deletions test/spec/modules/oneVideoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ describe('OneVideoBidAdapter', function () {

beforeEach(function () {
bidRequest = {
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 480]
}
},
bidder: 'oneVideo',
sizes: [640, 480],
bidId: '30b3efwfwe1e',
adUnitCode: 'video1',
params: {
video: {
playerWidth: 640,
Expand Down Expand Up @@ -140,20 +147,23 @@ describe('OneVideoBidAdapter', function () {
});

it('should return a valid bid response with just "adm"', function () {
const serverResponse = {seatbid: [{bid: [{id: 1, price: 6.01, adm: '<VAST></VAST>'}]}], cur: 'USD'};
const serverResponse = {seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: '<VAST></VAST>'}]}], cur: 'USD'};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
let o = {
requestId: bidRequest.bidId,
bidderCode: spec.code,
cpm: serverResponse.seatbid[0].bid[0].price,
creativeId: serverResponse.seatbid[0].bid[0].id,
adId: serverResponse.seatbid[0].bid[0].adid,
creativeId: serverResponse.seatbid[0].bid[0].crid,
vastXml: serverResponse.seatbid[0].bid[0].adm,
width: 640,
height: 480,
mediaType: 'video',
currency: 'USD',
ttl: 100,
netRevenue: true
netRevenue: true,
adUnitCode: bidRequest.adUnitCode,
renderer: (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined,
};
expect(bidResponse).to.deep.equal(o);
});
Expand Down