Skip to content

Commit

Permalink
Expose vjs xhr
Browse files Browse the repository at this point in the history
While we wait for Raynos/xhr to allow for downstream testing, expose our own XHR shim. An alternative to #2318.
  • Loading branch information
dmlap committed Jul 8, 2015
1 parent 49fbea6 commit e45e763
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import mergeOptions from '../../src/js/utils/merge-options.js';

import assign from 'object.assign';
import log from './utils/log.js';
import xhr from './xhr.js';
import * as Dom from './utils/dom.js';
import * as browser from './utils/browser.js';
import extendsFn from './extends.js';
Expand Down Expand Up @@ -307,6 +308,37 @@ videojs.addLanguage = function(code, data){
return merge(globalOptions.languages, { [code]: data })[code];
};

/**
* Simple http request for retrieving external files (e.g. text tracks)
*
* ##### Example
*
* // using url string
* videojs.xhr('http://example.com/myfile.vtt', function(error, response, responseBody){});
*
* // or options block
* videojs.xhr({
* uri: 'http://example.com/myfile.vtt',
* method: 'GET',
* responseType: 'text'
* }, function(error, response, responseBody){
* if (error) {
* // log the error
* } else {
* // successful, do something with the response
* }
* });
*
*
* API is modeled after the Raynos/xhr.
* https://github.com/Raynos/xhr/blob/master/index.js
*
* @param {Object|String} options Options block or URL string
* @param {Function} callback The callback function
* @returns {Object} The request
*/
videojs.xhr = xhr;

// REMOVING: We probably should add this to the migration plugin
// // Expose but deprecate the window[componentName] method for accessing components
// Object.getOwnPropertyNames(Component.components).forEach(function(name){
Expand Down

0 comments on commit e45e763

Please sign in to comment.