Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

AdPlayerPro Video Module : add PLCMT #12593

Merged
merged 2 commits into from
Dec 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
var adUnits = [{
code: 'div-gpt-ad-51545-0',
mediaTypes: {
video:{"context":"outstream"}
video: {context: 'outstream', playerSize: [640, 360]}
},
video: {
divId: 'player', // required to indicate which player is being used to render this ad unit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
var adUnits = [{
code: 'div-gpt-ad-51545-0',
mediaTypes: {
video:{"context":"outstream"}
video: {context: 'outstream', playerSize: [640, 360]}
},
video: {
divId: 'player', // required to indicate which player is being used to render this ad unit.
Expand Down
12 changes: 12 additions & 0 deletions modules/adplayerproVideoProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
API_FRAMEWORKS,
PLACEMENT,
PLAYBACK_METHODS,
PLCMT,
PROTOCOLS,
VIDEO_MIME_TYPE,
VPAID_MIME_TYPE
Expand Down Expand Up @@ -109,6 +110,7 @@ export function AdPlayerProProvider(config, adPlayerPro_, callbackStorage_, util
API_FRAMEWORKS.VPAID_2_0,
API_FRAMEWORKS.OMID_1_0
],
plcmt: utils.getPlcmt(playerConfig)
};

return video;
Expand Down Expand Up @@ -347,6 +349,16 @@ export const utils = {
return mute ? PLAYBACK_METHODS.AUTOPLAY_MUTED : PLAYBACK_METHODS.AUTOPLAY;
}
return PLAYBACK_METHODS.CLICK_TO_PLAY;
},

getPlcmt: function ({type, autoplay, muted, file}) {
type = type || 'inStream';
if (!file) {
// INTERSTITIAL: primary focus of the page and take up the majority of the viewport and cannot be scrolled out of view.
return type === 'rewarded' || type === 'inView' ? PLCMT.INTERSTITIAL : PLCMT.OUTSTREAM;
}
// INSTREAM must be set to “sound on” by default at player start
return type === 'inStream' && (!muted || !autoplay) ? PLCMT.INSTREAM : PLCMT.ACCOMPANYING_CONTENT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import sinon from 'sinon';
const {AdPlayerProProvider, utils} = require('modules/adplayerproVideoProvider.js');

const {
PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, VPAID_MIME_TYPE
PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, VPAID_MIME_TYPE, PLCMT
} = require('libraries/video/constants/ortb.js');

function getPlayerMock() {
Expand Down Expand Up @@ -66,6 +66,8 @@ function getUtilsMock() {
getPlacement: function () {
},
getPlaybackMethod: function () {
},
getPlcmt: function () {
}
};
}
Expand Down Expand Up @@ -218,10 +220,12 @@ describe('AdPlayerProProvider', function () {
const test_media_type = VIDEO_MIME_TYPE.MP4;
const test_placement = PLACEMENT.ARTICLE;
const test_playback_method = PLAYBACK_METHODS.CLICK_TO_PLAY;
const test_plcmt = PLCMT.OUTSTREAM;

utilsMock.getSupportedMediaTypes = () => [test_media_type];
utilsMock.getPlacement = () => test_placement;
utilsMock.getPlaybackMethod = () => test_playback_method;
utilsMock.getPlcmt = () => test_plcmt;

const provider = AdPlayerProProvider(config, null, null, utilsMock);
provider.init();
Expand All @@ -242,7 +246,8 @@ describe('AdPlayerProProvider', function () {
expect(video.playbackmethod).to.include(test_playback_method);
expect(video.playbackend).to.equal(1);
expect(video.api).to.have.length(2);
expect(video.api).to.include.members([API_FRAMEWORKS.VPAID_2_0, API_FRAMEWORKS.OMID_1_0]); //
expect(video.api).to.include.members([API_FRAMEWORKS.VPAID_2_0, API_FRAMEWORKS.OMID_1_0]);
expect(video.plcmt).to.equal(test_plcmt);
});
});

Expand Down Expand Up @@ -409,6 +414,22 @@ describe('AdPlayerProProvider utils', function () {
test(true, false, PLAYBACK_METHODS.AUTOPLAY);
test(true, true, PLAYBACK_METHODS.AUTOPLAY_MUTED);
});

it('getPlcmt', function () {
function test(type, autoplay, muted, file, expected) {
expect(utils.getPlcmt({type, autoplay, muted, file})).to.be.equal(expected);
}

test('inStream', false, false, 'f', PLCMT.INSTREAM);
test(undefined, false, false, 'f', PLCMT.INSTREAM);
test('inStream', false, true, 'f', PLCMT.INSTREAM);
test('inStream', true, false, 'f', PLCMT.INSTREAM);
test('inStream', true, true, 'f', PLCMT.ACCOMPANYING_CONTENT);

test('rewarded', true, false, undefined, PLCMT.INTERSTITIAL);
test('inView', true, false, undefined, PLCMT.INTERSTITIAL);
test('InPage', true, false, undefined, PLCMT.OUTSTREAM);
});
});

describe('AdPlayerProProvider callbackStorageFactory', function () {
Expand Down
Loading