A free and open source library for publishers to quickly implement a plugin for a videoJS player, such as Brightcove Player. This plugin may be used to invoke prebid.js to execute the prebidding process. It may also be used to render the "selected" video ad within the player.
This README is for developers who want to use and/or contribute to bc_prebid_vast. Additional documentation can be found at the Brightcove Prebid Plugin homepage. Sample integrations can be found under "Samples" in the "Brightcove Plugin" section of Prebid.js External Plugins. Table of Contents
A successful deployment of this plugin includes not only a build of two plugin components but also builds of other components that are provided in this repository and a companion repository. The “plugin” itself is actually made up of two components:
When registering the plugin, either on the page or in Brightcove Studio, you should use the URL to the plugin loader. The loader will automatically know how to load the main plugin script, either from the default location or using a custom path.
The other components partners include:
Ad Renderer - By default this plugin uses one of the following renderers to render the video ad depending on plugin configuration options passed into the plugin at run-time:
Alternatively, you may also partner the Prebid plugin with your own rendering code. Details about how to do this is provided below under Build and Run a Project Locally.
MailOnline CSS - If you are using the MailOnline rendering plugin, you also need to load the CSS file associated with the MailOnline plugin. This CSS file is provided in the companion MailOnline repository mentioned above at the following location: ./videojs-mailonline-plugin/bin/bc_vpaid_vast_mo.css
.
Prebid Plugin CSS - This Prebid plugin also supplies an additional CSS file that must be loaded along with this plugin. This CSS file is located in this repository at: ./prebid-js-plugin-brightcove/src/bc_prebid_vast_vjs.css
.
Markers Plugin - This plugin incorporates code from the Markers plugin: https://github.com/spchuang/videojs-markers/
.
./prebid-js-plugin-brightcove/src/MarkersHandler.js
.$ git clone https://github.com/prebid/prebid-js-plugin-brightcove.git
$ cd prebid-js-plugin-brightcove
$ npm install
Note: You need to have NodeJS
6.x or greater installed.
To build the project on your local machine, run:
$ gulp
or
$ gulp build
This runs some code quality checks and generates the following files:
./dist/bc_prebid_vast.min.js
- Minified production code of the loader./dist/bc_prebid_vast.js
- Non-minified production code of the loader./dist/bc_prebid_vast_plugin.min.js
- Minified production code of the main plugin./dist/bc_prebid_vast_plugin.js
- Non-minified production code of the main plugin./dist/styles/bc_prebid_vast_vjs.css
- Non-minified CSS plugin fileTo run the unit tests:
gulp test
To generate and view the code coverage reports:
gulp ci-test
Steps:
To build and run this project locally, if you are planning on using an AppNexus bidder you must first modify your host file to setup an alias for local.prebid. Otherwise, your "localhost" domain may become blacklisted by AppNexus.
Add the following line to your host file:
127.0.0.1 local.appnexus
You can either create your own custom build of the MailOnline plugin or you can replace the MailOnline plugin with your own ad rendering code.
If you have either created your own build of the MailOnline plugin or are replacing the MailOnline plugin with your own rendering code, you will need to modify the path that the plugin uses to load the rendering plugin.
./src/BcPrebidVast.js>loadMolPlugin(callback)
./src/VastRenderer.js>playAd(xml)
If you are replacing the MailOnline rendering plugin with your own custom rendering code, you need to change the code where currently an ad renderer is loaded and invoked.
adRenderer
parameter to your cofiguration object with this value: adRenderer: "custom"
../src/BcPrebidVast.js
../src/BcPrebidVast.js>loadMolPlugin(callback)
./src/BcPrebidVast.js>loadImaPlugin(callback)
./src/VastManager.js>play(...)
and ./src/AdListManager.js>playAd(...)
./src/VastManager.js
and also between your renderer and ./src/AdListManager.js
so that ad playback is synchronized with the playing of the main content in the Brightcove Player. Currently, the VastManager
and AdListManager
are using the following events to manage this synchronization:
vast.adStart
vast.adError
vast.adsCancel
vast.adSkip
vast.reset
vast.contentEnd
adFinished
Build and run the project locally with:
gulp dev-server
This builds the plugin and starts a web server at http://local.prebid:8082
serving from the project root.
There are several test pages provided with the plugin that use the plugin in a variety of ways. These test pages are provided in the repository at: ./tests/e2e/testPages/
You may select whichever style you want to test. See http://prebid.org/dev-docs/plugins/brightcove-prebid-plugin/BC-Prebid-Plugin-Options.html
for details on all the options that can be passed to the plugin.
prebid-main.html
prebid-header.html
prebid-body.html
prebid-studio-config.html
Before testing, you may need to make the following changes to your selected test page:
test_player
. If you have changed the id elsewhere in your code, the id of the player must match the player id that you are passing to doPrebid()
in the plugin.As an example, to run the prebid-body.html test page, go to:
http://local.prebid:8082/prebid-body.html
As you make code changes, the bundles will be rebuilt but you must refresh the page to test the new code.
When you are ready to deploy your build of this plugin, you need to make sure that all the paths are set up correctly. Depending on how you are integrating the plugin with your player, the paths can be defined:
Make sure the following paths are correct:
SSPs and publishers may contribute to this project.
For guidelines, see Contributing.
Our PR review process can be found here.
Code quality is defined by .eslintrc
and errors are reported in the terminal.
If you are contributing code, you should configure your editor with the provided .eslintrc
settings.
$ gulp test
This will run the tests. To keep the Karma test browser open, you need to modify karma.conf.js
to set singleRun
to false
.
http://localhost:9876/debug.html
.Detailed code coverage reporting can be generated explicitly with
$ gulp ci-test
The results will be in
./coverage
bc_prebid_vast is supported on Internet Explorer 11+ and modern browsers.
Review our governance model here.