Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer the implementation of select functions in the tech to source handlers if they provide them #2760

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/js/tech/tech.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,29 @@ Tech.withSourceHandlers = function(_Tech){
return '';
};

let originalSeekable = _Tech.prototype.seekable;
/*
* When using a source handler, prefer its implementation of
* any function normally provided by the tech.
*/
let deferrable = [
'seekable',
'duration'
];

// when a source handler is registered, prefer its implementation of
// seekable when present.
_Tech.prototype.seekable = function() {
if (this.sourceHandler_ && this.sourceHandler_.seekable) {
return this.sourceHandler_.seekable();
deferrable.forEach(function (fnName) {
let originalFn = this[fnName];

if (typeof originalFn !== 'function') {
return;
}
return originalSeekable.call(this);
};

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