README
vast-player
Vast-Player makes it easy to playback linear VAST creatives in the browser. It currently supports VPAID 1.0/2.0 (JavaScript and Flash) and HTML5 <MediaFile>
s. The library has the following responsibilites:
- Requesting VAST ad tags
- Resolving VAST wrapper tags
- Choosing a
<MediaFile>
based on the browser environment - Loading/initializing a
<MediaFile>
(including VPAID creatives) - Firing VAST tracking pixels/impressions at the correct time
- Opening VAST
<VideoClicks>
when appropriate
Example
<!DOCTYPE html>
<html>
<head>
<title>Vast-Player Example</title>
<script src="https://cdn.jsdelivr.net/npm/vast-player@latest/dist/vast-player.min.js"></script>
<style>
#container {
width: 640px; height: 385px;
position: relative;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
(function(VASTPlayer) {
'use strict';
var player = new VASTPlayer(document.getElementById('container'));
player.once('AdStopped', function() {
console.log('Ad finished playback!');
});
player.load(
'https://platform-staging.reelcontent.com/api/public/vast/2.0/tag?campaign=cam-e951792a909f17'
).then(function startAd() {
return player.startAd();
}).catch(function(reason) {
setTimeout(function() { throw reason; }, 0);
});
}(window.VASTPlayer));
</script>
</body>
</html>
Adding to Project
via npm (with browserify)
Install as a dependency