Video.js Advertisement Scheduler

A linear advertisement schedule plugin for Video.js 4.x and 5.x. With ad scheduler, the Video.js player can accept VMAP v1.0.1 schedule document while content playing, enables player to play preroll, midroll, and postroll inline advertisements.

Since this project is still under development, functions will change frequencies without notice.

Getting Started

Before use plugin works with exist Video.js enabled page, you'll need external VAST&VMAP parser for advertisement document information extraction. Here recommended to use vast-client-js from Dailymotion, and vmap-client-js created by me. This plugin also requires videojs-contrib-ads plugin has installed.

Once you've added the plugin script to your page, you can use it with any video:

<script src="video.js"></script>
<script src="vast-client.js"></script>
<script src="vmap-client.js"></script>
<script src="Video.js.ads.js"></script>
<script src="videojs-ad-scheduler.js"></script>
<script>
  var options = {
    plugins: {
      // You don't need to manually enable ads plugin, 
      // the ad scheduler will do the same work for you.
      ottAdScheduler: {
        serverUrl: '(Your VMAP advertisement access URL)'  // One of the usage
      }
    }
  };
  videojs(document.querySelector('video'), options, null).ready(function() {
    this.src([{src:"(Your main video content)", type:"video/mp4"}]);
    // Another usage to load VMAP document.
    this.ottAdScheduler.requestUrl('(Your VMAP advertisement access URL)'); 
    this.play();
  });
</script>

You can also use regular video.js src function to assign media content. Once video played, Video.js will schedule ad breaks and play ads described in VMAP/VAST documents.

Please see the working example of the plugin you can check out if you're having trouble.

Documentation

Plugin Options

You need a pass in an options object to the plugin upon initialization. This object may contain any of the following properties:

requestUrl (Required)

Type: String Default: ""

Setup VMAP requests URL, which will use in the content video.

allowSkip (Optional)

Type: Boolean Default: True

Allow user skip each ad content. This option will NOT override ad break instructions defined in the VAST document if ad document setup is not skippable.

skipTime (Optional)

Type: Integer Default: 5 (Seconds)

Allow user skip each ad content after ad content is played over specified seconds. This option will NOT override ad break instructions defined in the VAST document if ad document setup is not skippable.

startOffset (Optional)

Type: Integer Default: 0 (Seconds)

Allow player resume playback from given time offset, the value must be in seconds. This startOffset function must call before loading actual content, otherwise, the player offset may not operate corrected.

resumeSkipMidroll (Optional)

Type: Boolean Default: false

Allow control player to skip midrolls that setup before given startOffset. Preroll advertisements will not affect by this setting. This resumeSkipMidroll function must call before loading VMAP or will still not skip midroll ads.

Methods

This plugin added options as same name methods, let the user be able to change options in ad scheduler runtime. Once you retrieve the player runtime, use player.ottAdScheduler namespace to access them.

    player.ottAdScheduler.requestUrl();       // Get current VMAP request URL
    player.ottAdScheduler.requestUrl(foo);    // Setup VMAP request URL as foo

Development

Requirement

Steps

  1. checkout project or download zip file.
  2. cd into extracted folder.
  3. Setup environment: npm install && bower install
  4. Build dependency libraries grunt mkdir && grunt shell
  5. Build distrubited version if scheduler: grunt
  6. Run demo locally: grunt serve

Release History

Author

Stevennick Ciou