From c8cd17457b294e29a4b48bcbb1be6cf2fe0a56a6 Mon Sep 17 00:00:00 2001 From: AnirudhRahul Date: Wed, 5 Jan 2022 03:41:48 -0500 Subject: [PATCH 1/5] Added draft for videojs integration example --- .../videoModule/{ => video-test}/index.html | 0 .../videoModule/videojsAdapter/index.html | 127 ++++++++++++++++++ 2 files changed, 127 insertions(+) rename integrationExamples/videoModule/{ => video-test}/index.html (100%) create mode 100644 integrationExamples/videoModule/videojsAdapter/index.html diff --git a/integrationExamples/videoModule/index.html b/integrationExamples/videoModule/video-test/index.html similarity index 100% rename from integrationExamples/videoModule/index.html rename to integrationExamples/videoModule/video-test/index.html diff --git a/integrationExamples/videoModule/videojsAdapter/index.html b/integrationExamples/videoModule/videojsAdapter/index.html new file mode 100644 index 00000000000..0e46754aeb7 --- /dev/null +++ b/integrationExamples/videoModule/videojsAdapter/index.html @@ -0,0 +1,127 @@ + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1 existing Player
+
+ +
+
Div-2 controlled Player
+
+ + + + + + + + From e75c3105f2b7667a498b51236ad8be0b75b484d5 Mon Sep 17 00:00:00 2001 From: AnirudhRahul Date: Wed, 5 Jan 2022 11:01:27 -0500 Subject: [PATCH 2/5] Moved jwplayer integration example, added draft for videojs example --- .../index.html | 8 +- .../videoModule/videojsAdapter/index.html | 123 ++++++++---------- 2 files changed, 56 insertions(+), 75 deletions(-) rename integrationExamples/videoModule/{video-test => jwplayerAdapter}/index.html (96%) diff --git a/integrationExamples/videoModule/video-test/index.html b/integrationExamples/videoModule/jwplayerAdapter/index.html similarity index 96% rename from integrationExamples/videoModule/video-test/index.html rename to integrationExamples/videoModule/jwplayerAdapter/index.html index 3deb6689263..54aea6995cd 100644 --- a/integrationExamples/videoModule/video-test/index.html +++ b/integrationExamples/videoModule/jwplayerAdapter/index.html @@ -1,11 +1,11 @@ - - + + + - + }] + } + }); + pbjs.requestBids(); + }); + + + -

Prebid.js Test

+

VideoJS Adapter Test

+
Div-1 existing Player
- + +
+ +
Div-2 existing player without automatic setup
+
+ + +
-
Div-2 controlled Player
-
+
Div-3 controlled Player
+
- + + From c2d94a46625550b2cabf14f27af8de67e0a9bd05 Mon Sep 17 00:00:00 2001 From: AnirudhRahul Date: Wed, 5 Jan 2022 15:44:35 -0500 Subject: [PATCH 3/5] Added call to video adapter --- modules/videoModule/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/videoModule/index.js b/modules/videoModule/index.js index bd249a1586d..e43797ca348 100644 --- a/modules/videoModule/index.js +++ b/modules/videoModule/index.js @@ -139,3 +139,5 @@ export function pbVideoFactory() { pbVideo.init(); return pbVideo; } + +pbVideoFactory(); \ No newline at end of file From 3fcdc7c4a01cf296d36aebe5e998ee396d0b5bb1 Mon Sep 17 00:00:00 2001 From: AnirudhRahul Date: Wed, 5 Jan 2022 17:25:44 -0500 Subject: [PATCH 4/5] Created integration example for a mocked videojs adapter --- .../videoModule/jwplayerAdapter/index.html | 3 +- .../videoModule/videojsAdapter/index.html | 71 +++++----- modules/.submodules.json | 3 +- modules/videojsVideoProvider.js | 131 ++++++++++++++++++ 4 files changed, 168 insertions(+), 40 deletions(-) create mode 100644 modules/videojsVideoProvider.js diff --git a/integrationExamples/videoModule/jwplayerAdapter/index.html b/integrationExamples/videoModule/jwplayerAdapter/index.html index 54aea6995cd..3e0b178c4a7 100644 --- a/integrationExamples/videoModule/jwplayerAdapter/index.html +++ b/integrationExamples/videoModule/jwplayerAdapter/index.html @@ -42,8 +42,7 @@ var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; - - - - - - + }); + pbjs.requestBids(); + }); + @@ -83,14 +80,14 @@

VideoJS Adapter Test

Div-1 existing Player
-
Div-2 existing player without automatic setup
- +
diff --git a/modules/.submodules.json b/modules/.submodules.json index c4d279e771a..30800257784 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -55,6 +55,7 @@ ], "videoModule": [ "coreVideo", - "jwplayerVideoProvider" + "jwplayerVideoProvider", + "videojsVideoProvider" ] } diff --git a/modules/videojsVideoProvider.js b/modules/videojsVideoProvider.js new file mode 100644 index 00000000000..26b2956a7e3 --- /dev/null +++ b/modules/videojsVideoProvider.js @@ -0,0 +1,131 @@ +import { + PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE +} from './videoModule/constants/ortb.js'; +import { + SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY, + AD_TIME, AD_PAUSE, AD_CLICK, AD_SKIPPED, AD_ERROR, AD_COMPLETE, AD_BREAK_END, PLAYLIST, PLAYBACK_REQUEST, + AUTOSTART_BLOCKED, PLAY_ATTEMPT_FAILED, CONTENT_LOADED, PLAY, PAUSE, BUFFER, TIME, SEEK_START, SEEK_END, MUTE, VOLUME, + RENDITION_UPDATE, ERROR, COMPLETE, PLAYLIST_COMPLETE, FULLSCREEN, PLAYER_RESIZE, VIEWABLE, CAST, PLAYBACK_MODE +} from './videoModule/constants/events.js'; +import stateFactory from './videoModule/shared/state.js'; +import { adStateFactory, timeStateFactory, callbackStorageFactory} from './jwplayerVideoProvider.js'; + +export function VideojsProvider(config, videojs_, adState_, timeState_, callbackStorage_, utils) { + let videojs = videojs_; + let player = null; + let playerVersion = null; + const {playerConfig, divId} = config; + + let adState = adState_; + let timeState = timeState_; + let callbackStorage = callbackStorage_; + let minimumSupportedPlayerVersion = 'v7.17.0'; + + + function init() { + console.log("Initialized videojs provider") + + if (!videojs) { + triggerSetupFailure(-1); // TODO: come up with code for player absent + return; + } + + // playerVersion = videojs.version; + + // if (playerVersion < minimumSupportedPlayerVersion) { + // triggerSetupFailure(-2); // TODO: come up with code for version not supported + // return; + // } + + // player = videojs(divId); + // if (player.getState() === undefined) { + // setupPlayer(playerConfig); + // } else { + // setupCompleteCallback && setupCompleteCallback(SETUP_COMPLETE, getSetupCompletePayload()); + // } + } + + function getId() { + return divId; + } + + function getOrtbParams() { + console.log("Requested ortb params") + // if (!player) { + // return; + // } + // const config = player.getConfig(); + // const adConfig = config.advertising || {}; + supportedMediaTypes = supportedMediaTypes || utils.getSupportedMediaTypes(MEDIA_TYPES); + + const video = { + mimes: [], + w: 0, + h: 0, + }; + + const content = { + id: item.mediaid, + url: item.file, + title: item.title, + cat: item.iabCategories, + keywords: item.tags, + len: duration, + }; + + return { + video, + content + } + } + + function setAdTagUrl(adTagUrl, options) { + console.log("Set ad tag url:", adTagUrl) + // if (!player) { + // return; + // } + // player.playAd(adTagUrl || options.adXml, options); + } + + function onEvents(events, callback) { + console.log("Added callback for", events) + } + + function offEvents(events, callback) { + console.log("Removed callback for", events) + + } + + function destroy() { + console.log("Destroying player") + if (!player) { + return; + } + player.remove(); + player = null; + } + + return { + init, + getId, + getOrtbParams, + setAdTagUrl, + onEvents, + offEvents, + destroy + }; +} + +import { VIDEO_JS_VENDOR } from './videoModule/constants/vendorCodes.js'; +import { videoVendorDirectory } from './videoModule/vendorDirectory.js'; + +const videojsSubmoduleFactory = function (config) { + const adState = adStateFactory(); + const timeState = timeStateFactory(); + const callbackStorage = callbackStorageFactory(); + return VideojsProvider(config, null, adState, timeState, callbackStorage, {}); +} +videojsSubmoduleFactory.vendorCode = VIDEO_JS_VENDOR; + +videoVendorDirectory[VIDEO_JS_VENDOR] = videojsSubmoduleFactory; +export default videojsSubmoduleFactory; \ No newline at end of file From 0ea1795d39faa36ce2bfa487d9387ff73d17f5b1 Mon Sep 17 00:00:00 2001 From: AnirudhRahul Date: Wed, 5 Jan 2022 18:58:45 -0500 Subject: [PATCH 5/5] Fixed call order for integration examples, moved imports up --- integrationExamples/videoModule/jwplayerAdapter/index.html | 2 +- integrationExamples/videoModule/videojsAdapter/index.html | 2 +- modules/videojsVideoProvider.js | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/integrationExamples/videoModule/jwplayerAdapter/index.html b/integrationExamples/videoModule/jwplayerAdapter/index.html index 3e0b178c4a7..12e3d9e363d 100644 --- a/integrationExamples/videoModule/jwplayerAdapter/index.html +++ b/integrationExamples/videoModule/jwplayerAdapter/index.html @@ -47,7 +47,6 @@ pbjs.onEvent('adImpression', event => { console.log('adImpression: ', event); }); - pbjs.addAdUnits(adUnits); pbjs.setConfig({ video: { providers: [{ @@ -96,6 +95,7 @@ }] } }); + pbjs.addAdUnits(adUnits); pbjs.requestBids(); }); diff --git a/integrationExamples/videoModule/videojsAdapter/index.html b/integrationExamples/videoModule/videojsAdapter/index.html index 70eba4ecbc3..a5c07dc4302 100644 --- a/integrationExamples/videoModule/videojsAdapter/index.html +++ b/integrationExamples/videoModule/videojsAdapter/index.html @@ -44,7 +44,6 @@ pbjs.onEvent('adImpression', event => { console.log('adImpression: ', event); }); - pbjs.addAdUnits(adUnits); pbjs.setConfig({ video: { providers: [{ @@ -70,6 +69,7 @@ },] } }); + pbjs.addAdUnits(adUnits); pbjs.requestBids(); }); diff --git a/modules/videojsVideoProvider.js b/modules/videojsVideoProvider.js index 26b2956a7e3..8afa2910be1 100644 --- a/modules/videojsVideoProvider.js +++ b/modules/videojsVideoProvider.js @@ -9,6 +9,8 @@ import { } from './videoModule/constants/events.js'; import stateFactory from './videoModule/shared/state.js'; import { adStateFactory, timeStateFactory, callbackStorageFactory} from './jwplayerVideoProvider.js'; +import { VIDEO_JS_VENDOR } from './videoModule/constants/vendorCodes.js'; +import { videoVendorDirectory } from './videoModule/vendorDirectory.js'; export function VideojsProvider(config, videojs_, adState_, timeState_, callbackStorage_, utils) { let videojs = videojs_; @@ -116,8 +118,7 @@ export function VideojsProvider(config, videojs_, adState_, timeState_, callback }; } -import { VIDEO_JS_VENDOR } from './videoModule/constants/vendorCodes.js'; -import { videoVendorDirectory } from './videoModule/vendorDirectory.js'; + const videojsSubmoduleFactory = function (config) { const adState = adStateFactory();