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

smartxBidAdapter: new Feature - Made Out-Stream Player configurable #6239

Merged
merged 11 commits into from
Feb 4, 2021
50 changes: 42 additions & 8 deletions modules/smartxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,49 @@ export const spec = {
}

function createOutstreamScript(bid) {
// const slot = utils.getBidIdParameter('slot', bid.renderer.config.outstream_options);
// for SmartPlay 4.12
function scPrebidClose(ele, completeCollapsed) {
if (completeCollapsed) {
document.getElementById(ele.id).style.display = 'none';
}
}

const confMinAdWidth = utils.getBidIdParameter('minAdWidth', bid.renderer.config.outstream_options) || 290;
const confMaxAdWidth = utils.getBidIdParameter('maxAdWidth', bid.renderer.config.outstream_options) || 900;
const confStartOpen = utils.getBidIdParameter('startOpen', bid.renderer.config.outstream_options) || 'false';
const confEndingScreen = utils.getBidIdParameter('endingScreen', bid.renderer.config.outstream_options) || 'true';
const confHeaderText = utils.getBidIdParameter('headerText', bid.renderer.config.outstream_options) || '';
const confSkipOffset = utils.getBidIdParameter('skipOffset', bid.renderer.config.outstream_options) || 0;
const confDesiredBitrate = utils.getBidIdParameter('desiredBitrate', bid.renderer.config.outstream_options) || 1600;
const elementId = utils.getBidIdParameter('slot', bid.renderer.config.outstream_options) || bid.adUnitCode;

// for SmartPlay 4.12
let initCollapsed = true;
let completeCollapsed = true;
if (confStartOpen === 'true') {
initCollapsed = false;
}
if (confEndingScreen === 'true') {
completeCollapsed = false;
}

utils.logMessage('[SMARTX][renderer] Handle SmartX outstream renderer');
const elementId = bid.adUnitCode;

let smartPlayObj = {
minAdWidth: 290,
maxAdWidth: 900,
elementLocator: {
allowInViewport: false,
minimumElementWidth: 290,
scanPixelsBelowViewport: 800
minAdWidth: confMinAdWidth,
maxAdWidth: confMaxAdWidth,
headerText: confHeaderText,
skipOffset: confSkipOffset,
behaviourMatrix: {
init: {
'collapsed': initCollapsed
},
complete: {
'collapsed': completeCollapsed
}
},
environmentVars: {
desiredBitrate: confDesiredBitrate,
},
onStartCallback: function (m, n) {
try {
Expand All @@ -351,6 +384,7 @@ function createOutstreamScript(bid) {
},
onEndCallback: function (m, n) {
try {
scPrebidClose(n, completeCollapsed); // for SmartPlay 4.12
window.sc_smartIntxtEnd(n);
} catch (f) {}
},
Expand Down
34 changes: 24 additions & 10 deletions modules/smartxBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ This adapter requires setup and approval from the smartclip team.
publisherId: '11986',
siteId: '22860',
bidfloor: 0.3,
bidfloorcur: "EUR",
bidfloorcur: 'EUR',
at: 2,
cur: ["EUR"],
cur: ['EUR'],
outstream_options: {
slot: 'video1'
slot: 'video1',
minAdWidth: 290,
maxAdWidth: 900,
headerText: '',
skipOffset: 0,
startOpen: 'true',
endingScreen: 'true',
desiredBitrate: 1600,
},
}
}],
Expand All @@ -57,11 +64,18 @@ This adapter requires setup and approval from the smartclip team.
publisherId: '11986',
siteId: '22860',
bidfloor: 0.3,
bidfloorcur: "EUR",
bidfloorcur: 'EUR',
at: 2,
cur: ["EUR"],
cur: ['EUR'],
outstream_options: {
slot: 'video1'
slot: 'video1',
minAdWidth: 290,
maxAdWidth: 900,
headerText: '',
skipOffset: 0,
startOpen: 'true',
endingScreen: 'true',
desiredBitrate: 1600,
},
user: {
data: [{
Expand Down Expand Up @@ -104,9 +118,9 @@ This adapter requires setup and approval from the smartclip team.
publisherId: '11986',
siteId: '22860',
bidfloor: 0.3,
bidfloorcur: "EUR",
bidfloorcur: 'EUR',
at: 2,
cur: ["EUR"]
cur: ['EUR']
}
}],
}];
Expand All @@ -129,9 +143,9 @@ This adapter requires setup and approval from the smartclip team.
publisherId: '11986',
siteId: '22860',
bidfloor: 0.3,
bidfloorcur: "EUR",
bidfloorcur: 'EUR',
at: 2,
cur: ["EUR"],
cur: ['EUR'],
user: {
data: [{
id: 'emq',
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/smartxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ describe('The smartx adapter', function () {
};
});

it('should attempt to insert the EASI script', function () {
it('should attempt to insert the script', function () {
var scriptTag;
sinon.stub(window.document, 'getElementById').returns({
appendChild: sinon.stub().callsFake(function (script) {
Expand Down