Skip to content

Commit

Permalink
Fix Tech's sourceHandler deferring to work with IE
Browse files Browse the repository at this point in the history
  • Loading branch information
jrivera committed Oct 30, 2015
1 parent 4b67a05 commit b7b0c12
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions src/js/tech/tech.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,32 +572,25 @@ Tech.withSourceHandlers = function(_Tech){
* When using a source handler, prefer its implementation of
* any function normally provided by the tech.
*/
let techProto = _Tech.prototype;
let deferrable = [
'seekable',
'duration'
];

Object.keys(techProto)
.filter(function onlyFunctions(key) {
return typeof this[key] === 'function';
}, techProto)
.filter(function onlyDeferrableKeys(key) {
return Boolean(deferrable.indexOf(key) + 1);
}, techProto)
.map(function getFunctions(key) {
return this[key];
}, techProto)
.forEach(function wrapFunctions(originalFn) {
let fnName = originalFn.name;

this[fnName] = function() {
if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments);
}
return originalFn.apply(this, arguments);
};
}, techProto);
deferrable.forEach(function (fnName) {
let originalFn = this[fnName];

if (typeof originalFn !== 'function') {
return;
}

this[fnName] = function() {
if (this.sourceHandler_ && this.sourceHandler_[fnName]) {
return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments);
}
return originalFn.apply(this, arguments);
};
}, _Tech.prototype);

/*
* Create a function for setting the source using a source object
Expand Down

0 comments on commit b7b0c12

Please sign in to comment.