Skip to content

Commit

Permalink
Update playerSize logic
Browse files Browse the repository at this point in the history
  • Loading branch information
epechuzal committed Sep 1, 2021
1 parent e46181b commit 3c5c4fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ export const sharethroughAdapterSpec = {

if (bidReq.mediaTypes && bidReq.mediaTypes.video) {
const videoRequest = bidReq.mediaTypes.video;

// default playerSize, only change this if we know width and height are properly defined in the request
let [w, h] = [640, 360];
if (videoRequest.playerSize && videoRequest.playerSize[0] && videoRequest.playerSize[1]) {
[w, h] = videoRequest.playerSize;
}

impression.video = {
pos: nullish(videoRequest.pos, 0),
topframe: utils.inIframe() ? 0 : 1,
Expand All @@ -105,8 +112,8 @@ export const sharethroughAdapterSpec = {
api: getVideoApi(videoRequest),
mimes: videoRequest.mimes || ['video/mp4'],
protocols: getVideoProtocols(videoRequest),
w: videoRequest.playerSize[0] || 640,
h: videoRequest.playerSize[1] || 360,
w,
h,
startdelay: nullish(videoRequest.startdelay, 0),
skipmin: nullish(videoRequest.skipmin, 0),
skipafter: nullish(videoRequest.skipafter, 0),
Expand Down
3 changes: 3 additions & 0 deletions test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ describe('sharethrough adapter spec', function() {
delete bidRequests[1].mediaTypes.video.api;
delete bidRequests[1].mediaTypes.video.mimes;
delete bidRequests[1].mediaTypes.video.protocols;
delete bidRequests[1].mediaTypes.video.playerSize;
delete bidRequests[1].mediaTypes.video.startdelay;
delete bidRequests[1].mediaTypes.video.skipmin;
delete bidRequests[1].mediaTypes.video.skipafter;
Expand All @@ -410,6 +411,8 @@ describe('sharethrough adapter spec', function() {
expect(videoImp.api).to.deep.equal([2]);
expect(videoImp.mimes).to.deep.equal(['video/mp4']);
expect(videoImp.protocols).to.deep.equal([2, 3, 5, 6, 7, 8]);
expect(videoImp.w).to.equal(640);
expect(videoImp.h).to.equal(360);
expect(videoImp.startdelay).to.equal(0);
expect(videoImp.skipmin).to.equal(0);
expect(videoImp.skipafter).to.equal(0);
Expand Down

0 comments on commit 3c5c4fc

Please sign in to comment.