diff --git a/integrationExamples/videoModule/index.html b/integrationExamples/videoModule/jwplayerAdapter/index.html similarity index 96% rename from integrationExamples/videoModule/index.html rename to integrationExamples/videoModule/jwplayerAdapter/index.html index 3deb6689263..12e3d9e363d 100644 --- a/integrationExamples/videoModule/index.html +++ b/integrationExamples/videoModule/jwplayerAdapter/index.html @@ -1,11 +1,11 @@ - - + - @@ -109,5 +109,4 @@
Div-2
- - + \ No newline at end of file diff --git a/integrationExamples/videoModule/videojsAdapter/index.html b/integrationExamples/videoModule/videojsAdapter/index.html new file mode 100644 index 00000000000..a5c07dc4302 --- /dev/null +++ b/integrationExamples/videoModule/videojsAdapter/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + +

VideoJS Adapter Test

+ +
Div-1 existing Player
+
+ +
+ +
Div-2 existing player without automatic setup
+
+ + + +
+ +
Div-3 controlled Player
+
+ + + + + + + + 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/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 diff --git a/modules/videojsVideoProvider.js b/modules/videojsVideoProvider.js new file mode 100644 index 00000000000..8afa2910be1 --- /dev/null +++ b/modules/videojsVideoProvider.js @@ -0,0 +1,132 @@ +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'; +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_; + 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 + }; +} + + + +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