VAST 2.0 support within Flowplayer 6 HTML
Note: This project is a work in progress and may not fulfill all of the VAST 2.0 spec yet.
- Create a flowplayer instance like you normally would (make sure you use the playlist feature).
- Invoke the attach method to start the vast loading process.
- The player will will until the vast load has completed (or failed) and rewrite the playlist.
- Only the first video returned in the VAST response is used.
- If the creative is of type "application/javascript" the playlist is left as is and the event vpaid_js is invoked on the player object.
- The player will be locked until the ad has been viewed then removed from the playlist.
This plugin requires that you use the flowplayer playlist functionality.
var vast = require('flowplayer-vast');
var container = document.getElementById('div');
var player = flowplayer(container, {
playlist: [],
wmode: 'transparent' // support onclick event for IE for ad clicks
});
vast.init(container, player, 'http://serer.com/vast.xml');
var vast = require('flowplayer-vast');
var container = document.getElementById('div');
var playlist = [];
vast.loadPreroll(container, 'http://serer.com/vast.xml', function(preroll){
if (preroll && preroll.video) {
playlist.unshift(preroll.video);
}
var player = flowplayer(container, {
playlist: playlist,
wmode: 'transparent' // support onclick event for IE for ad clicks
});
if (preroll) {
vast.attachEvents(container, player);
// if you have the flowplayer-vpaid plugin setup
if (preroll.swf) {
return player.trigger('vpaid_swf', [preroll.swf]);
}
if (preroll.js) {
return player.trigger('vpaid_js', [preroll.js]);
}
}
});
To support vpaid responses for javascript, you can either use the flowplayer-vpaid project or implement your own like so:
player.on('vpaid_js', function (e, config) {
// configure vpaid environment
});
- 1.1.10: Fix for skipping in Flowplayer 7
- 1.1.9: Only attach event if element exists
- 1.1.8: Always disable (if player is auto paused/resume, ads will be skippable)
- 1.1.7: Fix when there is no title
- 1.1.6: Fix from last change
- 1.1.5: Allow pausing and volume changing of ads
- 1.1.4: Fixes issue on iPad where user is unable to play after clicking ad
- 1.1.3: Ability to keep preroll in rotation
- 1.1.2: Timeout for loading vast URL and chrome bug
- 1.1.0: More granular API, edge case fixes across device
- 1.0.4: Only mark complete if it has not been skipped
- 1.0.3: Bug fix
- 1.0.2: Fixed for vpaid js ads
- 1.0.1: Moved to browserify
- 1.0.0: Initial release