Skip to content

Commit

Permalink
[Video Module] Bugfix: Allow publishers to override video params (pre…
Browse files Browse the repository at this point in the history
…bid#9611)

* allows publisher to override video params

* passes proper config to ima
  • Loading branch information
karimMourra authored and jorgeluisrocha committed May 18, 2023
1 parent ba0eeb1 commit 9be7974
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
8 changes: 5 additions & 3 deletions modules/videoModule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ export function PbVideo(videoCore_, getConfig_, pbGlobal_, pbEvents_, videoEvent
return;
}

const video = Object.assign({}, adUnit.mediaTypes.video, ortbVideo);
const video = Object.assign({}, ortbVideo, adUnit.mediaTypes.video);

video.context = ortbVideo.placement === PLACEMENT.INSTREAM ? 'instream' : 'outstream';
if (!video.context) {
video.context = ortbVideo.placement === PLACEMENT.INSTREAM ? 'instream' : 'outstream';
}

const width = ortbVideo.w;
const height = ortbVideo.h;
if (width && height) {
if (!video.playerSize && width && height) {
video.playerSize = [width, height];
}

Expand Down
6 changes: 3 additions & 3 deletions modules/videojsVideoProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ https://github.com/Conviva/conviva-js-videojs/blob/master/conviva-videojs-module
const setupFailMessage = 'Failed to instantiate the player';
const AD_MANAGER_EVENTS = [AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY, AD_PAUSE, AD_TIME, AD_COMPLETE, AD_SKIPPED];

export function VideojsProvider(config, vjs_, adState_, timeState_, callbackStorage_, utils) {
export function VideojsProvider(providerConfig, vjs_, adState_, timeState_, callbackStorage_, utils) {
let vjs = vjs_;
// Supplied callbacks are typically wrapped by handlers
// we use this dict to keep track of these pairings
Expand All @@ -46,7 +46,7 @@ export function VideojsProvider(config, vjs_, adState_, timeState_, callbackStor
let player = null;
let playerVersion = null;
let playerIsSetup = false;
const {playerConfig, divId} = config;
const {playerConfig, divId} = providerConfig;
let isMuted;
let previousLastTimePosition = 0;
let lastTimePosition = 0;
Expand Down Expand Up @@ -521,7 +521,7 @@ export function VideojsProvider(config, vjs_, adState_, timeState_, callbackStor
return;
}

const adConfig = utils.getAdConfig(config);
const adConfig = utils.getAdConfig(playerConfig);
player.ima(adConfig);
}

Expand Down
31 changes: 31 additions & 0 deletions test/spec/modules/videoModule/pbVideo_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,37 @@ describe('Prebid Video', function () {
expect(nextFn.calledOnce).to.be.true;
expect(nextFn.getCall(0).args[0].ortb2).to.be.deep.equal({ site: { content: { test: 'contentTestValue' } } });
});

it('allows publishers to override video param', function () {
const getOrtbVideoSpy = videoCoreMock.getOrtbVideo = sinon.spy(() => ({
test: 'videoTestValue',
test2: 'videoModuleValue'
}));

let beforeBidRequestCallback;
const requestBids = {
before: callback_ => beforeBidRequestCallback = callback_
};

pbVideoFactory(null, null, Object.assign({}, pbGlobalMock, { requestBids }));
expect(beforeBidRequestCallback).to.not.be.undefined;
const nextFn = sinon.spy();
const adUnits = [{
code: 'ad1',
mediaTypes: {
video: {
test2: 'publisherValue'
}
},
video: { divId: 'divId' }
}];
beforeBidRequestCallback(nextFn, { adUnits });
expect(getOrtbVideoSpy.calledOnce).to.be.true;
const adUnit = adUnits[0];
expect(adUnit.mediaTypes.video).to.have.property('test', 'videoTestValue');
expect(adUnit.mediaTypes.video).to.have.property('test2', 'publisherValue');
expect(nextFn.calledOnce).to.be.true;
});
});

describe('Ad tag injection', function () {
Expand Down

0 comments on commit 9be7974

Please sign in to comment.