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.
This project is under development and will change frequencies without notice.
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="https://github.com/stevennick/videojs-ad-scheduler/raw/master/video.js"></script>
<script src="https://github.com/stevennick/videojs-ad-scheduler/raw/master/vast-client.js"></script>
<script src="https://github.com/stevennick/videojs-ad-scheduler/raw/master/vmap-client.js"></script>
<script src="https://github.com/stevennick/videojs-ad-scheduler/raw/master/videojs.ads.js"></script>
<script src="https://github.com/stevennick/videojs-ad-scheduler/raw/master/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. Select one of them to enable
// linear advertisement.
this.ottAdScheduler.requestUrl('(Your VMAP advertisement access URL)');
this.play();
});
</script>
You can also use the 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.
There's also a working example of the plugin you can check out if you're having trouble.
You need pass in an options object to the plugin upon initialization. This object may contain any of the following properties:
Type: String
Default: ""
Required
Setup VMAP requests URL, which will use in content video.
Type: Boolean
Default: True
Optional
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.
Type: Integer
Default: 5 (Seconds)
Optional
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.
Type: Integer
Default: 0 (Seconds)
Optional
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.
Type: Boolean
Default: false
Optional
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.
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.serverUrl(); // Get current VMAP request URL
player.ottAdScheduler.serverUrl(foo); // Setup VMAP request URL as foo
npm install && bower install
grunt mkdir && grunt shell
grunt
grunt serve
Stevennick Ciou
Copyright (c) 2015 Stevennick Ciou All rights reserved. Detialed license, please see the LICENSE file.