Git Product home page Git Product logo

vast-client-js's Introduction

npm version downloads per week license

VAST Client JS

Vast Client JS is a JavaScript library to fetch and parse Digital Video Ad Serving Template (VAST) documents.

This library provides three components:

  • A VAST Client to fetch and parse VAST XML resources into JavaScript Objects.
  • A VAST Parser to directly parse a VAST XML.
  • A VAST Tracker to batch and call tracking URLs.

For the full API documentation go here. For the full Class reference go here

To explore a practical example of how the vast client can be implemented, please visit this link.

Complies with the VAST 4.3 specification provided by the Interactive Advertising Bureau (IAB).

Get Started

VAST Client JS is available as an NPM package and can be easily installed with:

npm i @dailymotion/vast-client

Then import the components you need.

VASTClient

If you need to fetch and parse VAST documents, you can use the get method from the VASTClient:

import { VASTClient } from '@dailymotion/vast-client'

const vastClient = new VASTClient();

vastClient.get('https://www.examplevast.com/vast.xml')
  .then(parsedVAST => {
    // Do something with the parsed VAST response
  })
  .catch(err => {
    // Deal with the error
  });

In addition to fetching and parsing a VAST resource, VASTClient provides options to filter a sequence of calls based on count and time of execution, together with the possibility to track URLs using VASTTracker.

If you need to directly parse a VAST XML and also follow any wrappers chain, you can use the parseVAST method from the VASTClient :

import { VASTClient } from '@dailymotion/vast-client'

const vastClient = new VASTClient();

vastClient.parseVAST(vastXml)
  .then(parsedVAST => {
    // Do something with the parsed VAST response
  })
  .catch(err => {
    // Deal with the error
  });

VASTParser

To directly parse a VAST XML you can use the VASTParser: The VASTParser will make no fetching, the final response will only contain the first VAST encountered.

import { VASTParser } from '@dailymotion/vast-client'

const vastParser = new VASTParser();

vastParser.parseVAST(vastXml)
  .then(parsedVAST => {
    // Do something with the parsed VAST response
  })
  .catch(err => {
    // Deal with the error
  });

VASTTracker

To track the execution of an ad, create a VASTTracker instance and use the dedicated methods to calls VAST tracking elements.

import { VASTTracker } from '@dailymotion/vast-client'

const vastTracker = new VASTTracker(vastClient, ad, creative);

// Track an impression for the given ad. Will call any <Impression> URI from the <InLine> and <Wrapper> tracking elements.
vastTracker.trackImpression();

API Documentation

The API documentation is organized by components:

Changelog and migration guides can be found in the release notes.

Pre-bundled versions

We provide several pre-bundled versions of the client (see dist directory)

Bundlers

A version for js bundlers (like webpack or rollup) is available by default when adding the lib using a package manager (like npm or yarn): vast-client.js or vast-client.min.js [minified].

const import {
  VASTClient,
  VASTParser,
  VASTTracker
} from '@dailymotion/vast-client'

const vastClient = new VASTClient();
const vastParser = new VASTParser();
const vastTracker = new VASTTracker();

Browser script

A pre-bundled version of VAST Client JS is available: vast-client.min.js [minified].

To use it, either host it on your CDN or locally in your project. If you're using a script tag make sure to set the type property to module like below.

your index.html

<script type="module" src="your-main-file.js"></script>

main.js

import {VASTClient, VASTParser, VASTTracker} from "vast-client.min.js"

const vastClient = new VASTClient();
const vastParser = new VASTParser();
const vastTracker = new VASTTracker();

Node

A pre-bundled version for node is available too: vast-client-node.js or vast-client-node.min.js [minified].

// Method 1: From npm
const VAST = require('@dailymotion/vast-client')

// Method 2: For pre-bundled you must copy first the file inside your project
// then you will be able to require it without the need of npm
const VAST = require('your/path/vast-client-node.min.js')

const vastClient = new VAST.VASTClient();
const vastParser = new VAST.VASTParser();
const vastTracker = new VAST.VASTTracker();

Build / Contribute

See CONTRIBUTING

vast-client-js's People

Contributors

0ff avatar alkerway avatar briganti avatar clementfrancon avatar dependabot[bot] avatar dharfr avatar eliamaino-fp avatar florianorpeliere avatar guillaumebaechler avatar jakub-g avatar johansatge avatar klipstein avatar kobawan avatar lotphy avatar lupennat avatar mente avatar mpotra avatar mseeley avatar nhjm449 avatar paulinemdaily avatar rapha0511 avatar rgulrajani avatar rhumlover avatar rs avatar rs-guian avatar rumesh avatar shyamks avatar tlfyber avatar vvanghelue avatar zacharietfr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vast-client-js's Issues

Is VAST 2.0 supported?

Hi,

I'm testing this module with a VAST 2.0 url, but the method DMVAST.client.get it doesn't returns any object or error.
I've seen that there are some commits about VAST 2.0, so I was wondering if there's something wrong with what I'm doing.

The VAST url that was using is http://ads.us.e-planning.net/eb/4/1cb7f/Home/test_vast_vp1?o=v&ma=1&vv=2

Publish on NPM

Hey guys,

Mind publishing this on NPM? If you need PR or help let me know ok?

Thnx,

  • Steven

DMVAST usage example

Hello, and congruts for this tool!

I'm trying a create a player using the DMVAST client, but i can't clearly figure out how to use it
Are there any more analytical examples on this.

I am using the flow bellow:
i am requesting a vast code as bellow, parse the video URL, create a Vast tracker and then create a video element dynamically with the video url

	DMVAST.client.get('http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=is&c=23&pl=VAST&pli=14222276&PluID=0&pos=1901&ord=[timestamp]&cim=1', function(response, error)
		{
			// process the VAST response
			var VAST = response;
			var videoURL = response.ads["0"].creatives["0"].mediaFiles["0"].fileURL;


			// Create a VAST Tracker instance
			var vastTracker = new DMVAST.tracker(response.ads["0"], response.ads["0"].creatives["0"]);
		

			var content = document.getElementById("story_body");
			var video = document.createElement("video");
			video.controls = true;
			video.muted = true;
			video.src = videoURL;
			video.load();

After that, how do i call any tracking events? or they are fired automatically?
Also, Is it supposed to show the skip button automatically, or do i have to saw it manually, and how?

Wrapper URLs not called when passing in Response Document

I have a situation where I am passing in the response document and not passing a URL. When the response document has a <Wrapper> object, the <Wrapper>'s URL is not called, and instead the original document I passed in is re-used.

Suggested Fix is to not re-use the response object on subsequent calls for <Wrapper> objects.

Steps to Reproduce:

  • XML Document
<?xml version="1.0" encoding="UTF-8"?>
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vast.xsd" version="2.0">
   <Ad id="27209779">
      <Wrapper>
         <AdSystem version="1.0">adnxs</AdSystem>
         <VASTAdTagURI>http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=is&amp;c=23&amp;pl=VAST&amp;pli=12627946&amp;PluID=0&amp;pos=6644&amp;ord=[timestamp]&amp;cim=1</VASTAdTagURI>
         <Impression>http://ams1-ib.adnxs.com/it?e=wqT_3QLdAXTdAAAAAwDWAAUBCAAQABi7xP7klOiglHggACotCQANAQARDQgEABkRCQAhEQkAKREJ8JMwATgAQABIAFCz4PwMWABgAGgAeACAAQCYAQCgAQCoAQCwAQC4AQPAAQXIAQDQAQDYAQDgAQHwAQDYAgDgAgCAAwCIAwGQAwCYAwCgAwCqAwDAA6wCyAMA2AMA4AMA6AMA-AMAgAQAkgQDL2NymAQAqAQAsgQKCAAQABgAIAAwALgEAMAEAMgEANoEAggA4AQA8AQA&amp;s=4adc7b3cf7f16d3046ebc86d8ff055112a36cc7a</Impression>
         <Creatives>
            <Creative AdID="27209779">
               <Linear>
                  <VideoClicks>
                     <ClickTracking>http://ams1-ib.adnxs.com/click?AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAO6KfTEGDKHgAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAzMJ8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwUAAAAAAAEAOgSsIwAAAAA./bn=0/clickenc=</ClickTracking>
                  </VideoClicks>
               </Linear>
            </Creative>
         </Creatives>
         <Extensions>
            <Extension type="Value">
               <Bid currency="USD" source="AppNexus">0</Bid>
            </Extension>
         </Extensions>
      </Wrapper>
   </Ad>
</VAST>
  • Call to vast-client-js
 var xmlStr = <value from above>
 var parser = new window.DOMParser()
 parser.parseFromString(xmlStr, "text/xml")
 DMVAST.client.get('', {response: xmlDoc}, function(response, error) {});

Ad parse failure on URI encoded query strings

Encoded query strings (in the media URI) are cause the ad parse logic to fail.

<MediaFiles>
  <MediaFile apiFramework="VPAID" type="application/javascript" delivery="progressive" ...>
    <![CDATA[parser.js?adData=http%3A%2F%2Fad.com%2F%3Fcb%3D%5Btime%5D]]>
    </MediaFile>
</MediaFiles>

Note: using decodeURIComponent solves the issue.

Support for parsing <Extensions> in <InLine>

We have a use case where we need to get at the values within . Seeing as by spec value can be any valid XML. I'm proposing a very generic parsed response. It'd be an array of extension elements each with name, value, attributes where they are string, string, object respectively. It'll be up to the end user to parse the value of each extension any farther as that would be custom code for the situation.

Catch HTTPS-->HTTP error

I want to show a VAST Preview on my HTTPS site, the user can provide VASTs with their videos.

Some users however use insecure HTTP videos. In the vast-client.js there is a separate check to catch and throw an error in that case.
But I was not able to catch that error inside my DMVAST.client.get() call.

Is there any way to catch that error so I can provide a specific error handling to the user?

Error Handling in vast-client.js (parsed from xmlhttprequest.coffee)

XHRURLHandler.get = function(url, options, cb) {
var xhr;
if (window.location.protocol === 'https:' && url.indexOf('http://') === 0) {
return cb(new Error('Cannot go from HTTPS to HTTP.'));
}
...

[Question]Active tracking for nonlinear/companion clickthrough

Hi,

I use this very nice parser for my project and currently, I can't find a solution to active tracking clickthrough for nonlinear or companion ads. For example, for linear this:
ad - container for linear ad
tracker - new DMVAST.tracker(adv.ad, adv.creative)
`

        //Set clickthrough on a linear ad.

        ad.addEventListener('click', function() {

            // Do VAST tracking for clickThrough

            tracker.click();

        });

        tracker.on('clickthrough', function(url) {

            log('clickthrough tracking URLs have been called - Linear');

            // Open clicktrough URL into a new window

            window.open(url);

        });

`

code works nice.
Any suggestions?

Thanks,
Stevan

Ad Pod vs Standalone Ad

As far as I understand VAST 3.0 spec - I thought that ads with sequence attribute are to be in group (pod) to be played as a group while stand alone ads - those without sequence should be separate. For example if any of the ad inside pod fail to load - player can chose one from the stand alone ad what spec calls ad buffet. From my initial test - it seems like there is no distinction made by the DMVAST client between ads that belong to a pod and those that are stand alone ads. Am I mistaken in thinking they should be separated? I'd appreciate your thoughts on this.

Tester Failing on Valid VAST Files

If you try out any of the sample VAST files from iab, they don't seem to pass your [http://dailymotion.github.io/vast-client-js/#/test](vast tester).

I think the problem is here because the callback for client.get takes cbk(error, response), and it looks like the valid response is being passed as an error.

"minSuggestedDuration" in seconds (as duration)

Hi,
i like this tool so much :) Thanks for the good work! 👍

With nonLinear Ads you return the duration: "00:00:30" and with linearAds: "30".
Maybe something like this would be fine:

nonlinearAd.minSuggestedDuration = this.parseDuration(nonlinearResource.getAttribute("minSuggestedDuration"));

Thanks :)

Request for AltText for StaticResource companion ad

Hello and thanks for this great tool!

We noticed that the parser doesn't parse altText attribute if a staticresource is being served
in file vast-client-js/src/companionad.coffee the VASTCompanionAd class doen't define an alttext property

class VASTCompanionAd
    constructor: ->
        @id = null
        @width = 0
        @height = 0
        @type = null
        @staticResource = null
        @htmlResource = null
        @iframeResource = null
        @companionClickThroughURLTemplate = null
        @trackingEvents = {}

module.exports = VASTCompanionAd

Is this a bug? or is there any other way we can fetch the alttext property?
Is this going to be developed?

thanks a lot in advance

Impression urls getting fired before actual ad start

Hi Michael,

I was looking at the tracker code and noticed that the impression URLs are dispatched when load is called on the VASTTracker.
As per IAB standards for video ads, the impressions should get dispatched after the ad has started playing.
Also, when the ads fails, the impression is getting logged in case of a VPAID ad.

Do you think this is an issue and if yes, will be addressed in the vast-client?

Error cannot resolve module `fs`

Keep seeing the error Error cannot resolve module 'fs' when trying to import vast-client-js as follows var vast = require('vast-client');.

Nonlinear Support

Do you consider implementing nonlinears? Due to tightly coupled structure of the code it is not really easy to implement as a separate module.

Extract CompanionClickTracking value from companion ads

According to the VAST spec, companion ads can have an optional CompanionClickTracking property which "contains a URI to a location or file that the video player should request when the user clicks on the companion creative." Currently the client extracts the CompanionClickThrough property but doesn't extract CompanionClickTracking. Would it be possible to add support for this property to the VAST client?

It seems like it might be a small change to that part of the parser code but I couldn't tell if there would be any side-effects or potential problems resulting from modifying it:
https://github.com/dailymotion/vast-client-js/blob/master/src/parser.coffee#L388

Ideally the value would be returned on the companion ad object as something like
companionAd.companionClickTrackingURLTemplate

Duration Error when no ":"

Hi,
i know in the specs there has to be HH:MM:SS but i know people who write "120".
Then the player freeze with no Duration.

In "VASTParser.parseDuration" i write:
if (!(durationString != null)) {
return -1;
}
if (durationString.indexOf(":") < 0) {
return durationString;
}

BR

exposing VAST-errors

Hi guys,

i want to link our metrics-system with the parser to track all VAST-errors popping up.
There is currently no way to do this afaik.

Two scenarios i can see working here.

a) pass an additional error-callback through client.get() to parser.parse()
or
b) wrap VASTUtil.track() with a function which emits an 'VAST-error' event.

what do you guys think make sense here?
Thanks for looking into this.
cheers,
Hannes

Uncaught TypeError: Cannot read property 'replace' of undefined When VAST file with empty impression is returned from DFP

Hi Guys

I am getting this error when I use the plugin

Uncaught TypeError: Cannot read property 'replace' of undefined vast-client.js:1409 
VASTUtil.resolveURLTemplatesvast-client.js:1378 VASTUtil.track vast-client.js:1214 
VASTTracker.trackURLsvast-client.js:1143 VASTTracker.load videojs. vast.js:130 
Vast.setupEvents.canplayFnvideo.dev.js:868 retvideo.dev.js:343 data.dispatcher video.dev.js:588 
vjs.triggervideo.dev.js:2196 vjs.Component.trigger video.dev.js:6403 
vjs.Html5.eventHandlervideo.dev.js:868 ret video.dev.js:343 data.dispatcher

I have been investigating this error for a while and it seems that the cause of it is the VAST file that DFP returns. Which contains and empty impressions tag like the one below

...
<Impression>
<![CDATA[ ]]>
</Impression>
...

What happens is that when the parser (https://github.com/dailymotion/vast-client-js/blob/master/src/parser.coffee) is parsing the xml on line 187

  when "Impression"
                    ad.impressionURLTemplates.push (@parseNodeText node)

Since the impression is empty the this code adds undefined to ad.impressionURLTemplates
This is a problem for the tracker (https://github.com/dailymotion/vast-client-js/blob/master/src/tracker.coffee) when you try to track the impression url templates on line 98

 load: ->
        unless @impressed
            @impressed = yes
            @trackURLs @ad.impressionURLTemplates
            @track "creativeView"

Without going too much in detail you end up in the VASTUtil.track function (https://github.com/dailymotion/vast-client-js/blob/master/src/util.coffee) that as you see below, is not ready to deal with undefined items

class VASTUtil
    @track: (URLTemplates, variables) ->
        URLs = @resolveURLTemplates(URLTemplates, variables)
        for URL in URLs
            if window?
                i = new Image()
                i.src = URL
            else
                # node mode, do not track (unit test only)

    @resolveURLTemplates: (URLTemplates, variables) ->
        URLs = []

        variables ?= {} # ["CACHEBUSTING", "random", "CONTENTPLAYHEAD", "ASSETURI", "ERRORCODE"]
        unless "CACHEBUSTING" of variables
            variables["CACHEBUSTING"] = Math.round(Math.random() * 1.0e+10)
        variables["random"] = variables["CACHEBUSTING"] # synonym for Auditude macro

        for URLTemplate in URLTemplates
            resolveURL = URLTemplate
            continue unless resolveURL
            for key, value of variables
                macro1 = "[#{key}]"
                macro2 = "%%#{key}%%"
                resolveURL = resolveURL.replace(macro1, value)
                resolveURL = resolveURL.replace(macro2, value)
            URLs.push resolveURL

        return URLs

I would have issued a pull request but my knowledge of coffeescript is unexisting.
Can you please do something about it?

VideoClicks child-node attributes are missing

The ad object returned does not include the expected VideoClicks child-node attributes. Note, I'm testing for the ClickThrough id attribute.

<VideoClicks>
  <ClickThrough id="my-id">...</ClickThrough>
</VideoClicks>

See IAB spec, page 67

Architecture issue

Hey guys,

I'm trying to use this in a componentised way (we implement this in our platform, but I'm building a standalone debugger). What I want to do should be relatively straight forward if it wasn't so tightly coupled:

  • Show choice: By URL or By XML
  • If By XML, show CodeMirror editor and have our employees input XML
  • If By URL, run through VASTClient.client.

The problem here is when users choose By XML. Because of the way the client is structured, there's no way to just parse XML to the Object literal format you use, without invoking URLHandler.get. This seems like "bad architecture". The XML parser should be a static method on Parser, and be invokable without needing to call URLHandler.get. Would you be interested in a PR for this?

Thanks!

Try to load VAST URL over HTTPS if location is HTTPS

Thanks for this great library.

I would like to propose an improvement for the Ad Tag Waterfalling.

In case the Ad Player is integrated on a secure site and one of the Ad Tags in the waterfall is pointing to a non secure site, the complete process is stopped.

XHRURLHandler.get = function(url, options, cb) {
    var xhr;
    if (window.location.protocol === 'https:' && url.indexOf('http://') === 0) {
      return cb(new Error('XHRURLHandler: Cannot go from HTTPS to HTTP.'));
    }

Because most AdServes support http and https, the Handler should try to fix the configuration error and load the URL via https instead of stopping.

ClickThrough node is null.

The ClickThrough node in VideoClicks returns null. Note that the ClickTracking node works as expected.

<VideoClicks>
  <ClickThrough>...</ClickThrough>
  <ClickTracking id="test1">...</ClickTracking>
  <ClickTracking id="test2">...</ClickTracking>
</VideoClicks>

How do I actually use the this? What is 'player'?

Sorry for the question, but how do I actually use this?

In my head I included 'vast-client.js'

and then I copied the code from shown as shown in usage

but there is now object named player as used in:

player.vastTracker = new DMVAST.tracker(ad, creative);
player.vastTracker.on('clickthrough', function(url)
{
 document.location.href = url;
});
player.on('canplay', function() {this.vastTracker.load();});
player.on('timeupdate', function() {this.vastTracker.setProgress(this.currentTime);});
player.on('play', function() {this.vastTracker.setPaused(false);});
player.on('pause', function() {this.vastTracker.setPaused(true);});

I tried setting player to the video element of my page but this is obviously no the expected element since it does not have the on method.

Where is player created?

Thanks for clarification!

AdParameters not being parsed in case of a nonlinearAd VAST xml tag.

<NonLinearAds>
<NonLinear id="793" height="-2" width="-2" maintainAspectRatio="true" scalable="true" apiFramework="VPAID">
<StaticResource creativeType="application/x-javascript">
<![CDATA[ //www.hello.com/tags/vpaid.js ]]>
</StaticResource>
<AdParameters>
<![CDATA[
{"key":"value}
]]>
</AdParameters>
</NonLinear>
</NonLinearAds>

The AdParameters is not being parsed in case of a NonLinear Ad.

IE 8

There are some JS errors on IE7 and IE8.
Maybe one should add a workaround?
Array.prototype.forEach.call(...);
CSSStyleDeclaration.prototype.getProperty = function(a) {return this.getAttribute(a);};
CSSStyleDeclaration.prototype.setProperty = function(a,b) {return this.setAttribute(a,b);}
CSSStyleDeclaration.prototype.removeProperty = function(a) {return this.removeAttribute(a);}

Passing macros to the tracker and VASTClient

First of all thank you very much for your excellent tool.

Because my ad player lives in an iframe, i need to pass the referrer and domain inside the get and track URLs as parameters.

I have seen that i can pass variables to the function trackURLs, but this would mean, that I would clutter my code for all tracking events passing in the right variables.

Maybe there is a solution where an variables object with macros could be passed to the tracker and the VASTClient on initialization which are used for all ad requests and tracking events.

For my use case I would need especially:
{WIDTH}
{HEIGHT}
{REFERRER}
{DOMAIN}
{LOCATION_LAT}
{LOCATION_LONG}
{IP_ADDRESS}
{USER_AGENT}

I am sorry for not providing a PR, but I am not used to coffee script.

Vast 3.0?

Is this client up to date with Vast 3.0? If so, could you put it in the README?

Thanks!

Cannot bundle on Windows

Hi,

I hit a snag with the project bundling on Windows when running command:

npm run-script bundle

> [email protected] bundle C:\xampp\htdocs\vast-client-js
> browserify -s DMVAST -c 'coffee -scb' --extension=.coffee src/index.coffee -o vast-client.js

C:\xampp\htdocs\vast-client-js\node_modules\shell-quote\index.js:16
    return s.match(/(['"])((\\\1|[^\1])*?)\1|(\\ |\S)+/g)
             ^

TypeError: s.match is not a function
    at exports.parse (C:\xampp\htdocs\vast-client-js\node_modules\shell-quote\index.js:16:14)
    at C:\xampp\htdocs\vast-client-js\node_modules\browserify\bin\args.js:174:23
    at Array.forEach (native)
    at module.exports (C:\xampp\htdocs\vast-client-js\node_modules\browserify\bin\args.js:173:10)
    at Object.<anonymous> (C:\xampp\htdocs\vast-client-js\node_modules\browserify\bin\cmd.js:6:26)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Krzysztof\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "bundle"
npm ERR! node v6.3.1
npm ERR! npm  v3.8.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] bundle: `browserify -s DMVAST -c 'coffee -scb' --extension=.coffee src/index.coffee -o vast-client.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] bundle script 'browserify -s DMVAST -c 'coffee -scb' --extension=.coffee src/index.coffee -o vast-client.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vast-client package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     browserify -s DMVAST -c 'coffee -scb' --extension=.coffee src/index.coffee -o vast-client.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vast-client
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vast-client
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\xampp\htdocs\vast-client-js\npm-debug.log

My environment is:

  • Windows 7 Pro (64x)
  • Node v6.3.1
  • NPM v3.8.7

Where I can find a docs or some demo?

Hello! Great library!

But actually, not so clear how to use it. Where I can find a docs or some demo?

Even in Usage section example we have player variable, but I can't find where it was defined? What player variable is? HTML5 player defined somewhere else? Or what?

It will be nice, if someone give more concrete example for basic case: "we have a VAST compatible URL, we need to parse it to get video url, tracking events urls etc. And we need to play this video and track events in defined points". Can someone give an example how to use this library for that?

Problem with wrapper, VASTAdTagURI and TrackingEvents

I’m trying to display an add in videojs using the onion vast plugin which uses vast-client. As soon as I have <TrackingEvents>, vast-client bombs saying for example Uncaught TypeError: Cannot read property 'complete' of undefined.

If I remove the content of <TrackingEvents>, then everything works and the ad displays. Any ideas what could be going on?

Here’s the XML I used:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vast.xsd" version="3.0">
  <Ad id="1">
    <Wrapper>
      <AdSystem>AdGear RTB</AdSystem>
      <VASTAdTagURI><![CDATA[http://ad3.liverail.com/?LR_PUBLISHER_ID=1331&LR_CAMPAIGN_ID=229&LR_SCHEMA=vast2#sthash.I98E97KQ.dpuf]]></VASTAdTagURI>
      <Impression><![CDATA[http://www.google.com]]></Impression>
      <Error><![CDATA[http://www.mytracker.com?vast3_error_[ERRORCODE].gif]]></Error>
      <Creatives>
        <Creative>
          <Linear>
            <TrackingEvents>
              <Tracking event="complete"><![CDATA[http://www.mytracker.com?complete.gif]]></Tracking>
              <Tracking event="firstQuartile"><![CDATA[http://www.mytracker.com?firstQuartile.gif]]></Tracking>
              <Tracking event="fullscreen"><![CDATA[http://www.mytracker.com?fullscreen.gif]]></Tracking>
              <Tracking event="midpoint"><![CDATA[http://www.mytracker.com?midpoint.gif]]></Tracking>
              <Tracking event="mute"><![CDATA[http://www.mytracker.com?mute.gif]]></Tracking>
              <Tracking event="pause"><![CDATA[http://www.mytracker.com?pause.gif]]></Tracking>
              <Tracking event="resume"><![CDATA[http://www.mytracker.com?resume.gif]]></Tracking>
              <Tracking event="rewind"><![CDATA[http://www.mytracker.com?rewind.gif]]></Tracking>
              <Tracking event="start"><![CDATA[http://www.mytracker.com?start.gif]]></Tracking>
              <Tracking event="thirdQuartile"><![CDATA[http://www.mytracker.com?thirdQuartile.gif]]></Tracking>
              <Tracking event="unmute"><![CDATA[http://www.mytracker.com?unmute.gif]]></Tracking>
            </TrackingEvents>
            <VideoClicks>
              <ClickTracking><![CDATA[http://www.mytracker.com?click.gif]]></ClickTracking>
            </VideoClicks>

          </Linear>
        </Creative>
      </Creatives>
    </Wrapper>
  </Ad>
</VAST>

Problem when parsing empty creative

I have only experimented this error from time to time whenever I got an empty creative

   <Creative><![CDATA[]]></Creative>

I imagine that is not very common but still it throws an error from time to time that prevents the ads from loading.

I have tracked down the error to the '_parse' function in https://github.com/dailymotion/vast-client-js/blob/master/src/parser.coffee

on line 122 you have

creative.trackingEvents[eventName] or= []

This line compiles to

(_base = creative.trackingEvents)[eventName] || (_base[eventName] = []);

having _base variable declared at the beginning of the function with undefined value
So if

creative.trackingEvents)[eventName]

is undefined, it tries to define

_base[eventName] = [])

and since _base is undefine, the virtual machine throws an error.

Can you please take a look at it??

progress event doesnt supported

VAST 3.0 spec says we can track ads progress with quartiles and progress event in same time but vast client doesn't support progress event

XMLHttpRequest.overrideMimeType throws error in IE

Hi. XHRURLHandler.get has a call to XMLHttpRequest.overrideMimeType. This call throws an error in IE10 for me.

From https://github.com/dailymotion/vast-client-js/blob/master/src/urlhandlers/xmlhttprequest.coffee:

        try
            xhr = @xhr()
            xhr.open('GET', url)
            xhr.timeout = options.timeout or 0
            xhr.withCredentials = options.withCredentials or false
            xhr.overrideMimeType('text/xml');
            xhr.onreadystatechange = ->
                if xhr.readyState == 4
                    cb(null, xhr.responseXML)
            xhr.send()
        catch
            cb()

Can we add a quick check for the existence of overrideMimeType before the function call to prevent throwing an error?

Thanks.

Wrapper support

Could you please ad support for VAST wrappers? I'm using DFP and we often have wrappers in our VAST response. The response is getting returned as undefined.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.