1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-29 02:57:21 +02:00

@dmlap expose the xhr helper utility. closes #2321

This commit is contained in:
David LaPalomento 2015-07-21 18:58:55 -04:00
parent 843a57765d
commit b097016215
3 changed files with 34 additions and 1 deletions

View File

@ -72,6 +72,7 @@ CHANGELOG
* @dmlap export a basic played() on techs ([view](https://github.com/videojs/video.js/pull/2384))
* @dmlap use seekable on source handlers when defined ([view](https://github.com/videojs/video.js/pull/2376))
* @dmlap fire seeking in the flash tech, not the SWF ([view](https://github.com/videojs/video.js/pull/2372))
* @dmlap expose the xhr helper utility ([view](https://github.com/videojs/video.js/pull/2321))
--------------------

View File

@ -13,6 +13,7 @@ import * as Fn from './utils/fn.js';
import assign from 'object.assign';
import { createTimeRange } from './utils/time-ranges.js';
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';
@ -357,6 +358,37 @@ videojs.log = log;
*/
videojs.createTimeRange = createTimeRange;
/**
* 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){

View File

@ -45,7 +45,7 @@ var xhr = function(options, callback){
}
// Merge with default options
mergeOptions({
options = mergeOptions({
method: 'GET',
timeout: 45 * 1000
}, options);