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

[Video Module] Bugfix: Allow publishers to override video params #9611

Merged
merged 2 commits into from
Mar 2, 2023
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
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