fetchVAST(url, wrapperDepth = 0, previousUrl = null) {
    return new Promise((resolve, reject) => {
      // Process url with defined filter
      this.URLTemplateFilters.forEach((filter) => {
        url = filter(url);
      });

      this.parentURLs.push(url);
      const timeBeforeGet = Date.now();
      this.emit('VAST-resolving', {
        url,
        previousUrl,
        wrapperDepth,
        maxWrapperDepth: this.maxWrapperDepth,
        timeout: this.fetchingOptions.timeout,
      });

      this.urlHandler.get(
        url,
        this.fetchingOptions,
        (error, xml, details = {}) => {
          const deltaTime = Math.round(Date.now() - timeBeforeGet);
          const info = Object.assign(
            {
              url,
              previousUrl,
              wrapperDepth,
              error,
              duration: deltaTime,
            },
            details
          );

          this.emit('VAST-resolved', info);

          updateEstimatedBitrate(details.byteLength, deltaTime);

          if (error) {
            reject(error);
          } else {
            resolve(xml);
          }
        }
      );
    });
  }
/**
   * Fetches a VAST document for the given url.
   * Returns a Promise which resolves,rejects according to the result of the request.
   * @param  {String} url - The url to request the VAST document.
   * @param {Number} wrapperDepth - how many times the current url has been wrapped
   * @param {String} previousUrl - url of the previous VAST
   * @emits  VASTParser#VAST-resolving
   * @emits  VASTParser#VAST-resolved
   * @return {Promise}
   */
Fetches a VAST document for the given url.
Returns a Promise which resolves,rejects according to the result of the request.
@param  {String} url - The url to request the VAST document.
Fetches a VAST document for the given url . Returns a Promise which resolves rejects according to the result of the request . @param { String } url - The url to request the VAST document .
fetchVAST(url, wrapperDepth = 0, previousUrl = null) {
    return new Promise((resolve, reject) => {
      this.URLTemplateFilters.forEach((filter) => {
        url = filter(url);
      });
      this.parentURLs.push(url);
      const timeBeforeGet = Date.now();
      this.emit('VAST-resolving', {
        url,
        previousUrl,
        wrapperDepth,
        maxWrapperDepth: this.maxWrapperDepth,
        timeout: this.fetchingOptions.timeout,
      });
      this.urlHandler.get(
        url,
        this.fetchingOptions,
        (error, xml, details = {}) => {
          const deltaTime = Math.round(Date.now() - timeBeforeGet);
          const info = Object.assign(
            {
              url,
              previousUrl,
              wrapperDepth,
              error,
              duration: deltaTime,
            },
            details
          );
          this.emit('VAST-resolved', info);
          updateEstimatedBitrate(details.byteLength, deltaTime);
          if (error) {
            reject(error);
          } else {
            resolve(xml);
          }
        }
      );
    });
  }
fetchVAST ( url , wrapperDepth = 0 , previousUrl = null ) { return new Promise ( ( resolve , reject ) => { this . URLTemplateFilters . forEach ( ( filter ) => { url = filter ( url ) ; } ) ; this . parentURLs . push ( url ) ; const timeBeforeGet = Date . now ( ) ; this . emit ( 'VAST-resolving' , { url , previousUrl , wrapperDepth , maxWrapperDepth : this . maxWrapperDepth , timeout : this . fetchingOptions . timeout , } ) ; this . urlHandler . get ( url , this . fetchingOptions , ( error , xml , details = { } ) => { const deltaTime = Math . round ( Date . now ( ) - timeBeforeGet ) ; const info = Object . assign ( { url , previousUrl , wrapperDepth , error , duration : deltaTime , } , details ) ; this . emit ( 'VAST-resolved' , info ) ; updateEstimatedBitrate ( details . byteLength , deltaTime ) ; if ( error ) { reject ( error ) ; } else { resolve ( xml ) ; } } ) ; } ) ; }
Fetches a VAST document for the given url.
Fetches a VAST document for the given url .
// Process url with defined filter