Table of contents of this page:

Welcome to Viblast Documentation

Everything you need to know about Viblast Solutions. For more information contact us.

Viblast Documentation

XHR Manipulation

Viblast exposes the xhrBeforeSend callback that can be used to manipulate an XHR object before it is sent. Use this to set custom headers, etc. Here is its general form:

viblast("#playid").setup({
  // as usual
  xhrBeforeSend: function(ev) {
    console.log('Sending a ', ev.method, 'request to ', ev.url, 'by Viblast instance', ev.target);
  }
});

The single argument passed to xhrBeforeSend has the following properties:

  • target - the viblast instance
  • xhr - the XMLHttpRequest itself
  • method - the method of the HTTP request
  • url - the URL of the HTTP request

video.js

Using xhrBeforeSend with video.js is very similar:

videojs("playerid", {
  viblast: {
    // as usual
    xhrBeforeSend: function(ev) {
      console.log('Sending a ', ev.method, 'request to ', ev.url, 'by Viblast instance', ev.target);
    }
  }
});

As always you can find an example in our Codepen page.

Beware

Use this API with caution. Don't override things like responseType because viblast.js will break.