diff --git a/modules/smartxBidAdapter.js b/modules/smartxBidAdapter.js index 5b36e17be11..f3188c1f110 100644 --- a/modules/smartxBidAdapter.js +++ b/modules/smartxBidAdapter.js @@ -303,7 +303,7 @@ export const spec = { const playersize = deepAccess(currentBidRequest, 'mediaTypes.video.playerSize'); const renderer = Renderer.install({ id: 0, - url: 'https://dco.smartclip.net/?plc=7777778', + url: 'https://dco.smartclip.net/?plc=7777779', config: { adText: 'SmartX Outstream Video Ad via Prebid.js', player_width: playersize[0][0], @@ -353,65 +353,73 @@ function createOutstreamConfig(bid) { logMessage('[SMARTX][renderer] Handle SmartX outstream renderer'); - var smartPlayObj = { + var playerConfig = { minAdWidth: confMinAdWidth, maxAdWidth: confMaxAdWidth, - onStartCallback: function (m, n) { + coreSetup: {}, + layoutSettings: {}, + onCappedCallback: function() { try { - window.sc_smartIntxtStart(n); - } catch (f) {} - }, - onCappedCallback: function (m, n) { - try { - window.sc_smartIntxtNoad(n); - } catch (f) {} - }, - onEndCallback: function (m, n) { - try { - window.sc_smartIntxtEnd(n); + window.sc_smartIntxtNoad(); } catch (f) {} }, }; if (confStartOpen == 'true') { - smartPlayObj.startOpen = true; + playerConfig.startOpen = true; } else if (confStartOpen == 'false') { - smartPlayObj.startOpen = false; + playerConfig.startOpen = false; } if (confEndingScreen == 'true') { - smartPlayObj.endingScreen = true; + playerConfig.endingScreen = true; } else if (confEndingScreen == 'false') { - smartPlayObj.endingScreen = false; + playerConfig.endingScreen = false; } if (confTitle || (typeof bid.renderer.config.outstream_options.title == 'string' && bid.renderer.config.outstream_options.title == '')) { - smartPlayObj.title = confTitle; + playerConfig.layoutSettings.advertisingLabel = confTitle; } if (confSkipOffset) { - smartPlayObj.skipOffset = confSkipOffset; + playerConfig.coreSetup.skipOffset = confSkipOffset; } if (confDesiredBitrate) { - smartPlayObj.desiredBitrate = confDesiredBitrate; + playerConfig.coreSetup.desiredBitrate = confDesiredBitrate; } if (confVisibilityThreshold) { - smartPlayObj.visibilityThreshold = confVisibilityThreshold; + playerConfig.visibilityThreshold = confVisibilityThreshold; } - smartPlayObj.adResponse = bid.vastContent; + playerConfig.adResponse = bid.vastContent; const divID = '[id="' + elementId + '"]'; + var playerListener = function callback(event) { + switch (event) { + case 'AdSlotStarted': + try { + window.sc_smartIntxtStart(); + } catch (f) {} + break; + + case 'AdSlotComplete': + try { + window.sc_smartIntxtEnd(); + } catch (f) {} + break; + } + }; + try { // eslint-disable-next-line - let _outstreamPlayer = new OutstreamPlayer(divID, smartPlayObj); + outstreamplayer.connect(divID).setup(playerConfig, playerListener) } catch (e) { logError('[SMARTX][renderer] Error caught: ' + e); } - return smartPlayObj; + return playerConfig; } /** diff --git a/test/spec/modules/smartxBidAdapter_spec.js b/test/spec/modules/smartxBidAdapter_spec.js index b7235eee878..58ce50efb8e 100644 --- a/test/spec/modules/smartxBidAdapter_spec.js +++ b/test/spec/modules/smartxBidAdapter_spec.js @@ -514,7 +514,7 @@ describe('The smartx adapter', function () { responses[0].renderer.render(responses[0]); - expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777778'); + expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777779'); window.document.getElementById.restore(); }); @@ -542,7 +542,7 @@ describe('The smartx adapter', function () { responses[0].renderer.render(responses[0]); - expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777778'); + expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777779'); window.document.getElementById.restore(); }); @@ -560,7 +560,7 @@ describe('The smartx adapter', function () { responses[0].renderer.render(responses[0]); - expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777778'); + expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777779'); window.document.getElementById.restore(); });